[vlc-commits] mmdevice: handle "--no-volume-save"

Thomas Guillem git at videolan.org
Wed Feb 28 13:55:47 CET 2018


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Feb 27 13:30:57 2018 +0100| [aba1b0140878de8cc501c42a5491eaf7d70d4095] | committer: Thomas Guillem

mmdevice: handle "--no-volume-save"

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" and don't use the VLC
audio session.

Fixes #19664

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

 modules/audio_output/mmdevice.c | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/modules/audio_output/mmdevice.c b/modules/audio_output/mmdevice.c
index 0fcf4ea930..0047056dad 100644
--- a/modules/audio_output/mmdevice.c
+++ b/modules/audio_output/mmdevice.c
@@ -173,7 +173,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;
@@ -188,12 +188,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)
@@ -885,7 +893,8 @@ static HRESULT MMSession(audio_output_t *aout, IMMDeviceEnumerator *it)
     manager = pv;
     if (SUCCEEDED(hr))
     {
-        LPCGUID guid = &GUID_VLC_AUD_OUT;
+        LPCGUID guid = var_InheritBool(aout, "volume-save") ? &GUID_VLC_AUD_OUT
+                                                            : NULL;
 
         /* Register session control */
         hr = IAudioSessionManager_GetAudioSessionControl(manager, guid, 0,
@@ -1263,6 +1272,10 @@ static int Open(vlc_object_t *obj)
     sys->requested_mute = -1;
     sys->acquired_device = NULL;
     sys->request_device_restart = false;
+
+    if (!var_InheritBool(aout, "volume-save"))
+        VolumeSetLocked(aout, var_InheritFloat(aout, "mmdevice-volume"));
+
     InitializeCriticalSection(&sys->lock);
     InitializeConditionVariable(&sys->work);
     InitializeConditionVariable(&sys->ready);
@@ -1450,6 +1463,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"))
@@ -1466,4 +1482,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()



More information about the vlc-commits mailing list