[vlc-commits] [Git][videolan/vlc][3.0.x] 2 commits: mmdevice: report volume and mute only when necessary

Steve Lhomme (@robUx4) gitlab at videolan.org
Sun Sep 27 01:22:17 UTC 2026



Steve Lhomme pushed to branch 3.0.x at VideoLAN / VLC


Commits:
1ef4f638 by Thomas Guillem at 2026-09-27T01:13:19+00:00
mmdevice: report volume and mute only when necessary

When volume or mute was changed, both volume and mute were reported.

(cherry picked from commit d5fe154f074c9dc5d9ff0bca63e1e744cc6c8429)
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>

- - - - -
efd110e1 by Ayush Dey at 2026-09-27T01:13:19+00:00
mmdevice: report external session volume and mute changes

(cherry picked from commit 7700507b85062319d5d818e8dfab697eff2da46f)
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>

- - - - -


1 changed file:

- modules/audio_output/mmdevice.c


Changes:

=====================================
modules/audio_output/mmdevice.c
=====================================
@@ -108,6 +108,7 @@ struct aout_sys_t
     enum device_acquisition_status device_status;
     atomic_uintptr_t device_name; /**< device identifier to use, 0 if default */
     atomic_bool default_device_changed;
+    atomic_bool session_volume_changed; /**< Flag to check if session volume/mute changed */
     vlc_sem_t init_passed;
     CRITICAL_SECTION lock;
     CONDITION_VARIABLE work;
@@ -296,8 +297,9 @@ vlc_AudioSessionEvents_OnSimpleVolumeChanged(IAudioSessionEvents *this,
 
     msg_Dbg(aout, "simple volume changed: %f, muting %sabled", vol,
             mute ? "en" : "dis");
+    atomic_store(&sys->session_volume_changed, true);
     EnterCriticalSection(&sys->lock);
-    WakeConditionVariable(&sys->work); /* implicit state: vol & mute */
+    WakeConditionVariable(&sys->work);
     LeaveCriticalSection(&sys->lock);
     (void) ctx;
     return S_OK;
@@ -807,44 +809,58 @@ static void MMSessionMainloop(audio_output_t *aout, ISimpleAudioVolume *volume)
     aout_sys_t *sys = aout->sys;
     HRESULT hr;
 
+    bool report_volume = true;
+    bool report_mute = true;
+
     while (sys->device_status != DEVICE_PENDING)
     {
         if (volume != NULL)
         {
-            float level;
+            if (atomic_exchange(&sys->session_volume_changed, false))
+                report_volume = report_mute = true;
 
-            level = sys->requested_volume;
-            if (level >= 0.f)
+            if (sys->requested_volume >= 0.f)
             {
-                hr = ISimpleAudioVolume_SetMasterVolume(volume, level, NULL);
+                hr = ISimpleAudioVolume_SetMasterVolume(volume, sys->requested_volume, NULL);
                 if (FAILED(hr))
                     msg_Err(aout, "cannot set master volume (error 0x%lX)",
                             hr);
+                report_volume = true;
+                sys->requested_volume = -1.f;
             }
-            sys->requested_volume = -1.f;
 
-            hr = ISimpleAudioVolume_GetMasterVolume(volume, &level);
-            if (SUCCEEDED(hr))
-                aout_VolumeReport(aout, cbrtf(level * sys->gain));
-            else
-                msg_Err(aout, "cannot get master volume (error 0x%lX)", hr);
+            if (report_volume)
+            {
+                float level;
+                hr = ISimpleAudioVolume_GetMasterVolume(volume, &level);
+                if (SUCCEEDED(hr))
+                    aout_VolumeReport(aout, cbrtf(level * sys->gain));
+                else
+                    msg_Err(aout, "cannot get master volume (error 0x%lX)", hr);
+                report_volume = false;
+            }
 
-            BOOL mute;
             if (sys->requested_mute >= 0)
             {
-                mute = sys->requested_mute ? TRUE : FALSE;
+                BOOL mute = sys->requested_mute ? TRUE : FALSE;
 
                 hr = ISimpleAudioVolume_SetMute(volume, mute, NULL);
                 if (FAILED(hr))
                     msg_Err(aout, "cannot set mute (error 0x%lX)", hr);
+                report_mute = true;
+                sys->requested_mute = -1;
             }
-            sys->requested_mute = -1;
 
-            hr = ISimpleAudioVolume_GetMute(volume, &mute);
-            if (SUCCEEDED(hr))
-                aout_MuteReport(aout, mute != FALSE);
-            else
-                msg_Err(aout, "cannot get mute (error 0x%lX)", hr);
+            if (report_mute)
+            {
+                BOOL mute;
+                hr = ISimpleAudioVolume_GetMute(volume, &mute);
+                if (SUCCEEDED(hr))
+                    aout_MuteReport(aout, mute != FALSE);
+                else
+                    msg_Err(aout, "cannot get mute (error 0x%lX)", hr);
+                report_mute = false;
+            }
         }
 
         SleepConditionVariableCS(&sys->work, &sys->lock, INFINITE);
@@ -1320,6 +1336,7 @@ static int Open(vlc_object_t *obj)
     sys->requested_volume = -1.f;
     sys->requested_mute = -1;
     atomic_init(&sys->default_device_changed, false);
+    atomic_init(&sys->session_volume_changed, false);
 
     if (!var_CreateGetBool(aout, "volume-save"))
         VolumeSetLocked(aout, var_InheritFloat(aout, "mmdevice-volume"));



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/58f19304cbc30a42bc0a954b10d122a0155c1f2d...efd110e1a9be543bca2512bd56e5c0a638abc9c5

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/58f19304cbc30a42bc0a954b10d122a0155c1f2d...efd110e1a9be543bca2512bd56e5c0a638abc9c5
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help




More information about the vlc-commits mailing list