From 07438ca4f0afd9ebe352b48d978909d5baa4666f Mon Sep 17 00:00:00 2001 From: Jonas Rabbe Date: Tue, 19 Jul 2011 14:09:22 +1000 Subject: [PATCH] Fixed a hang of the QAudioOutput auto test on Mac OS X Task-number: QTMOBILITY-1779 Change-Id: If4141ed848dd0475b0008ec85daba55fa5f086b3 Reviewed-on: http://codereview.qt.nokia.com/1805 Reviewed-by: Qt Sanity Bot Reviewed-by: Michael Goddard --- src/multimediakit/audio/qaudiooutput_mac_p.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/multimediakit/audio/qaudiooutput_mac_p.cpp b/src/multimediakit/audio/qaudiooutput_mac_p.cpp index fcaa3cbd..17d3d1ff 100644 --- a/src/multimediakit/audio/qaudiooutput_mac_p.cpp +++ b/src/multimediakit/audio/qaudiooutput_mac_p.cpp @@ -108,9 +108,14 @@ public: QAudioRingBuffer::Region region = m_buffer->acquireReadRegion((maxFrames - framesRead) * m_bytesPerFrame); if (region.second > 0) { + // Ensure that we only read whole frames. region.second -= region.second % m_bytesPerFrame; - memcpy(data + (framesRead * m_bytesPerFrame), region.first, region.second); - framesRead += region.second / m_bytesPerFrame; + + if (region.second > 0) { + memcpy(data + (framesRead * m_bytesPerFrame), region.first, region.second); + framesRead += region.second / m_bytesPerFrame; + } else + wecan = false; // If there is only a partial frame left we should exit. } else wecan = false;