[vlc-commits] mmdevice: split DeviceHotplugReport()

Thomas Guillem git at videolan.org
Thu Mar 1 10:28:52 CET 2018


vlc/vlc-3.0 | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Feb 26 13:31:00 2018 +0100| [860d6bd470357121e6c57d2f7d13e24b95e25065] | committer: Thomas Guillem

mmdevice: split DeviceHotplugReport()

Add DeviceGetFriendlyName() that can be used to fetch the friendly name.

(cherry picked from commit 9d694a9d837ecdca87db13c0e6fbbdd40fa88650)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=860d6bd470357121e6c57d2f7d13e24b95e25065
---

 modules/audio_output/mmdevice.c | 31 ++++++++++++++++++-------------
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/modules/audio_output/mmdevice.c b/modules/audio_output/mmdevice.c
index 74af74e53d..d68862ed7c 100644
--- a/modules/audio_output/mmdevice.c
+++ b/modules/audio_output/mmdevice.c
@@ -451,25 +451,17 @@ static const struct IAudioVolumeDuckNotificationVtbl vlc_AudioVolumeDuckNotifica
 /*** Audio devices ***/
 
 /** Gets the user-readable device name */
-static int DeviceHotplugReport(audio_output_t *aout, LPCWSTR wid,
-                               IMMDevice *dev)
+static char *DeviceGetFriendlyName(IMMDevice *dev)
 {
     IPropertyStore *props;
-    char *name;
     PROPVARIANT v;
     HRESULT hr;
 
-    char *id = FromWide(wid);
-    if (unlikely(id == NULL))
-        return VLC_ENOMEM;
-
     hr = IMMDevice_OpenPropertyStore(dev, STGM_READ, &props);
     if (FAILED(hr))
-    {
-        free(id);
-        return VLC_EGENERIC;
-    }
+        return NULL;
 
+    char *name = NULL;
     PropVariantInit(&v);
     hr = IPropertyStore_GetValue(props, &PKEY_Device_FriendlyName, &v);
     if (SUCCEEDED(hr))
@@ -477,10 +469,23 @@ static int DeviceHotplugReport(audio_output_t *aout, LPCWSTR wid,
         name = FromWide(v.pwszVal);
         PropVariantClear(&v);
     }
-    else
-        name = id;
 
     IPropertyStore_Release(props);
+
+    return name;
+}
+
+static int DeviceHotplugReport(audio_output_t *aout, LPCWSTR wid,
+                               IMMDevice *dev)
+{
+    char *id = FromWide(wid);
+    if (!id)
+        return VLC_EGENERIC;
+
+    char *name = DeviceGetFriendlyName(dev);
+    if (name == NULL)
+        name = id;
+
     aout_HotplugReport(aout, id, name);
 
     free(id);



More information about the vlc-commits mailing list