summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-04-20 07:33:13 +0200
committerwm4 <wm4@nowhere>2017-04-20 07:33:13 +0200
commit05e6d423d9211d940a247ae23c99198985f20cb3 (patch)
tree46fc2d568df3e2beab288d7a6b0795061bfd2af4 /audio
parent5ae25ae42449b29edcb5d4561ef83f950fd26683 (diff)
downloadmpv-05e6d423d9211d940a247ae23c99198985f20cb3.tar.bz2
mpv-05e6d423d9211d940a247ae23c99198985f20cb3.tar.xz
ao_wasapi_changenotify: fix potential race condition
IMMDeviceEnumerator_RegisterEndpointNotificationCallback() will start listening for notifications, and is the point at which callbacks can start firing. These callbacks will read the fields we set after the register calls, which is a potential race condition. Move it upwards.
Diffstat (limited to 'audio')
-rw-r--r--audio/out/ao_wasapi_changenotify.c16
1 files changed, 8 insertions, 8 deletions
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",