Fix device add/remove handlers
This commit is contained in:
@@ -1,7 +1,35 @@
|
||||
#include "ApplicationData.h"
|
||||
#include "Util.h"
|
||||
#include "AudioApi.h"
|
||||
#include <functiondiscoverykeys.h>
|
||||
|
||||
AudioDevice::AudioDevice()
|
||||
AudioDevice::AudioDevice(IMMDevice* device, LPCWSTR deviceId)
|
||||
{
|
||||
id = std::wstring(deviceId);
|
||||
|
||||
IPropertyStore* propertyStore;
|
||||
HRESULT err = device->OpenPropertyStore(STGM_READ, &propertyStore);
|
||||
isError(err, "Failed to open prop store: ");
|
||||
|
||||
PROPVARIANT deviceNameProp;
|
||||
const wchar_t* deviceName;
|
||||
err = getDevicePropertyString(propertyStore, PKEY_Device_FriendlyName, &deviceNameProp, deviceName);
|
||||
isError(err, "Failed to read name of device :");
|
||||
name = utf8Encode(deviceName);
|
||||
|
||||
err = device->GetState(&state);
|
||||
isError(err, "Failed to reat state of device: ");
|
||||
|
||||
err = device->Activate(__uuidof(IAudioEndpointVolume), CLSCTX_INPROC_SERVER, NULL, (LPVOID*)&volumeInterface);
|
||||
isError(err, "Failed to get audio endpoint volume interface: ");
|
||||
|
||||
err = device->Activate(__uuidof(IAudioMeterInformation), CLSCTX_INPROC_SERVER, NULL, (LPVOID*)&meterInterface);
|
||||
isError(err, "Failed to get audio meter interface: ");
|
||||
|
||||
if (propertyStore)
|
||||
{
|
||||
propertyStore->Release();
|
||||
}
|
||||
}
|
||||
|
||||
AudioDevice::AudioDevice(AudioDevice&& other) noexcept
|
||||
|
||||
Reference in New Issue
Block a user