[vlc-commits] mmdevice: refactor DevicesEnum()
Thomas Guillem
git at videolan.org
Thu Mar 1 10:28:53 CET 2018
vlc/vlc-3.0 | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Feb 27 11:24:01 2018 +0100| [993aa80c6bdac6f3754f2bfdd59876019eabf188] | committer: Thomas Guillem
mmdevice: refactor DevicesEnum()
In order to be used by the change_string_cb callback (see next commit).
(cherry picked from commit d073b9c9d8178c74028b70e8878cdae4177e4361)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=993aa80c6bdac6f3754f2bfdd59876019eabf188
---
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 d68862ed7c..0bb59ae07c 100644
--- a/modules/audio_output/mmdevice.c
+++ b/modules/audio_output/mmdevice.c
@@ -685,16 +685,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;
}
@@ -702,7 +705,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;
}
@@ -725,7 +728,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++;
@@ -1046,6 +1049,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;
@@ -1055,7 +1065,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