summaryrefslogtreecommitdiffstats
path: root/audio/out/ao_wasapi.c
diff options
context:
space:
mode:
authorKevin Mitchell <kevmitch@gmail.com>2015-03-31 01:56:17 -0700
committerKevin Mitchell <kevmitch@gmail.com>2015-03-31 02:02:54 -0700
commita6bf38bcadafd3f7b08b63d8ea1642a9f351f6e6 (patch)
treee7fb5b2f4d13d452499ac45022444f63c17a336a /audio/out/ao_wasapi.c
parent1091353d476b7187c8cfd350dbb98d2d1ad6d07c (diff)
downloadmpv-a6bf38bcadafd3f7b08b63d8ea1642a9f351f6e6.tar.bz2
mpv-a6bf38bcadafd3f7b08b63d8ea1642a9f351f6e6.tar.xz
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.
Diffstat (limited to 'audio/out/ao_wasapi.c')
-rw-r--r--audio/out/ao_wasapi.c20
1 files changed, 20 insertions, 0 deletions
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),