summaryrefslogtreecommitdiffstats
path: root/services/audioflinger
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2012-09-23 15:20:50 -0700
committerEric Laurent <elaurent@google.com>2012-09-23 15:20:50 -0700
commit1afc26db11b71c43f63a0f72a45a803f1a7910dd (patch)
tree7237e91d3b5ed733ab530046b81a350e4b732113 /services/audioflinger
parent94a68ecf2b56bd56994d0352cbaad56e58dcf0dc (diff)
downloadframeworks_av-1afc26db11b71c43f63a0f72a45a803f1a7910dd.zip
frameworks_av-1afc26db11b71c43f63a0f72a45a803f1a7910dd.tar.gz
frameworks_av-1afc26db11b71c43f63a0f72a45a803f1a7910dd.tar.bz2
fix end of track presentation on suspended output
The code detecting the end of an audio track presentation before removing it from the active track list is based on the count of audio frames sent to audio HAL. When an output stream is suspended (e.g. A2DP when SCO is active), this count does not change and a track in stopped state will never be removed from active track list causing the mixer thread to never release the wake lock. The fix consists in incrementing the audio HAL frame count even if the output is suspended. Also fix a problem in getRenderPosition() when the output is suspended. Bug 7167534. Change-Id: I3be836cbbea29b65dc087199cac6a1cd84c0a41d
Diffstat (limited to 'services/audioflinger')
-rw-r--r--services/audioflinger/AudioFlinger.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index de116a9..8e950aa 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -2116,7 +2116,17 @@ status_t AudioFlinger::PlaybackThread::getRenderPosition(uint32_t *halFrames, ui
}
*halFrames = mBytesWritten / audio_stream_frame_size(&mOutput->stream->common);
- return mOutput->stream->get_render_position(mOutput->stream, dspFrames);
+ if (isSuspended()) {
+ // return an estimation of rendered frames when the output is suspended
+ int32_t frames = mBytesWritten - latency_l();
+ if (frames < 0) {
+ frames = 0;
+ }
+ *dspFrames = (uint32_t)frames;
+ return NO_ERROR;
+ } else {
+ return mOutput->stream->get_render_position(mOutput->stream, dspFrames);
+ }
}
uint32_t AudioFlinger::PlaybackThread::hasAudioSession(int sessionId) const
@@ -2573,7 +2583,6 @@ bool AudioFlinger::PlaybackThread::threadLoop()
threadLoop_standby();
mStandby = true;
- mBytesWritten = 0;
}
if (!mActiveTracks.size() && mConfigEvents.isEmpty()) {
@@ -2593,6 +2602,7 @@ bool AudioFlinger::PlaybackThread::threadLoop()
mMixerStatus = MIXER_IDLE;
mMixerStatusIgnoringFastTracks = MIXER_IDLE;
+ mBytesWritten = 0;
checkSilentMode_l();
@@ -2623,6 +2633,7 @@ bool AudioFlinger::PlaybackThread::threadLoop()
if (isSuspended()) {
sleepTime = suspendSleepTimeUs();
+ mBytesWritten += mixBufferSize;
}
// only process effects if we're going to write