summaryrefslogtreecommitdiffstats
path: root/audio/out/ao_wasapi_utils.c
diff options
context:
space:
mode:
authorKevin Mitchell <kevmitch@gmail.com>2015-03-31 12:53:05 -0700
committerKevin Mitchell <kevmitch@gmail.com>2015-03-31 13:43:32 -0700
commitb6c28dd26b6415181b406e1118920b13f80286b4 (patch)
tree2a7ee7350851c83de68f76b69f53bb1b79886874 /audio/out/ao_wasapi_utils.c
parentea00fe0eebe234c5f6f0f01f7f117cca3516d4df (diff)
downloadmpv-b6c28dd26b6415181b406e1118920b13f80286b4.tar.bz2
mpv-b6c28dd26b6415181b406e1118920b13f80286b4.tar.xz
ao_wasapi: simplify hotplug
Take advantage of the fact that list_devs is called with a hotplug_inited ao. Also eliminate unnecessary nested function abstraction of hotplug_(un)init and list_devs. However, keep list_devs in ao_wasapi_utils.c since it uses the private functions get_device_id, get_device_name and exposing these would require including headers for IMMDevice in ao_wasapi_utils.h.
Diffstat (limited to 'audio/out/ao_wasapi_utils.c')
-rwxr-xr-xaudio/out/ao_wasapi_utils.c42
1 files changed, 5 insertions, 37 deletions
diff --git a/audio/out/ao_wasapi_utils.c b/audio/out/ao_wasapi_utils.c
index eb4350f96d..1b201f6b20 100755
--- a/audio/out/ao_wasapi_utils.c
+++ b/audio/out/ao_wasapi_utils.c
@@ -829,20 +829,15 @@ end:
return found;
}
-HRESULT wasapi_enumerate_devices(struct ao *ao,
- struct ao_device_list *list)
+void wasapi_list_devs(struct ao *ao, struct ao_device_list *list)
{
- IMMDeviceEnumerator *pEnumerator = NULL;
+ struct wasapi_state *state = (struct wasapi_state *)ao->priv;
IMMDeviceCollection *pDevices = NULL;
IMMDevice *pDevice = NULL;
char *name = NULL, *id = NULL;
- HRESULT hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL,
- &IID_IMMDeviceEnumerator,
- (void **)&pEnumerator);
- EXIT_ON_ERROR(hr);
- hr = IMMDeviceEnumerator_EnumAudioEndpoints(pEnumerator, eRender,
- DEVICE_STATE_ACTIVE, &pDevices);
+ HRESULT hr = IMMDeviceEnumerator_EnumAudioEndpoints(state->pEnumerator, eRender,
+ DEVICE_STATE_ACTIVE, &pDevices);
EXIT_ON_ERROR(hr);
int count;
@@ -871,9 +866,8 @@ HRESULT wasapi_enumerate_devices(struct ao *ao,
SAFE_RELEASE(pDevice, IMMDevice_Release(pDevice));
}
SAFE_RELEASE(pDevices, IMMDeviceCollection_Release(pDevices));
- SAFE_RELEASE(pEnumerator, IMMDeviceEnumerator_Release(pEnumerator));
- return S_OK;
+ return;
exit_label:
MP_ERR(ao, "Error enumerating devices: %s (0x%"PRIx32")\n",
wasapi_explain_err(hr), (uint32_t) hr);
@@ -881,8 +875,6 @@ exit_label:
talloc_free(id);
SAFE_RELEASE(pDevice, IMMDevice_Release(pDevice));
SAFE_RELEASE(pDevices, IMMDeviceCollection_Release(pDevices));
- SAFE_RELEASE(pEnumerator, IMMDeviceEnumerator_Release(pEnumerator));
- return hr;
}
static HRESULT load_default_device(struct ao *ao, IMMDeviceEnumerator* pEnumerator,
@@ -1169,30 +1161,6 @@ 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;