diff --git a/audio/out/ao_wasapi_changenotify.c b/audio/out/ao_wasapi_changenotify.c index b9806e0adb..dc529b638d 100644 --- a/audio/out/ao_wasapi_changenotify.c +++ b/audio/out/ao_wasapi_changenotify.c @@ -202,14 +202,6 @@ HRESULT wasapi_change_init(struct ao *ao, bool is_hotplug) (void **)&change->pEnumerator); EXIT_ON_ERROR(hr); - // COM voodoo to emulate c++ class - change->client.lpVtbl = &sIMMNotificationClientVtbl; - - // register the change notification client - hr = IMMDeviceEnumerator_RegisterEndpointNotificationCallback( - change->pEnumerator, (IMMNotificationClient *)change); - EXIT_ON_ERROR(hr); - // so the callbacks can access the ao change->ao = ao; @@ -224,6 +216,14 @@ HRESULT wasapi_change_init(struct ao *ao, bool is_hotplug) MP_VERBOSE(ao, "Monitoring changes in device %S\n", change->monitored); } + // COM voodoo to emulate c++ class + change->client.lpVtbl = &sIMMNotificationClientVtbl; + + // register the change notification client + hr = IMMDeviceEnumerator_RegisterEndpointNotificationCallback( + change->pEnumerator, (IMMNotificationClient *)change); + EXIT_ON_ERROR(hr); + return hr; exit_label: MP_ERR(state, "Error setting up device change monitoring: %s\n",