From efb99436370fdb60e4b816dcbaf6bb20d853627b Mon Sep 17 00:00:00 2001 From: Kevin Mitchell Date: Tue, 29 Dec 2015 01:13:17 -0800 Subject: ao_wasapi: make persistent enumerator local to change_notify This is no longer required by anything else --- audio/out/ao_wasapi_changenotify.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'audio/out/ao_wasapi_changenotify.c') 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)); } -- cgit v1.2.3