[vlc-devel] [PATCH 2/4] coreaudio: notify when the output is silence
Thomas Guillem
thomas at gllm.fr
Wed Apr 21 15:00:39 UTC 2021
It can be used as a hint to whether the buffer needs to be processed or
not.
---
modules/audio_output/auhal.c | 3 ++-
modules/audio_output/coreaudio_common.c | 9 +++++++--
modules/audio_output/coreaudio_common.h | 2 +-
3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/modules/audio_output/auhal.c b/modules/audio_output/auhal.c
index f99acfc27ec..739c857f851 100644
--- a/modules/audio_output/auhal.c
+++ b/modules/audio_output/auhal.c
@@ -981,7 +981,8 @@ RenderCallbackSPDIF(AudioDeviceID inDevice, const AudioTimeStamp * inNow,
uint64_t i_host_time = (inOutputTime->mFlags & kAudioTimeStampHostTimeValid)
? inOutputTime->mHostTime : 0;
- ca_Render(p_aout, 0, i_host_time, p_output, i_size);
+ bool ignored;
+ ca_Render(p_aout, 0, i_host_time, p_output, i_size, &ignored);
return noErr;
}
diff --git a/modules/audio_output/coreaudio_common.c b/modules/audio_output/coreaudio_common.c
index 4c96a1ffbd6..dbeae522f97 100644
--- a/modules/audio_output/coreaudio_common.c
+++ b/modules/audio_output/coreaudio_common.c
@@ -126,7 +126,7 @@ ca_Open(audio_output_t *p_aout)
/* Called from render callbacks. No lock, wait, and IO here */
void
ca_Render(audio_output_t *p_aout, uint32_t i_frames, uint64_t i_host_time,
- uint8_t *p_output, size_t i_requested)
+ uint8_t *p_output, size_t i_requested, bool *is_silence)
{
struct aout_sys_common *p_sys = (struct aout_sys_common *) p_aout->sys;
@@ -224,11 +224,13 @@ ca_Render(audio_output_t *p_aout, uint32_t i_frames, uint64_t i_host_time,
memset(p_output, 0, i_requested);
}
+ *is_silence = p_sys->b_muted;
lock_unlock(p_sys);
return;
drop:
memset(p_output, 0, i_requested);
+ *is_silence = true;
lock_unlock(p_sys);
}
@@ -532,8 +534,11 @@ RenderCallback(void *p_data, AudioUnitRenderActionFlags *ioActionFlags,
uint64_t i_host_time = (inTimeStamp->mFlags & kAudioTimeStampHostTimeValid)
? inTimeStamp->mHostTime : 0;
+ bool is_silence;
ca_Render(p_data, inNumberFrames, i_host_time, ioData->mBuffers[0].mData,
- ioData->mBuffers[0].mDataByteSize);
+ ioData->mBuffers[0].mDataByteSize, &is_silence);
+ if (is_silence)
+ *ioActionFlags |= kAudioUnitRenderAction_OutputIsSilence;
return noErr;
}
diff --git a/modules/audio_output/coreaudio_common.h b/modules/audio_output/coreaudio_common.h
index faa3286e1d1..1a8f50c0898 100644
--- a/modules/audio_output/coreaudio_common.h
+++ b/modules/audio_output/coreaudio_common.h
@@ -88,7 +88,7 @@ struct aout_sys_common
int ca_Open(audio_output_t *p_aout);
void ca_Render(audio_output_t *p_aout, uint32_t i_nb_samples, uint64_t i_host_time,
- uint8_t *p_output, size_t i_requested);
+ uint8_t *p_output, size_t i_requested, bool *is_silence);
int ca_TimeGet(audio_output_t *p_aout, vlc_tick_t *delay);
--
2.30.0
More information about the vlc-devel
mailing list