From 7844f679be8d94c5cdf017f53754cb68ee2f00da Mon Sep 17 00:00:00 2001 From: Haynes Mathew George Date: Wed, 15 Jan 2014 12:32:55 -0800 Subject: AudioFlinger: Modify flush handling for offload path Do not allow an offload track to directly control the offload thread behavior. OffloadThread can check for any pending flush reporting by its active tracks and decide to flush the HW or not. Bug: 12530661 Change-Id: Ib33f023c942f6c091b618004136b153c38a6eef6 --- services/audioflinger/Tracks.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'services/audioflinger/Tracks.cpp') diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp index ecedca9..8ffa43e 100644 --- a/services/audioflinger/Tracks.cpp +++ b/services/audioflinger/Tracks.cpp @@ -347,7 +347,8 @@ AudioFlinger::PlaybackThread::Track::Track( mCachedVolume(1.0), mIsInvalid(false), mAudioTrackServerProxy(NULL), - mResumeToStopping(false) + mResumeToStopping(false), + mFlushHwPending(false) { if (mCblk != NULL) { if (sharedBuffer == 0) { @@ -731,6 +732,7 @@ void AudioFlinger::PlaybackThread::Track::flush() mRetryCount = PlaybackThread::kMaxTrackRetriesOffload; } + mFlushHwPending = true; mResumeToStopping = false; } else { if (mState != STOPPING_1 && mState != STOPPING_2 && mState != STOPPED && @@ -751,11 +753,19 @@ void AudioFlinger::PlaybackThread::Track::flush() // Prevent flush being lost if the track is flushed and then resumed // before mixer thread can run. This is important when offloading // because the hardware buffer could hold a large amount of audio - playbackThread->flushOutput_l(); playbackThread->broadcast_l(); } } +// must be called with thread lock held +void AudioFlinger::PlaybackThread::Track::flushAck() +{ + if (!isOffloaded()) + return; + + mFlushHwPending = false; +} + void AudioFlinger::PlaybackThread::Track::reset() { // Do not reset twice to avoid discarding data written just after a flush and before -- cgit v1.1