From 78c131473165830c8d042a0f445ca858aaa7a4b1 Mon Sep 17 00:00:00 2001 From: Jean-Michel Trivi <> Date: Tue, 24 Mar 2009 19:48:58 -0700 Subject: [PATCH] Automated import from //branches/donutburger/...@141200,141200 --- include/media/AudioRecord.h | 1 + media/libmedia/AudioRecord.cpp | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/media/AudioRecord.h b/include/media/AudioRecord.h index ff6485536cfe..7164b78e0735 100644 --- a/include/media/AudioRecord.h +++ b/include/media/AudioRecord.h @@ -335,6 +335,7 @@ private: uint32_t mNotificationFrames; uint32_t mRemainingFrames; uint32_t mMarkerPosition; + bool mMarkerReached; uint32_t mNewPosition; uint32_t mUpdatePeriod; }; diff --git a/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp index 7594ff0ca066..5c800c3efb2e 100644 --- a/media/libmedia/AudioRecord.cpp +++ b/media/libmedia/AudioRecord.cpp @@ -200,6 +200,7 @@ status_t AudioRecord::set( // TODO: add audio hardware input latency here mLatency = (1000*mFrameCount) / mSampleRate; mMarkerPosition = 0; + mMarkerReached = false; mNewPosition = 0; mUpdatePeriod = 0; @@ -293,6 +294,9 @@ status_t AudioRecord::stop() if (android_atomic_and(~1, &mActive) == 1) { mAudioRecord->stop(); + // the record head position will reset to 0, so if a marker is set, we need + // to activate it again + mMarkerReached = false; if (t != 0) { t->requestExit(); } else { @@ -317,6 +321,7 @@ status_t AudioRecord::setMarkerPosition(uint32_t marker) if (mCbf == 0) return INVALID_OPERATION; mMarkerPosition = marker; + mMarkerReached = false; return NO_ERROR; } @@ -492,10 +497,10 @@ bool AudioRecord::processAudioBuffer(const sp& thread) size_t readSize; // Manage marker callback - if (mMarkerPosition > 0) { + if (!mMarkerReached && (mMarkerPosition > 0)) { if (mCblk->user >= mMarkerPosition) { mCbf(EVENT_MARKER, mUserData, (void *)&mMarkerPosition); - mMarkerPosition = 0; + mMarkerReached = true; } } -- 2.11.0