[vlc-devel] [PATCH 1/7] mmdevice: add "Default" device

Hugo Beauzée-Luyssen hugo at beauzee.fr
Tue Feb 27 14:07:07 CET 2018


On Tue, Feb 27, 2018, at 2:03 PM, Rémi Denis-Courmont wrote:
> Le 27 février 2018 14:57:45 GMT+02:00, "Hugo Beauzée-Luyssen" 
> <hugo at beauzee.fr> a écrit :
> >On Tue, Feb 27, 2018, at 1:51 PM, Rémi Denis-Courmont wrote:
> >> Le 27 février 2018 12:41:05 GMT+02:00, Thomas Guillem
> ><thomas at gllm.fr> a écrit :
> >> >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
> >> >---
> >> > modules/audio_output/mmdevice.c | 27 +++++++++++++++++++--------
> >> > 1 file changed, 19 insertions(+), 8 deletions(-)
> >> >
> >> >diff --git a/modules/audio_output/mmdevice.c
> >> >b/modules/audio_output/mmdevice.c
> >> >index 731474848b..48d05ad2d6 100644
> >> >--- a/modules/audio_output/mmdevice.c
> >> >+++ b/modules/audio_output/mmdevice.c
> >> >@@ -71,6 +71,7 @@ static void LeaveMTA(void)
> >> > }
> >> > 
> >> > static wchar_t default_device[1] = L"";
> >> >+static char default_device_b[1] = "";
> >> > 
> >> > struct aout_sys_t
> >> > {
> >> >@@ -111,6 +112,8 @@ struct aout_sys_t
> >> >  * and (trivially) the device and session notifications. */
> >> > 
> >> > static int DeviceSelect(audio_output_t *, const char *);
> >> >+static int DeviceSelectLocked(audio_output_t *t, const char *);
> >> >+
> >> > static int vlc_FromHR(audio_output_t *aout, HRESULT hr)
> >> > {
> >> >     /* Select the default device (and restart) on unplug */
> >> >@@ -733,7 +736,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))
> >> >@@ -835,15 +838,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);
> >> >+                }
> >> >             }
> >> >         }
> >> >     }
> >> >@@ -1227,6 +1235,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;
> >> >@@ -1264,6 +1274,7 @@ static int Open(vlc_object_t *obj)
> >> >     aout->volume_set = VolumeSet;
> >> >     aout->mute_set = MuteSet;
> >> >     aout->device_select = DeviceSelect;
> >> >+
> >> >     return VLC_SUCCESS;
> >> > 
> >> > error:
> >> >-- 
> >> >2.11.0
> >> >
> >> >_______________________________________________
> >> >vlc-devel mailing list
> >> >To unsubscribe or modify your subscription options:
> >> >https://mailman.videolan.org/listinfo/vlc-devel
> >> 
> >> I wouldn't call that "following" external changes. Following external
> >
> >> changes ought to involve automatically moving *and* automatically 
> >> reporting the device change.
> >> 
> >> Also, IIRC*, Windows mixer does not show "default" as a target to
> >move a 
> >> stream to.
> >> 
> >
> >It does not, as the device selection list basically represents the
> >default device (to be fair, I don't recall how things are presented on
> >Windows before Win10)
> >
> >> With that noted, I think it is much better to report the current
> >device 
> >> in audio menu than to show "Default" there.
> >> 
> >
> >I disagree. Having a "Default" virtual device allows you to say
> >"whichever is selected by windows", but also allows you to explicitly
> >pin VLC to a specific device.
> >Not having a default device means that when windows defaults change, we
> >also change, which I find to be an unintuitive behavior.
> >
> >> * I don't have access to a Windows Vista or later installation
> >anymore. 
> >> 
> >
> >
> >-- 
> >  Hugo Beauzée-Luyssen
> >  hugo at beauzee.fr
> >_______________________________________________
> >vlc-devel mailing list
> >To unsubscribe or modify your subscription options:
> >https://mailman.videolan.org/listinfo/vlc-devel
> 
> Default is necessary in configuration, if only because a default value 
> is needed. In run-time Audio menu, it's counter-intuitive, if the 
> platform itself does not exhibit such an option.
> 
> Oh sure, it means the user cannot explicitly switch between the current 
> default device and the abstract default choice. That seems like a rather 
> small loss compared to not seeing what the current device actually is.
> -- 
> Remi Denis-Courmont

I don't understand your point.
The platform exposes a default device, the application offers you a choice to abide by that setting, or to use a different device explicitly.

-- 
  Hugo Beauzée-Luyssen
  hugo at beauzee.fr


More information about the vlc-devel mailing list