summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Mitchell <kevmitch@gmail.com>2015-12-29 01:13:17 -0800
committerKevin Mitchell <kevmitch@gmail.com>2016-01-04 07:41:21 -0800
commitefb99436370fdb60e4b816dcbaf6bb20d853627b (patch)
tree34914766602d692bc7b49a379af5e29b3b8d67c5
parent243a2976a8721283e8c6ff1e6cb77230762fe9ab (diff)
downloadmpv-efb99436370fdb60e4b816dcbaf6bb20d853627b.tar.bz2
mpv-efb99436370fdb60e4b816dcbaf6bb20d853627b.tar.xz
ao_wasapi: make persistent enumerator local to change_notify
This is no longer required by anything else
-rw-r--r--audio/out/ao_wasapi.c9
-rwxr-xr-xaudio/out/ao_wasapi.h2
-rwxr-xr-xaudio/out/ao_wasapi_changenotify.c13
-rwxr-xr-xaudio/out/ao_wasapi_utils.c9
4 files changed, 12 insertions, 21 deletions
diff --git a/audio/out/ao_wasapi.c b/audio/out/ao_wasapi.c
index faea556157..37f6d3b4de 100644
--- a/audio/out/ao_wasapi.c
+++ b/audio/out/ao_wasapi.c
@@ -455,10 +455,7 @@ static void audio_resume(struct ao *ao)
static void hotplug_uninit(struct ao *ao)
{
MP_DBG(ao, "Hotplug uninit\n");
- struct wasapi_state *state = ao->priv;
wasapi_change_uninit(ao);
- SAFE_RELEASE(state->pEnumerator,
- IMMDeviceEnumerator_Release(state->pEnumerator));
CoUninitialize();
}
@@ -468,11 +465,7 @@ static int hotplug_init(struct ao *ao)
struct wasapi_state *state = ao->priv;
state->log = ao->log;
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
- HRESULT hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL,
- &IID_IMMDeviceEnumerator,
- (void **)&state->pEnumerator);
- EXIT_ON_ERROR(hr);
- hr = wasapi_change_init(ao, true);
+ HRESULT hr = wasapi_change_init(ao, true);
EXIT_ON_ERROR(hr);
return 0;
diff --git a/audio/out/ao_wasapi.h b/audio/out/ao_wasapi.h
index f54e63a783..d7a650c3e3 100755
--- a/audio/out/ao_wasapi.h
+++ b/audio/out/ao_wasapi.h
@@ -30,6 +30,7 @@
typedef struct change_notify {
IMMNotificationClient client; // this must be first in the structure!
+ IMMDeviceEnumerator *pEnumerator; // object where client is registered
LPWSTR monitored; // Monitored device
bool is_hotplug;
struct ao *ao;
@@ -69,7 +70,6 @@ typedef struct wasapi_state {
IMMDevice *pDevice;
IAudioClient *pAudioClient;
IAudioRenderClient *pRenderClient;
- IMMDeviceEnumerator *pEnumerator;
// WASAPI internal clock information, for estimating delay
IAudioClock *pAudioClock;
diff --git a/audio/out/ao_wasapi_changenotify.c b/audio/out/ao_wasapi_changenotify.c
index cde942fe59..69c702e283 100755
--- a/audio/out/ao_wasapi_changenotify.c
+++ b/audio/out/ao_wasapi_changenotify.c
@@ -203,13 +203,17 @@ HRESULT wasapi_change_init(struct ao *ao, bool is_hotplug)
{
struct wasapi_state *state = ao->priv;
struct change_notify *change = &state->change;
- HRESULT hr;
+ HRESULT hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL,
+ &IID_IMMDeviceEnumerator,
+ (void **)&change->pEnumerator);
+ EXIT_ON_ERROR(hr);
+
// COM voodoo to emulate c++ class
change->client.lpVtbl = &sIMMDeviceEnumeratorVtbl_vtbl;
// register the change notification client
hr = IMMDeviceEnumerator_RegisterEndpointNotificationCallback(
- state->pEnumerator, (IMMNotificationClient *)change);
+ change->pEnumerator, (IMMNotificationClient *)change);
EXIT_ON_ERROR(hr);
// so the callbacks can access the ao
@@ -240,10 +244,11 @@ void wasapi_change_uninit(struct ao *ao)
struct wasapi_state *state = ao->priv;
struct change_notify *change = &state->change;
- if (state->pEnumerator && change->client.lpVtbl) {
+ if (change->pEnumerator && change->client.lpVtbl) {
IMMDeviceEnumerator_UnregisterEndpointNotificationCallback(
- state->pEnumerator, (IMMNotificationClient *)change);
+ change->pEnumerator, (IMMNotificationClient *)change);
}
if (change->monitored) CoTaskMemFree(change->monitored);
+ SAFE_RELEASE(change->pEnumerator, IMMDeviceEnumerator_Release(change->pEnumerator));
}
diff --git a/audio/out/ao_wasapi_utils.c b/audio/out/ao_wasapi_utils.c
index fc2f8bb7aa..c68b276120 100755
--- a/audio/out/ao_wasapi_utils.c
+++ b/audio/out/ao_wasapi_utils.c
@@ -1101,13 +1101,7 @@ HRESULT wasapi_thread_init(struct ao *ao)
MP_DBG(ao, "Init wasapi thread\n");
int64_t retry_wait = 1;
retry: ;
-
- HRESULT hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL,
- &IID_IMMDeviceEnumerator,
- (void **)&state->pEnumerator);
- EXIT_ON_ERROR(hr);
-
- hr = find_device(ao);
+ HRESULT hr = find_device(ao);
EXIT_ON_ERROR(hr);
hr = load_device(ao->log, &state->pDevice, state->deviceID);
@@ -1170,7 +1164,6 @@ void wasapi_thread_uninit(struct ao *ao)
SAFE_RELEASE(state->pAudioClient, IAudioClient_Release(state->pAudioClient));
SAFE_RELEASE(state->pDevice, IMMDevice_Release(state->pDevice));
SAFE_RELEASE(state->deviceID, talloc_free(state->deviceID));
- SAFE_RELEASE(state->pEnumerator, IMMDeviceEnumerator_Release(state->pEnumerator));
SAFE_RELEASE(state->hTask, AvRevertMmThreadCharacteristics(state->hTask));
MP_DBG(ao, "Thread uninit done\n");
}