diff options
author | Stefano Pigozzi <stefano.pigozzi@gmail.com> | 2013-07-28 11:21:03 +0200 |
---|---|---|
committer | Stefano Pigozzi <stefano.pigozzi@gmail.com> | 2013-07-28 11:21:03 +0200 |
commit | ca678dce4d3170a65ac184574bd12130aed06e82 (patch) | |
tree | 25e6ef22951b26dfb80365205e58f6d8977f1ae6 /audio/out | |
parent | 721071a5ecd7d95c55b65749825dd69fff835211 (diff) | |
download | mpv-ca678dce4d3170a65ac184574bd12130aed06e82.tar.bz2 mpv-ca678dce4d3170a65ac184574bd12130aed06e82.tar.xz |
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.
Diffstat (limited to 'audio/out')
-rw-r--r-- | audio/out/ao_coreaudio.c | 7 |
1 files changed, 6 insertions, 1 deletions
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; } |