diff --git a/audio/out/ao_coreaudio.c b/audio/out/ao_coreaudio.c index d96b597f6e1a6..01e39d10df92b 100644 --- a/audio/out/ao_coreaudio.c +++ b/audio/out/ao_coreaudio.c @@ -78,7 +78,14 @@ static OSStatus render_cb_lpcm(void *ctx, AudioUnitRenderActionFlags *aflags, int64_t end = mp_time_ns(); end += p->hw_latency_ns + ca_get_latency(ts) + ca_frames_to_ns(ao, frames); - ao_read_data(ao, planes, frames, end); + int samples = ao_read_data(ao, planes, frames, end); + + if (samples == 0) + *aflags |= kAudioUnitRenderAction_OutputIsSilence; + + for (int n = 0; n < buffer_list->mNumberBuffers; n++) + buffer_list->mBuffers[n].mDataByteSize = samples * ao->sstride; + return noErr; }