[vlc-commits] audiounit_ios: merge stability improvements from AUHAL module

Felix Paul Kühne git at videolan.org
Mon Dec 30 19:13:39 CET 2013


vlc/vlc-2.1 | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Fri Dec 27 10:58:03 2013 +0100| [19e1db78f3b73cdb38196d075e9ec6714e143deb] | committer: Felix Paul Kühne

audiounit_ios: merge stability improvements from AUHAL module

(cherry picked from commit 50229412d358e954329e48c873bb04e73ab1e805)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.1.git/?a=commit;h=19e1db78f3b73cdb38196d075e9ec6714e143deb
---

 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