[vlc-devel] [PATCH 1/2] mmdevice: handle "--no-volume-save"

Thomas Guillem thomas at gllm.fr
Tue Feb 27 14:47:07 CET 2018



On Tue, Feb 27, 2018, at 14:42, Rémi Denis-Courmont wrote:
> Le 27 février 2018 15:37:38 GMT+02:00, Thomas Guillem <thomas at gllm.fr> a écrit :
> >
> >
> >On Tue, Feb 27, 2018, at 14:21, Rémi Denis-Courmont wrote:
> >> Le 27 février 2018 14:59:48 GMT+02:00, Thomas Guillem
> ><thomas at gllm.fr> a écrit :
> >> >It's handled the other way around than old aout modules.
> >> >
> >> >By default, "volume-save" is true and we keep the current behavior
> >(the
> >> >volume
> >> >is saved by Windows for this session). If "volume-save" is false,
> >then
> >> >we use
> >> >the prefered volume set by the user "mmdevice-volume".
> >> >
> >> >This reverts commit 6bbc6b6cb191f1a4dd29bd059c90e9cbaf0edb16.
> >> >
> >> >Fixes #19664
> >> >---
> >> > modules/audio_output/mmdevice.c | 26 ++++++++++++++++++++------
> >> > 1 file changed, 20 insertions(+), 6 deletions(-)
> >> >
> >> >diff --git a/modules/audio_output/mmdevice.c
> >> >b/modules/audio_output/mmdevice.c
> >> >index ca142f5d6a..7980125cec 100644
> >> >--- a/modules/audio_output/mmdevice.c
> >> >+++ b/modules/audio_output/mmdevice.c
> >> >@@ -197,7 +197,7 @@ static void Flush(audio_output_t *aout, bool
> >wait)
> >> >     vlc_FromHR(aout, hr);
> >> > }
> >> > 
> >> >-static int VolumeSet(audio_output_t *aout, float vol)
> >> >+static int VolumeSetLocked(audio_output_t *aout, float vol)
> >> > {
> >> >     aout_sys_t *sys = aout->sys;
> >> >     float gain = 1.f;
> >> >@@ -212,12 +212,20 @@ static int VolumeSet(audio_output_t *aout,
> >float
> >> >vol)
> >> > 
> >> >     aout_GainRequest(aout, gain);
> >> > 
> >> >-    EnterCriticalSection(&sys->lock);
> >> >     sys->gain = gain;
> >> >     sys->requested_volume = vol;
> >> >+    return 0;
> >> >+}
> >> >+
> >> >+static int VolumeSet(audio_output_t *aout, float vol)
> >> >+{
> >> >+    aout_sys_t *sys = aout->sys;
> >> >+
> >> >+    EnterCriticalSection(&sys->lock);
> >> >+    int ret = VolumeSetLocked(aout, vol);
> >> >     WakeConditionVariable(&sys->work);
> >> >     LeaveCriticalSection(&sys->lock);
> >> >-    return 0;
> >> >+    return ret;
> >> > }
> >> > 
> >> > static int MuteSet(audio_output_t *aout, bool mute)
> >> >@@ -1266,9 +1274,6 @@ static void Stop(audio_output_t *aout)
> >> > 
> >> > static int Open(vlc_object_t *obj)
> >> > {
> >> >-    if (!var_InheritBool(obj, "volume-save"))
> >> >-        return VLC_EGENERIC;
> >> >-
> >> >     audio_output_t *aout = (audio_output_t *)obj;
> >> > 
> >> >     aout_sys_t *sys = malloc(sizeof (*sys));
> >> >@@ -1291,6 +1296,10 @@ static int Open(vlc_object_t *obj)
> >> >     sys->requested_volume = -1.f;
> >> >     sys->requested_mute = -1;
> >> >     sys->acquired_device = NULL;
> >> >+
> >> >+    if (!var_InheritBool(aout, "volume-save"))
> >> >+        VolumeSetLocked(aout, var_InheritFloat(aout,
> >> >"mmdevice-volume"));
> >> >+
> >> >     InitializeCriticalSection(&sys->lock);
> >> >     InitializeConditionVariable(&sys->work);
> >> >     InitializeConditionVariable(&sys->ready);
> >> >@@ -1475,6 +1484,9 @@ static const char *const
> >> >ppsz_mmdevice_passthrough_texts[] = {
> >> > #define DEVICE_TEXT N_("Output device")
> >> > #define DEVICE_LONGTEXT N_("Select your audio output device")
> >> > 
> >> >+#define VOLUME_TEXT N_("Audio volume")
> >> >+#define VOLUME_LONGTEXT N_("Audio volume in hundredths of decibels
> >> >(dB).")
> >> >+
> >> > vlc_module_begin()
> >> >     set_shortname("MMDevice")
> >> >     set_description(N_("Windows Multimedia Device output"))
> >> >@@ -1491,4 +1503,6 @@ vlc_module_begin()
> >> >                              ppsz_mmdevice_passthrough_texts )
> >> >add_string("mmdevice-audio-device", NULL, DEVICE_TEXT,
> >DEVICE_LONGTEXT,
> >> >false)
> >> >         change_string_cb(ReloadAudioDevices)
> >> >+    add_float("mmdevice-volume", 1.f, VOLUME_TEXT, VOLUME_LONGTEXT,
> >> >true)
> >> >+        change_float_range( 0.f, 1.25f )
> >> > vlc_module_end()
> >> >-- 
> >> >2.11.0
> >> >
> >> >_______________________________________________
> >> >vlc-devel mailing list
> >> >To unsubscribe or modify your subscription options:
> >> >https://mailman.videolan.org/listinfo/vlc-devel
> >> 
> >> This is wrong. It will corrupt the volume saved in the OS, thus
> >messing 
> >> with other instances and LibVLC apps.
> >
> >It's already the case without this patch. If 2 programs based on LibVLC
> >are used, they will mess each others, changing the last volume used of
> >the other.
> >
> >> -- 
> >> Remi Denis-Courmont
> >> _______________________________________________
> >> vlc-devel mailing list
> >> To unsubscribe or modify your subscription options:
> >> https://mailman.videolan.org/listinfo/vlc-devel
> >_______________________________________________
> >vlc-devel mailing list
> >To unsubscribe or modify your subscription options:
> >https://mailman.videolan.org/listinfo/vlc-devel
> 
> Without this patch, the volume that is saved is the volume that is 
> expected. With this patch, there are no such warranties anymore.
> 
> As noted yesterday, if/when application forces the volume, it should not 
> use a session.

https://msdn.microsoft.com/en-us/library/windows/desktop/dd370963(v=vs.85).aspx

"If this parameter is NULL or points to the value GUID_NULL, the method assigns the stream to the default session."

So, I should try that ? I want this session to be always forgotten in that case.

> -- 
> Remi Denis-Courmont
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list