From ca678dce4d3170a65ac184574bd12130aed06e82 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 28 Jul 2013 11:21:03 +0200 Subject: ao_coreaudio: prevent buffer underruns to output garbage This was removed in d427b4fd. I now found a sample that causes underruns when moving to a chapter and apparently this is also a problem when taking screenshots. --- audio/out/ao_coreaudio.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'audio') diff --git a/audio/out/ao_coreaudio.c b/audio/out/ao_coreaudio.c index 718c71187d..62fe630acd 100644 --- a/audio/out/ao_coreaudio.c +++ b/audio/out/ao_coreaudio.c @@ -109,7 +109,12 @@ static OSStatus render_cb_lpcm(void *ctx, AudioUnitRenderActionFlags *aflags, AudioBuffer buf = buffer_list->mBuffers[0]; int requested = buf.mDataByteSize; - buf.mDataByteSize = mp_ring_read(p->buffer, buf.mData, requested); + if (mp_ring_buffered(p->buffer) < requested) { + ca_msg(MSGL_V, "buffer underrun\n"); + audio_pause(ao); + } else { + mp_ring_read(p->buffer, buf.mData, requested); + } return noErr; } -- cgit v1.2.3