[vlc-devel] [PATCH 1/3] mmdevice: improve volume/mute set/get
Thomas Guillem
thomas at gllm.fr
Mon Oct 3 17:43:51 CEST 2016
Don't call GetMasterVolume/GetMute just after a SetMasterVolume/SetMute.
Volume and mute are now reported after the values are set.
---
modules/audio_output/mmdevice.c | 41 ++++++++++++++++++++++++-----------------
1 file changed, 24 insertions(+), 17 deletions(-)
diff --git a/modules/audio_output/mmdevice.c b/modules/audio_output/mmdevice.c
index 161fde8..e544f66 100644
--- a/modules/audio_output/mmdevice.c
+++ b/modules/audio_output/mmdevice.c
@@ -944,12 +944,6 @@ static HRESULT MMSession(audio_output_t *aout, IMMDeviceEnumerator *it)
{
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);
-
level = sys->volume;
if (level >= 0.f)
{
@@ -960,23 +954,36 @@ static HRESULT MMSession(audio_output_t *aout, IMMDeviceEnumerator *it)
}
sys->volume = -1.f;
- 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);
-
- if (sys->mute >= 0)
+ if (level < 0.f)
{
- mute = sys->mute ? TRUE : FALSE;
+ hr = ISimpleAudioVolume_GetMasterVolume(volume, &level);
+ if (FAILED(hr))
+ msg_Err(aout, "cannot get master volume (error 0x%lx)", hr);
+ }
+ if (level >= 0.f)
+ aout_VolumeReport(aout, cbrtf(level * sys->gain));
- hr = ISimpleAudioVolume_SetMute(volume, mute, NULL);
+ signed char mute = sys->mute;
+ if (mute >= 0)
+ {
+ hr = ISimpleAudioVolume_SetMute(volume, mute ? TRUE : FALSE,
+ NULL);
if (FAILED(hr))
msg_Err(aout, "cannot set mute (error 0x%lx)", hr);
}
sys->mute = -1;
+
+ if (mute < 0)
+ {
+ BOOL get_mute;
+ hr = ISimpleAudioVolume_GetMute(volume, &get_mute);
+ if (SUCCEEDED(hr))
+ mute = get_mute;
+ else
+ msg_Err(aout, "cannot get mute (error 0x%lx)", hr);
+ }
+ if (mute >= 0)
+ aout_MuteReport(aout, mute != FALSE);
}
SleepConditionVariableCS(&sys->work, &sys->lock, INFINITE);
--
2.9.3
More information about the vlc-devel
mailing list