Whitespace and pointer cleanup.
This commit is contained in:
parent
6fc0b8dca8
commit
a03eb9599f
32 changed files with 441 additions and 468 deletions
|
@ -10,73 +10,73 @@ const IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator);
|
|||
|
||||
int main()
|
||||
{
|
||||
CoInitialize(nullptr);
|
||||
IMMDeviceEnumerator* pEnumerator = nullptr;
|
||||
IMMDeviceCollection* pDeviceCollection = nullptr;
|
||||
HRESULT hr = S_OK;
|
||||
CoInitialize(nullptr);
|
||||
IMMDeviceEnumerator* pEnumerator = nullptr;
|
||||
IMMDeviceCollection* pDeviceCollection = nullptr;
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
hr = CoCreateInstance(CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL,
|
||||
IID_IMMDeviceEnumerator, (void**)& pEnumerator);
|
||||
if (!pEnumerator)
|
||||
{
|
||||
std::cout << "Failed to populate enumerator" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
hr = CoCreateInstance(CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL,
|
||||
IID_IMMDeviceEnumerator, (void**)& pEnumerator);
|
||||
if (!pEnumerator)
|
||||
{
|
||||
std::cout << "Failed to populate enumerator" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
hr = pEnumerator->EnumAudioEndpoints(eRender, DEVICE_STATE_ACTIVE, &pDeviceCollection);
|
||||
UINT count;
|
||||
hr = pDeviceCollection->GetCount(&count);
|
||||
if (count == 0)
|
||||
{
|
||||
std::cout << "No devices found\n";
|
||||
}
|
||||
// Each loop prints the name of an endpoint device.
|
||||
IMMDevice* pEndpoint = nullptr;
|
||||
IPropertyStore* pProps = nullptr;
|
||||
LPWSTR pwszID = nullptr;
|
||||
for (ULONG i = 0; i < count; i++)
|
||||
{
|
||||
// Get pointer to endpoint number i.
|
||||
hr = pDeviceCollection->Item(i, &pEndpoint);
|
||||
hr = pEnumerator->EnumAudioEndpoints(eRender, DEVICE_STATE_ACTIVE, &pDeviceCollection);
|
||||
UINT count;
|
||||
hr = pDeviceCollection->GetCount(&count);
|
||||
if (count == 0)
|
||||
{
|
||||
std::cout << "No devices found\n";
|
||||
}
|
||||
// Each loop prints the name of an endpoint device.
|
||||
IMMDevice* pEndpoint = nullptr;
|
||||
IPropertyStore* pProps = nullptr;
|
||||
LPWSTR pwszID = nullptr;
|
||||
for (ULONG i = 0; i < count; i++)
|
||||
{
|
||||
// Get pointer to endpoint number i.
|
||||
hr = pDeviceCollection->Item(i, &pEndpoint);
|
||||
|
||||
// Get the endpoint ID string.
|
||||
hr = pEndpoint->GetId(&pwszID);
|
||||
hr = pEndpoint->OpenPropertyStore(STGM_READ, &pProps);
|
||||
// Get the endpoint ID string.
|
||||
hr = pEndpoint->GetId(&pwszID);
|
||||
hr = pEndpoint->OpenPropertyStore(STGM_READ, &pProps);
|
||||
|
||||
PROPVARIANT varName;
|
||||
// Initialize container for property value.
|
||||
PropVariantInit(&varName);
|
||||
PROPVARIANT varName;
|
||||
// Initialize container for property value.
|
||||
PropVariantInit(&varName);
|
||||
|
||||
// Get the endpoint's friendly-name property.
|
||||
hr = pProps->GetValue(PKEY_Device_FriendlyName, &varName);
|
||||
// Get the endpoint's friendly-name property.
|
||||
hr = pProps->GetValue(PKEY_Device_FriendlyName, &varName);
|
||||
|
||||
// Print endpoint friendly name and endpoint ID.
|
||||
std::cout << "Endpoint: " << i << " " << varName.pwszVal << " " << pwszID << std::endl;
|
||||
CoTaskMemFree(pwszID);
|
||||
pwszID = nullptr;
|
||||
// Print endpoint friendly name and endpoint ID.
|
||||
std::cout << "Endpoint: " << i << " " << varName.pwszVal << " " << pwszID << std::endl;
|
||||
CoTaskMemFree(pwszID);
|
||||
pwszID = nullptr;
|
||||
|
||||
PropVariantClear(&varName);
|
||||
if (pProps)
|
||||
{
|
||||
pProps->Release();
|
||||
pProps = nullptr;
|
||||
}
|
||||
if (pEndpoint)
|
||||
{
|
||||
pEndpoint->Release();
|
||||
pEndpoint = nullptr;
|
||||
}
|
||||
}
|
||||
if (pEnumerator)
|
||||
{
|
||||
pEnumerator->Release();
|
||||
pEnumerator = nullptr;
|
||||
}
|
||||
if (pDeviceCollection)
|
||||
{
|
||||
pDeviceCollection->Release();
|
||||
pDeviceCollection = nullptr;
|
||||
}
|
||||
return 0;
|
||||
PropVariantClear(&varName);
|
||||
if (pProps)
|
||||
{
|
||||
pProps->Release();
|
||||
pProps = nullptr;
|
||||
}
|
||||
if (pEndpoint)
|
||||
{
|
||||
pEndpoint->Release();
|
||||
pEndpoint = nullptr;
|
||||
}
|
||||
}
|
||||
if (pEnumerator)
|
||||
{
|
||||
pEnumerator->Release();
|
||||
pEnumerator = nullptr;
|
||||
}
|
||||
if (pDeviceCollection)
|
||||
{
|
||||
pDeviceCollection->Release();
|
||||
pDeviceCollection = nullptr;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,33 +6,33 @@
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
CommandLineArgs command_line_args;
|
||||
command_line_args.Process(argc, argv);
|
||||
CommandLineArgs command_line_args;
|
||||
command_line_args.Process(argc, argv);
|
||||
|
||||
if(command_line_args.GetNumberOfArgs() < 2)
|
||||
{
|
||||
std::cerr << "Expected a filepath argument" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
if(command_line_args.GetNumberOfArgs() < 2)
|
||||
{
|
||||
std::cerr << "Expected a filepath argument" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
XmlParser parser;
|
||||
const auto filepath = command_line_args.GetArg(1);
|
||||
XmlParser parser;
|
||||
const auto filepath = command_line_args.GetArg(1);
|
||||
|
||||
if(!std::filesystem::exists(filepath))
|
||||
{
|
||||
std::cerr << "Couldn't find file: " << filepath << std::endl;
|
||||
return -1;
|
||||
}
|
||||
if(!std::filesystem::exists(filepath))
|
||||
{
|
||||
std::cerr << "Couldn't find file: " << filepath << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::ifstream xml_file;
|
||||
xml_file.open(filepath, std::ifstream::in);
|
||||
while(xml_file.good())
|
||||
{
|
||||
std::string line;
|
||||
std::getline(xml_file, line);
|
||||
parser.ProcessLine(line);
|
||||
}
|
||||
xml_file.close();
|
||||
std::ifstream xml_file;
|
||||
xml_file.open(filepath, std::ifstream::in);
|
||||
while(xml_file.good())
|
||||
{
|
||||
std::string line;
|
||||
std::getline(xml_file, line);
|
||||
parser.ProcessLine(line);
|
||||
}
|
||||
xml_file.close();
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue