[vlc-devel] [PATCH 1/4] coreaudio: add ca_MuteSet()
Thomas Guillem
thomas at gllm.fr
Wed Apr 21 15:00:38 UTC 2021
This will write 0s from the render callback without touching at the
playback buffer state.
---
modules/audio_output/coreaudio_common.c | 16 +++++++++++++++-
modules/audio_output/coreaudio_common.h | 3 +++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/modules/audio_output/coreaudio_common.c b/modules/audio_output/coreaudio_common.c
index fd8ee7279d6..4c96a1ffbd6 100644
--- a/modules/audio_output/coreaudio_common.c
+++ b/modules/audio_output/coreaudio_common.c
@@ -189,7 +189,10 @@ ca_Render(audio_output_t *p_aout, uint32_t i_frames, uint64_t i_host_time,
while (p_block != NULL && i_requested != 0)
{
size_t i_tocopy = __MIN(i_requested, p_block->i_buffer);
- memcpy(p_output, p_block->p_buffer, i_tocopy);
+ if (unlikely(p_sys->b_muted))
+ memset(p_output, 0, i_tocopy);
+ else
+ memcpy(p_output, p_block->p_buffer, i_tocopy);
i_requested -= i_tocopy;
i_copied += i_tocopy;
p_output += i_tocopy;
@@ -299,6 +302,16 @@ ca_Pause(audio_output_t * p_aout, bool pause, vlc_tick_t date)
lock_unlock(p_sys);
}
+void
+ca_MuteSet(audio_output_t * p_aout, bool muted)
+{
+ struct aout_sys_common *p_sys = (struct aout_sys_common *) p_aout->sys;
+
+ lock_lock(p_sys);
+ p_sys->b_muted = muted;
+ lock_unlock(p_sys);
+}
+
void
ca_Play(audio_output_t * p_aout, block_t * p_block, vlc_tick_t date)
{
@@ -400,6 +413,7 @@ ca_Initialize(audio_output_t *p_aout, const audio_sample_format_t *fmt,
p_sys->i_underrun_size = 0;
p_sys->b_paused = false;
+ p_sys->b_muted = false;
p_sys->i_render_host_time = p_sys->i_first_render_host_time = 0;
p_sys->i_render_frames = 0;
diff --git a/modules/audio_output/coreaudio_common.h b/modules/audio_output/coreaudio_common.h
index 4bd61394937..faa3286e1d1 100644
--- a/modules/audio_output/coreaudio_common.h
+++ b/modules/audio_output/coreaudio_common.h
@@ -53,6 +53,7 @@ struct aout_sys_common
size_t i_underrun_size;
bool b_paused;
+ bool b_muted;
bool b_do_flush;
size_t i_out_max_size;
@@ -95,6 +96,8 @@ void ca_Flush(audio_output_t *p_aout);
void ca_Pause(audio_output_t * p_aout, bool pause, vlc_tick_t date);
+void ca_MuteSet(audio_output_t * p_aout, bool mute);
+
void ca_Play(audio_output_t * p_aout, block_t * p_block, vlc_tick_t date);
int ca_Initialize(audio_output_t *p_aout, const audio_sample_format_t *fmt,
--
2.30.0
More information about the vlc-devel
mailing list