summaryrefslogtreecommitdiffstats
path: root/audio/out/ao_wasapi_utils.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_utils.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_utils.c')
-rwxr-xr-xaudio/out/ao_wasapi_utils.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/audio/out/ao_wasapi_utils.c b/audio/out/ao_wasapi_utils.c
index 9e2ffe0dff..6ecc6c82a2 100755
--- a/audio/out/ao_wasapi_utils.c
+++ b/audio/out/ao_wasapi_utils.c
@@ -1211,7 +1211,7 @@ retry:
}
state->previous_volume = state->initial_volume;
- wasapi_change_init(ao);
+ wasapi_change_init(ao, false);
MP_DBG(ao, "Init wasapi thread done\n");
return S_OK;
@@ -1221,6 +1221,30 @@ exit_label:
return hr;
}
+HRESULT wasapi_hotplug_init(struct ao *ao)
+{
+ struct wasapi_state *state = (struct wasapi_state *)ao->priv;
+ HRESULT hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL,
+ &IID_IMMDeviceEnumerator, (void **)&state->pEnumerator);
+ EXIT_ON_ERROR(hr);
+
+ hr = wasapi_change_init(ao, true);
+ EXIT_ON_ERROR(hr);
+
+ return S_OK;
+exit_label:
+ MP_ERR(state, "Error setting up audio hotplug: %s (0x%"PRIx32")\n",
+ wasapi_explain_err(hr), (uint32_t) hr);
+ return hr;
+}
+
+void wasapi_hotplug_uninit(struct ao *ao)
+{
+ struct wasapi_state *state = (struct wasapi_state *)ao->priv;
+ wasapi_change_uninit(ao);
+ SAFE_RELEASE(state->pEnumerator, IMMDeviceEnumerator_Release(state->pEnumerator));
+}
+
void wasapi_thread_uninit(struct ao *ao)
{
struct wasapi_state *state = (struct wasapi_state *)ao->priv;