[vlc-commits] auhal: check if render callback does not want data

David Fuhrmann git at videolan.org
Mon Feb 24 15:28:21 CET 2014


vlc | branch: master | David Fuhrmann <david.fuhrmann at googlemail.com> | Sun Feb 23 23:07:06 2014 +0100| [3aa6b1be4eddadc4fc74ae9f740588b2f5184c95] | committer: David Fuhrmann

auhal: check if render callback does not want data

Indeed this can happen rarely.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3aa6b1be4eddadc4fc74ae9f740588b2f5184c95
---

 modules/audio_output/auhal.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/modules/audio_output/auhal.c b/modules/audio_output/auhal.c
index 182d9f7..3ab1aa0 100644
--- a/modules/audio_output/auhal.c
+++ b/modules/audio_output/auhal.c
@@ -1302,6 +1302,8 @@ static OSStatus RenderCallbackAnalog(vlc_object_t *p_obj,
 
     int bytesRequested = ioData->mBuffers[0].mDataByteSize;
     Float32 *targetBuffer = (Float32*)ioData->mBuffers[0].mData;
+    if (unlikely(bytesRequested == 0)) /* cannot be negative */
+        return noErr;
 
     vlc_mutex_lock(&p_sys->lock);
     /* Pull audio from buffer */
@@ -1314,7 +1316,6 @@ static OSStatus RenderCallbackAnalog(vlc_object_t *p_obj,
         memset(targetBuffer, 0, bytesRequested);
     } else {
         int32_t bytesToCopy = __MIN(bytesRequested, availableBytes);
-        assert(bytesToCopy > 0);
 
         memcpy(targetBuffer, buffer, bytesToCopy);
         TPCircularBufferConsume(&p_sys->circular_buffer, bytesToCopy);
@@ -1349,6 +1350,8 @@ static OSStatus RenderCallbackSPDIF(AudioDeviceID inDevice,
 
     int bytesRequested = outOutputData->mBuffers[p_sys->i_stream_index].mDataByteSize;
     char *targetBuffer = outOutputData->mBuffers[p_sys->i_stream_index].mData;
+    if (unlikely(bytesRequested == 0)) /* cannot be negative */
+        return noErr;
 
     vlc_mutex_lock(&p_sys->lock);
     /* Pull audio from buffer */
@@ -1361,7 +1364,6 @@ static OSStatus RenderCallbackSPDIF(AudioDeviceID inDevice,
         memset(targetBuffer, 0, bytesRequested);
     } else {
         int32_t bytesToCopy = __MIN(bytesRequested, availableBytes);
-        assert(bytesToCopy > 0);
 
         memcpy(targetBuffer, buffer, bytesToCopy);
         TPCircularBufferConsume(&p_sys->circular_buffer, bytesToCopy);



More information about the vlc-commits mailing list