From a6bf38bcadafd3f7b08b63d8ea1642a9f351f6e6 Mon Sep 17 00:00:00 2001 From: Kevin Mitchell Date: Tue, 31 Mar 2015 01:56:17 -0700 Subject: ao/wasapi: add ao hotplug Create a second copy of the change_notify structure for the hotplug ao. change_notify->is_hotplug distinguishes the hotplug version from the regular one monitoring the currently playing ao. Also make the change notification less verbose now that there might be two of them around. --- audio/out/ao_wasapi.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'audio/out/ao_wasapi.c') diff --git a/audio/out/ao_wasapi.c b/audio/out/ao_wasapi.c index fb045d1858..8a8d910469 100644 --- a/audio/out/ao_wasapi.c +++ b/audio/out/ao_wasapi.c @@ -391,6 +391,24 @@ static void audio_resume(struct ao *ao) SetEvent(state->hResume); } +static void hotplug_uninit(struct ao *ao) +{ + MP_DBG(ao, "Hotplug uninit\n"); + wasapi_hotplug_uninit(ao); + CoUninitialize(); +} + +static int hotplug_init(struct ao *ao) +{ + MP_DBG(ao, "Hotplug init\n"); + CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); + if (wasapi_hotplug_init(ao) != S_OK) { + hotplug_uninit(ao); + return -1; + } + return 0; +} + static void list_devs(struct ao *ao, struct ao_device_list *list) { CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); @@ -410,6 +428,8 @@ const struct ao_driver audio_out_wasapi = { .reset = audio_reset, .resume = audio_resume, .list_devs = list_devs, + .hotplug_init = hotplug_init, + .hotplug_uninit = hotplug_uninit, .priv_size = sizeof(wasapi_state), .options = (const struct m_option[]) { OPT_FLAG("exclusive", opt_exclusive, 0), -- cgit v1.2.3