summaryrefslogtreecommitdiffstats
path: root/media/libmedia/AudioTrack.cpp
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2012-11-30 13:41:12 -0800
committerGlenn Kasten <gkasten@google.com>2012-12-03 10:42:52 -0800
commit4bae3649d504d590a546717a8e49f96a30d9a745 (patch)
tree0e9cc2e5390671a4021d85193b1ad31544040f3c /media/libmedia/AudioTrack.cpp
parente4756fe3a387615acb63c6a05788c8db9b5786cb (diff)
downloadframeworks_av-4bae3649d504d590a546717a8e49f96a30d9a745.zip
frameworks_av-4bae3649d504d590a546717a8e49f96a30d9a745.tar.gz
frameworks_av-4bae3649d504d590a546717a8e49f96a30d9a745.tar.bz2
flush() comments and checks
flush() is only useful for streaming mode. It is a no-op if track is active or uses a static buffer. Change-Id: I918ac181ffae3d16a0d67d8a7208f4aec61b5bd6
Diffstat (limited to 'media/libmedia/AudioTrack.cpp')
-rw-r--r--media/libmedia/AudioTrack.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index f5641e0..597d057 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -397,6 +397,7 @@ void AudioTrack::stop()
mMarkerReached = false;
// Force flush if a shared buffer is used otherwise audioflinger
// will not stop before end of buffer is reached.
+ // It may be needed to make sure that we stop playback, likely in case looping is on.
if (mSharedBuffer != 0) {
flush_l();
}
@@ -419,26 +420,26 @@ bool AudioTrack::stopped() const
void AudioTrack::flush()
{
AutoMutex lock(mLock);
- flush_l();
+ if (!mActive && mSharedBuffer == 0) {
+ flush_l();
+ }
}
-// must be called with mLock held
void AudioTrack::flush_l()
{
ALOGV("flush");
+ ALOG_ASSERT(!mActive);
// clear playback marker and periodic update counter
mMarkerPosition = 0;
mMarkerReached = false;
mUpdatePeriod = 0;
- if (!mActive) {
- mFlushed = true;
- mAudioTrack->flush();
- // Release AudioTrack callback thread in case it was waiting for new buffers
- // in AudioTrack::obtainBuffer()
- mCblk->cv.signal();
- }
+ mFlushed = true;
+ mAudioTrack->flush();
+ // Release AudioTrack callback thread in case it was waiting for new buffers
+ // in AudioTrack::obtainBuffer()
+ mCblk->cv.signal();
}
void AudioTrack::pause()