[vlc-commits] [Git][videolan/vlc][3.0.x] audio_output/winstore: report initial volume/mute status

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Thu Sep 16 19:24:08 UTC 2021



Jean-Baptiste Kempf pushed to branch 3.0.x at VideoLAN / VLC


Commits:
6ea058bf by Johannes Kauffmann at 2021-09-16T19:00:14+00:00
audio_output/winstore: report initial volume/mute status

Previously, the volume and mute properties would read their default
values (0 and false respectively) since neither Open() or Start()
would call aout_{Volume,Mute}Report by themselves.
Now, the initial volume and mute status are read during Start(), which
means that setting the volume should work after the first
volume_changed event is received by a libvlc consumer.

Partial workaround for #26032.

As a result, reporting the volume level after (un)muting is no longer
necessary (d104faec191b47630871aaab546ccd76e08b730d).

(cherry picked from commit 3a163f8190319c09db3b4c31640f0f53fbbe885f) (edited)

edited:
- omitted cast to void** for pc_AudioVolume

- - - - -


1 changed file:

- modules/audio_output/winstore.c


Changes:

=====================================
modules/audio_output/winstore.c
=====================================
@@ -339,15 +339,6 @@ static int MuteSet(audio_output_t *aout, bool mute)
         goto done;
     }
 
-    float vol;
-    hr = ISimpleAudioVolume_GetMasterVolume(pc_AudioVolume, &vol);
-    if (FAILED(hr))
-    {
-        msg_Err(aout, "cannot get volume (error 0x%lX)", hr);
-        goto done;
-    }
-
-    aout_VolumeReport(aout, cbrtf(vol * sys->gain));
     aout_MuteReport(aout, mute);
 
 done:
@@ -508,6 +499,42 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
             break;
     }
 
+    // Report the initial volume and mute status to the core
+    if (sys->client != NULL)
+    {
+        ISimpleAudioVolume* pc_AudioVolume = NULL;
+
+        hr = IAudioClient_GetService(sys->client, &IID_ISimpleAudioVolume, &pc_AudioVolume);
+        if (FAILED(hr))
+        {
+            msg_Err(aout, "cannot get volume service (error 0x%lx)", hr);
+            goto done;
+        }
+
+        float vol;
+        hr = ISimpleAudioVolume_GetMasterVolume(pc_AudioVolume, &vol);
+        if (FAILED(hr))
+        {
+            msg_Err(aout, "cannot get initial volume (error 0x%lX)", hr);
+            goto done;
+        }
+
+        WINBOOL mute;
+        hr = ISimpleAudioVolume_GetMute(pc_AudioVolume, &mute);
+        if (FAILED(hr))
+        {
+            msg_Err(aout, "cannot get initial mute (error 0x%lX)", hr);
+            goto done;
+        }
+
+        aout_VolumeReport(aout, cbrtf(vol * sys->gain));
+        aout_MuteReport(aout, mute != 0);
+
+    done:
+        if (pc_AudioVolume)
+            ISimpleAudioVolume_Release(pc_AudioVolume);
+    }
+
     LeaveCriticalSection(&sys->lock);
     LeaveMTA();
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/6ea058bf2d0813dab247f973b2d7bc9804486d81

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/6ea058bf2d0813dab247f973b2d7bc9804486d81
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list