summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2013-10-18 15:09:03 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-10-18 15:09:03 -0700
commita153b68f2260a8ed7fbb236fa659b13264ac5ac0 (patch)
treefde0bd5a83da59bde7dc9b146a8a8af48d911adc
parent6a7327f110b86613e6e8c7de105c49803acacc1d (diff)
parent77177fa20773d02b4f9c4147ecb98107f019fa7d (diff)
downloadframeworks_av-a153b68f2260a8ed7fbb236fa659b13264ac5ac0.zip
frameworks_av-a153b68f2260a8ed7fbb236fa659b13264ac5ac0.tar.gz
frameworks_av-a153b68f2260a8ed7fbb236fa659b13264ac5ac0.tar.bz2
am 77177fa2: am 95c03858: Merge "Allow releaseBuffer after flush" into klp-dev
* commit '77177fa20773d02b4f9c4147ecb98107f019fa7d': Allow releaseBuffer after flush
-rw-r--r--include/private/media/AudioTrackShared.h5
-rw-r--r--media/libmedia/AudioTrackShared.cpp10
-rw-r--r--services/audioflinger/Tracks.cpp2
3 files changed, 11 insertions, 6 deletions
diff --git a/include/private/media/AudioTrackShared.h b/include/private/media/AudioTrackShared.h
index 69d2486..85862a8 100644
--- a/include/private/media/AudioTrackShared.h
+++ b/include/private/media/AudioTrackShared.h
@@ -360,6 +360,7 @@ public:
// which must be > 0.
// buffer->mNonContig is unused.
// buffer->mRaw is unused.
+ // ackFlush is true iff being called from Track::start to acknowledge a pending flush.
// On exit:
// buffer->mFrameCount has the actual number of contiguous available frames,
// which is always 0 when the return status != NO_ERROR.
@@ -370,7 +371,7 @@ public:
// NO_ERROR Success, buffer->mFrameCount > 0.
// WOULD_BLOCK No frames are available.
// NO_INIT Shared memory is corrupt.
- virtual status_t obtainBuffer(Buffer* buffer);
+ virtual status_t obtainBuffer(Buffer* buffer, bool ackFlush = false);
// Release (some of) the frames last obtained.
// On entry, buffer->mFrameCount should have the number of frames to release,
@@ -437,7 +438,7 @@ protected:
public:
virtual size_t framesReady();
virtual void framesReadyIsCalledByMultipleThreads();
- virtual status_t obtainBuffer(Buffer* buffer);
+ virtual status_t obtainBuffer(Buffer* buffer, bool ackFlush);
virtual void releaseBuffer(Buffer* buffer);
virtual void tallyUnderrunFrames(uint32_t frameCount);
virtual uint32_t getUnderrunFrames() const { return 0; }
diff --git a/media/libmedia/AudioTrackShared.cpp b/media/libmedia/AudioTrackShared.cpp
index da73d65..caa7900 100644
--- a/media/libmedia/AudioTrackShared.cpp
+++ b/media/libmedia/AudioTrackShared.cpp
@@ -506,7 +506,7 @@ ServerProxy::ServerProxy(audio_track_cblk_t* cblk, void *buffers, size_t frameCo
{
}
-status_t ServerProxy::obtainBuffer(Buffer* buffer)
+status_t ServerProxy::obtainBuffer(Buffer* buffer, bool ackFlush)
{
LOG_ALWAYS_FATAL_IF(buffer == NULL || buffer->mFrameCount == 0);
if (mIsShutdown) {
@@ -579,7 +579,11 @@ status_t ServerProxy::obtainBuffer(Buffer* buffer)
buffer->mRaw = part1 > 0 ?
&((char *) mBuffers)[(mIsOut ? front : rear) * mFrameSize] : NULL;
buffer->mNonContig = availToServer - part1;
- mUnreleased = part1;
+ // After flush(), allow releaseBuffer() on a previously obtained buffer;
+ // see "Acknowledge any pending flush()" in audioflinger/Tracks.cpp.
+ if (!ackFlush) {
+ mUnreleased = part1;
+ }
return part1 > 0 ? NO_ERROR : WOULD_BLOCK;
}
no_init:
@@ -761,7 +765,7 @@ ssize_t StaticAudioTrackServerProxy::pollPosition()
return (ssize_t) position;
}
-status_t StaticAudioTrackServerProxy::obtainBuffer(Buffer* buffer)
+status_t StaticAudioTrackServerProxy::obtainBuffer(Buffer* buffer, bool ackFlush)
{
if (mIsShutdown) {
buffer->mFrameCount = 0;
diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp
index 88ae288..656dfbb 100644
--- a/services/audioflinger/Tracks.cpp
+++ b/services/audioflinger/Tracks.cpp
@@ -617,7 +617,7 @@ status_t AudioFlinger::PlaybackThread::Track::start(AudioSystem::sync_event_t ev
// and for fast tracks the track is not yet in the fast mixer thread's active set.
ServerProxy::Buffer buffer;
buffer.mFrameCount = 1;
- (void) mAudioTrackServerProxy->obtainBuffer(&buffer);
+ (void) mAudioTrackServerProxy->obtainBuffer(&buffer, true /*ackFlush*/);
}
} else {
status = BAD_VALUE;