diff options
Diffstat (limited to 'audio/out/ao_wasapi_changenotify.c')
-rwxr-xr-x | audio/out/ao_wasapi_changenotify.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/audio/out/ao_wasapi_changenotify.c b/audio/out/ao_wasapi_changenotify.c index cde942fe59..69c702e283 100755 --- a/audio/out/ao_wasapi_changenotify.c +++ b/audio/out/ao_wasapi_changenotify.c @@ -203,13 +203,17 @@ HRESULT wasapi_change_init(struct ao *ao, bool is_hotplug) { struct wasapi_state *state = ao->priv; struct change_notify *change = &state->change; - HRESULT hr; + HRESULT hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, + &IID_IMMDeviceEnumerator, + (void **)&change->pEnumerator); + EXIT_ON_ERROR(hr); + // COM voodoo to emulate c++ class change->client.lpVtbl = &sIMMDeviceEnumeratorVtbl_vtbl; // register the change notification client hr = IMMDeviceEnumerator_RegisterEndpointNotificationCallback( - state->pEnumerator, (IMMNotificationClient *)change); + change->pEnumerator, (IMMNotificationClient *)change); EXIT_ON_ERROR(hr); // so the callbacks can access the ao @@ -240,10 +244,11 @@ void wasapi_change_uninit(struct ao *ao) struct wasapi_state *state = ao->priv; struct change_notify *change = &state->change; - if (state->pEnumerator && change->client.lpVtbl) { + if (change->pEnumerator && change->client.lpVtbl) { IMMDeviceEnumerator_UnregisterEndpointNotificationCallback( - state->pEnumerator, (IMMNotificationClient *)change); + change->pEnumerator, (IMMNotificationClient *)change); } if (change->monitored) CoTaskMemFree(change->monitored); + SAFE_RELEASE(change->pEnumerator, IMMDeviceEnumerator_Release(change->pEnumerator)); } |