[vlc-devel] [PATCH 4/7] mmdevice: refactor DevicesEnum()
Rémi Denis-Courmont
remi at remlab.net
Tue Feb 27 15:35:20 CET 2018
Le 27 février 2018 12:41:08 GMT+02:00, Thomas Guillem <thomas at gllm.fr> a écrit :
>In order to be used by the change_string_cb callback (see next commit).
>---
> modules/audio_output/mmdevice.c | 23 ++++++++++++++++++-----
> 1 file changed, 18 insertions(+), 5 deletions(-)
>
>diff --git a/modules/audio_output/mmdevice.c
>b/modules/audio_output/mmdevice.c
>index cc5bbf0eec..9561b8701d 100644
>--- a/modules/audio_output/mmdevice.c
>+++ b/modules/audio_output/mmdevice.c
>@@ -708,16 +708,20 @@ 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)(vlc_object_t *, 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;
> }
>
>@@ -725,7 +729,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;
> }
>
>@@ -748,7 +752,7 @@ static int DevicesEnum(audio_output_t *aout,
>IMMDeviceEnumerator *it)
> continue;
> }
>
>- DeviceHotplugReport(aout, devid, dev);
>+ added_cb(this, added_cb_data, devid, dev);
> IMMDevice_Release(dev);
> CoTaskMemFree(devid);
> n++;
>@@ -1067,6 +1071,15 @@ static HRESULT MMSession(audio_output_t *aout,
>IMMDeviceEnumerator *it)
> return S_OK;
> }
>
>+static void MMThread_DevicesEnum_Added(vlc_object_t *this, void *data,
>+ LPCWSTR wid, IMMDevice *dev)
>+{
>+ audio_output_t *aout = (void *) this;
>+ (void) data;
>+
>+ DeviceHotplugReport(aout, wid, dev);
>+}
>+
> static void *MMThread(void *data)
> {
> audio_output_t *aout = data;
>@@ -1076,7 +1089,7 @@ static void *MMThread(void *data)
> EnterMTA();
> IMMDeviceEnumerator_RegisterEndpointNotificationCallback(it,
> &sys->device_events);
>- DevicesEnum(aout, it);
>+ DevicesEnum(VLC_OBJECT(aout), it, MMThread_DevicesEnum_Added,
>NULL);
>
> EnterCriticalSection(&sys->lock);
>
>--
>2.11.0
>
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel
Do you really need effectively two context pointers for the callback? that seems rather unusual and hackish.
--
Remi Denis-Courmont
More information about the vlc-devel
mailing list