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.
This commit is contained in:
Stefano Pigozzi 2013-07-28 11:21:03 +02:00
parent 721071a5ec
commit ca678dce4d
1 changed files with 6 additions and 1 deletions

View File

@ -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;
}