[vlc-commits] audiounit_ios: merge stability improvements from AUHAL module
Felix Paul Kühne
git at videolan.org
Fri Dec 27 11:02:24 CET 2013
vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Fri Dec 27 10:58:03 2013 +0100| [50229412d358e954329e48c873bb04e73ab1e805] | committer: Felix Paul Kühne
audiounit_ios: merge stability improvements from AUHAL module
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=50229412d358e954329e48c873bb04e73ab1e805
---
modules/audio_output/audiounit_ios.c | 28 +++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/modules/audio_output/audiounit_ios.c b/modules/audio_output/audiounit_ios.c
index 00d61b9..e00a7e3 100644
--- a/modules/audio_output/audiounit_ios.c
+++ b/modules/audio_output/audiounit_ios.c
@@ -336,20 +336,24 @@ static void Pause (audio_output_t *p_aout, bool pause, mtime_t date)
static void Flush(audio_output_t *p_aout, bool wait)
{
- struct aout_sys_t * p_sys = p_aout->sys;
+ struct aout_sys_t *p_sys = p_aout->sys;
+
+ int32_t availableBytes;
+ vlc_mutex_lock(&p_sys->lock);
+ TPCircularBufferTail(&p_sys->circular_buffer, &availableBytes);
if (wait) {
- int32_t availableBytes;
- vlc_mutex_lock(&p_sys->lock);
- TPCircularBufferTail(&p_sys->circular_buffer, &availableBytes);
while (availableBytes > 0) {
vlc_cond_wait(&p_sys->cond, &p_sys->lock);
TPCircularBufferTail(&p_sys->circular_buffer, &availableBytes);
}
- vlc_mutex_unlock(&p_sys->lock);
- } else
- /* flush circular buffer */
- TPCircularBufferClear(&p_aout->sys->circular_buffer);
+ } else {
+ /* flush circular buffer if data is left */
+ if (availableBytes > 0)
+ TPCircularBufferClear(&p_aout->sys->circular_buffer);
+ }
+
+ vlc_mutex_unlock(&p_sys->lock);
}
static int TimeGet(audio_output_t *p_aout, mtime_t *delay)
@@ -402,9 +406,11 @@ static OSStatus RenderCallback(vlc_object_t *p_obj,
} else {
int32_t bytesToCopy = __MIN(bytesRequested, availableBytes);
- memcpy(targetBuffer, buffer, bytesToCopy);
- TPCircularBufferConsume(&p_sys->circular_buffer, bytesToCopy);
- ioData->mBuffers[0].mDataByteSize = bytesToCopy;
+ if (likely(bytesToCopy > 0)) {
+ memcpy(targetBuffer, buffer, bytesToCopy);
+ TPCircularBufferConsume(&p_sys->circular_buffer, bytesToCopy);
+ ioData->mBuffers[0].mDataByteSize = bytesToCopy;
+ }
}
vlc_cond_signal(&p_sys->cond);
More information about the vlc-commits
mailing list