diff options
author | Mike Lockwood <lockwood@google.com> | 2012-02-17 09:20:43 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-02-17 09:20:43 -0800 |
commit | 29dcfcd66d884801e9907d04e81d407ee770802c (patch) | |
tree | 3b494547cfc30a85df3681e1f35b31346914919e /services/audioflinger | |
parent | 9fda4b87441fe17d90d8144639c9de6d9022c3c0 (diff) | |
parent | fe5b3ba4b332d5fc9aa4f453434329b9f38768c2 (diff) | |
download | frameworks_av-29dcfcd66d884801e9907d04e81d407ee770802c.zip frameworks_av-29dcfcd66d884801e9907d04e81d407ee770802c.tar.gz frameworks_av-29dcfcd66d884801e9907d04e81d407ee770802c.tar.bz2 |
Merge "Put a bandaid on a segfault in timed audio track handling."
Diffstat (limited to 'services/audioflinger')
-rw-r--r-- | services/audioflinger/AudioFlinger.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp index 29d63de..103e18b 100644 --- a/services/audioflinger/AudioFlinger.cpp +++ b/services/audioflinger/AudioFlinger.cpp @@ -4117,11 +4117,24 @@ void AudioFlinger::PlaybackThread::TimedTrack::releaseBuffer( Mutex::Autolock _l(mTimedBufferQueueLock); - if (buffer->raw != mTimedSilenceBuffer) { + // If the buffer which was just released is part of the buffer at the head + // of the queue, be sure to update the amt of the buffer which has been + // consumed. If the buffer being returned is not part of the head of the + // queue, its either because the buffer is part of the silence buffer, or + // because the head of the timed queue was trimmed after the mixer called + // getNextBuffer but before the mixer called releaseBuffer. + if ((buffer->raw != mTimedSilenceBuffer) && mTimedBufferQueue.size()) { TimedBuffer& head = mTimedBufferQueue.editItemAt(0); - head.setPosition(head.position() + buffer->frameCount * mCblk->frameSize); - if (static_cast<size_t>(head.position()) >= head.buffer()->size()) { - mTimedBufferQueue.removeAt(0); + + void* start = head.buffer()->pointer(); + void* end = head.buffer()->pointer() + head.buffer()->size(); + + if ((buffer->raw >= start) && (buffer->raw <= end)) { + head.setPosition(head.position() + + (buffer->frameCount * mCblk->frameSize)); + if (static_cast<size_t>(head.position()) >= head.buffer()->size()) { + mTimedBufferQueue.removeAt(0); + } } } |