[vlc-devel] [PATCH 4/4] auhal: use ca_MuteSet
Thomas Guillem
thomas at gllm.fr
Wed Apr 21 15:00:41 UTC 2021
Fix data race with au_unit. Indeed, the aout can be muted from any
threads.
SPDIF playback can now be muted.
---
modules/audio_output/auhal.c | 38 ++++++-------------------
modules/audio_output/coreaudio_common.h | 2 ++
2 files changed, 11 insertions(+), 29 deletions(-)
diff --git a/modules/audio_output/auhal.c b/modules/audio_output/auhal.c
index 739c857f851..b2fce91b76e 100644
--- a/modules/audio_output/auhal.c
+++ b/modules/audio_output/auhal.c
@@ -120,7 +120,6 @@ typedef struct
vlc_mutex_t selected_device_lock;
float f_volume;
- bool b_mute;
bool b_ignore_streams_changed_callback;
} aout_sys_t;
@@ -915,15 +914,12 @@ VolumeSet(audio_output_t * p_aout, float volume)
aout_VolumeReport(p_aout, volume);
/* Set volume for output unit */
- if (!p_sys->b_mute)
- {
- ostatus = AudioUnitSetParameter(p_sys->au_unit,
- kHALOutputParam_Volume,
- kAudioUnitScope_Global,
- 0,
- volume * volume * volume,
- 0);
- }
+ ostatus = AudioUnitSetParameter(p_sys->au_unit,
+ kHALOutputParam_Volume,
+ kAudioUnitScope_Global,
+ 0,
+ volume * volume * volume,
+ 0);
if (var_InheritBool(p_aout, "volume-save"))
config_PutInt("auhal-volume", lroundf(volume * AOUT_VOLUME_DEFAULT));
@@ -934,24 +930,10 @@ VolumeSet(audio_output_t * p_aout, float volume)
static int
MuteSet(audio_output_t * p_aout, bool mute)
{
- aout_sys_t *p_sys = p_aout->sys;
-
- if(p_sys->b_digital)
- return VLC_EGENERIC;
-
- p_sys->b_mute = mute;
+ ca_MuteSet(p_aout, mute);
aout_MuteReport(p_aout, mute);
- float volume = .0;
- if (!mute)
- volume = p_sys->f_volume;
-
- OSStatus err =
- AudioUnitSetParameter(p_sys->au_unit, kHALOutputParam_Volume,
- kAudioUnitScope_Global, 0,
- volume * volume * volume, 0);
-
- return err == noErr ? VLC_SUCCESS : VLC_EGENERIC;
+ return VLC_SUCCESS;
}
#pragma mark -
@@ -1128,7 +1110,6 @@ StartAnalog(audio_output_t *p_aout, audio_sample_format_t *fmt)
/* Set volume for output unit */
VolumeSet(p_aout, p_sys->f_volume);
- MuteSet(p_aout, p_sys->b_mute);
free(layout);
@@ -1771,8 +1752,7 @@ static int Open(vlc_object_t *obj)
p_sys->f_volume = var_InheritInteger(p_aout, "auhal-volume")
/ (float)AOUT_VOLUME_DEFAULT;
aout_VolumeReport(p_aout, p_sys->f_volume);
- p_sys->b_mute = var_InheritBool(p_aout, "mute");
- aout_MuteReport(p_aout, p_sys->b_mute);
+ MuteSet(p_aout, var_InheritBool(p_aout, "mute"));
return VLC_SUCCESS;
}
diff --git a/modules/audio_output/coreaudio_common.h b/modules/audio_output/coreaudio_common.h
index 1a8f50c0898..f806187d3db 100644
--- a/modules/audio_output/coreaudio_common.h
+++ b/modules/audio_output/coreaudio_common.h
@@ -117,3 +117,5 @@ int au_Initialize(audio_output_t *p_aout, AudioUnit au,
bool *warn_configuration);
void au_Uninitialize(audio_output_t *p_aout, AudioUnit au);
+
+void au_VolumeSet(audio_output_t *p_aout);
--
2.30.0
More information about the vlc-devel
mailing list