[vlc-commits] mmdevice: add "Default" device

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


vlc/vlc-3.0 | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Feb 26 13:11:42 2018 +0100| [a626c3d8e4c666b4d878a01e03a6bcc1cc2d6314] | committer: Thomas Guillem

mmdevice: add "Default" device

Like for DirectSound, add the "Default" virtual device that is selected by
default and that follows Windows devices change via external programs (or via
the taskbar).

Refs #19638

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

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

 modules/audio_output/mmdevice.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/modules/audio_output/mmdevice.c b/modules/audio_output/mmdevice.c
index 473bc5dea4..9356e59949 100644
--- a/modules/audio_output/mmdevice.c
+++ b/modules/audio_output/mmdevice.c
@@ -76,6 +76,7 @@ static void LeaveMTA(void)
 }
 
 static wchar_t default_device[1] = L"";
+static char default_device_b[1] = "";
 
 struct aout_sys_t
 {
@@ -738,7 +739,7 @@ static int DeviceSelectLocked(audio_output_t *aout, const char *id)
     aout_sys_t *sys = aout->sys;
     assert(sys->requested_device == NULL);
 
-    if (id != NULL)
+    if (id != NULL && strcmp(id, default_device_b) != 0)
     {
         sys->requested_device = ToWide(id);
         if (unlikely(sys->requested_device == NULL))
@@ -840,15 +841,20 @@ static HRESULT MMSession(audio_output_t *aout, IMMDeviceEnumerator *it)
     {   /* Report actual device */
         LPWSTR wdevid;
 
-        hr = IMMDevice_GetId(sys->dev, &wdevid);
-        if (SUCCEEDED(hr))
+        if (sys->acquired_device == default_device)
+            aout_DeviceReport(aout, default_device_b);
+        else
         {
-            char *id = FromWide(wdevid);
-            CoTaskMemFree(wdevid);
-            if (likely(id != NULL))
+            hr = IMMDevice_GetId(sys->dev, &wdevid);
+            if (SUCCEEDED(hr))
             {
-                aout_DeviceReport(aout, id);
-                free(id);
+                char *id = FromWide(wdevid);
+                CoTaskMemFree(wdevid);
+                if (likely(id != NULL))
+                {
+                    aout_DeviceReport(aout, id);
+                    free(id);
+                }
             }
         }
     }
@@ -1230,6 +1236,8 @@ static int Open(vlc_object_t *obj)
     InitializeConditionVariable(&sys->work);
     InitializeConditionVariable(&sys->ready);
 
+    aout_HotplugReport(aout, default_device_b, _("Default"));
+
     /* Initialize MMDevice API */
     if (TryEnterMTA(aout))
         goto error;
@@ -1267,6 +1275,7 @@ static int Open(vlc_object_t *obj)
     aout->volume_set = VolumeSet;
     aout->mute_set = MuteSet;
     aout->device_select = DeviceSelect;
+
     return VLC_SUCCESS;
 
 error:



More information about the vlc-commits mailing list