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

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Mon Sep 13 12:37:42 UTC 2021



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
3a163f81 by Johannes Kauffmann at 2021-09-13T12:15:26+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).

- - - - -


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:
@@ -502,6 +493,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, (void**)&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/3a163f8190319c09db3b4c31640f0f53fbbe885f

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




More information about the vlc-commits mailing list