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_utils.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'audio/out/ao_wasapi_utils.c') 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; -- cgit v1.2.3