diff options
author | Umar Getagazov <umar@handlerug.me> | 2023-10-24 17:04:18 +0300 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2023-10-29 21:19:04 +0100 |
commit | 0341a6f1d39801160322d3fe16245f8387735f4b (patch) | |
tree | f502f90f9419ffad2c4f61b183512d33ae7609f0 /audio/out/ao_coreaudio.c | |
parent | 18885917a756bd37ee8e5e7fa35a5ed862485cbe (diff) | |
download | mpv-0341a6f1d39801160322d3fe16245f8387735f4b.tar.bz2 mpv-0341a6f1d39801160322d3fe16245f8387735f4b.tar.xz |
ao_coreaudio: signal buffer underruns
Change the resulting buffer sizes to match the actual amount of samples
read, and set a flag in case no samples were read at all.
Diffstat (limited to 'audio/out/ao_coreaudio.c')
-rw-r--r-- | audio/out/ao_coreaudio.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/audio/out/ao_coreaudio.c b/audio/out/ao_coreaudio.c index d96b597f6e..01e39d10df 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; } |