[vlc-commits] mmdevice: refactor DevicesEnum()
Thomas Guillem
git at videolan.org
Wed Feb 28 13:55:42 CET 2018
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Feb 27 11:24:01 2018 +0100| [d073b9c9d8178c74028b70e8878cdae4177e4361] | committer: Thomas Guillem
mmdevice: refactor DevicesEnum()
In order to be used by the change_string_cb callback (see next commit).
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d073b9c9d8178c74028b70e8878cdae4177e4361
---
modules/audio_output/mmdevice.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/modules/audio_output/mmdevice.c b/modules/audio_output/mmdevice.c
index 66b8536379..d317cfc658 100644
--- a/modules/audio_output/mmdevice.c
+++ b/modules/audio_output/mmdevice.c
@@ -680,16 +680,19 @@ static const struct IMMNotificationClientVtbl vlc_MMNotificationClient =
vlc_MMNotificationClient_OnPropertyValueChanged,
};
-static int DevicesEnum(audio_output_t *aout, IMMDeviceEnumerator *it)
+static int DevicesEnum(vlc_object_t *this, IMMDeviceEnumerator *it,
+ void (*added_cb)(void *data, LPCWSTR wid, IMMDevice *dev),
+ void *added_cb_data)
{
HRESULT hr;
IMMDeviceCollection *devs;
+ assert(added_cb != NULL);
hr = IMMDeviceEnumerator_EnumAudioEndpoints(it, eRender,
DEVICE_STATE_ACTIVE, &devs);
if (FAILED(hr))
{
- msg_Warn(aout, "cannot enumerate audio endpoints (error 0x%lx)", hr);
+ msg_Warn(this, "cannot enumerate audio endpoints (error 0x%lx)", hr);
return -1;
}
@@ -697,7 +700,7 @@ static int DevicesEnum(audio_output_t *aout, IMMDeviceEnumerator *it)
hr = IMMDeviceCollection_GetCount(devs, &count);
if (FAILED(hr))
{
- msg_Warn(aout, "cannot count audio endpoints (error 0x%lx)", hr);
+ msg_Warn(this, "cannot count audio endpoints (error 0x%lx)", hr);
count = 0;
}
@@ -720,7 +723,7 @@ static int DevicesEnum(audio_output_t *aout, IMMDeviceEnumerator *it)
continue;
}
- DeviceHotplugReport(aout, devid, dev);
+ added_cb(added_cb_data, devid, dev);
IMMDevice_Release(dev);
CoTaskMemFree(devid);
n++;
@@ -1041,6 +1044,13 @@ static HRESULT MMSession(audio_output_t *aout, IMMDeviceEnumerator *it)
return S_OK;
}
+static void MMThread_DevicesEnum_Added(void *data, LPCWSTR wid, IMMDevice *dev)
+{
+ audio_output_t *aout = data;
+
+ DeviceHotplugReport(aout, wid, dev);
+}
+
static void *MMThread(void *data)
{
audio_output_t *aout = data;
@@ -1050,7 +1060,7 @@ static void *MMThread(void *data)
EnterMTA();
IMMDeviceEnumerator_RegisterEndpointNotificationCallback(it,
&sys->device_events);
- DevicesEnum(aout, it);
+ DevicesEnum(VLC_OBJECT(aout), it, MMThread_DevicesEnum_Added, aout);
EnterCriticalSection(&sys->lock);
More information about the vlc-commits
mailing list