summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2011-11-08 18:10:16 -0800
committerEric Laurent <elaurent@google.com>2011-11-08 18:42:37 -0800
commit8a04fe032b2a9ab0f2905571c59b5ce6bd0e9d71 (patch)
tree38c24b10f3b90f1f66ed320369b38c30ea1dfea0
parent650a3e8894c6d26b258d26bdec856fde7aba43d6 (diff)
downloadframeworks_base-8a04fe032b2a9ab0f2905571c59b5ce6bd0e9d71.zip
frameworks_base-8a04fe032b2a9ab0f2905571c59b5ce6bd0e9d71.tar.gz
frameworks_base-8a04fe032b2a9ab0f2905571c59b5ce6bd0e9d71.tar.bz2
Fix regression for SoundPool playback
Commit 19ddf0eb introduced a problem with applications (like SoundPool) relying on an underrun condition to detect end of playback instead of stopping the track when all data is written. AudioFlinger would keep waiting for new data in case of partial buffer filling and never reach the underrun condition. Added a mechanism to wait no more than once if not enough frames are present in the track buffer. Issue 5585490. Change-Id: I131e605ff6070831a01ddf734e68459e3bf2354b
-rw-r--r--services/audioflinger/AudioFlinger.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 96e8eb9..ff262f1 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -2066,9 +2066,14 @@ uint32_t AudioFlinger::MixerThread::prepareTracks_l(const SortedVector< wp<Track
// The first time a track is added we wait
// for all its buffers to be filled before processing it
mAudioMixer->setActiveTrack(track->name());
- // make sure that we have enough frames to mix one full buffer
+ // make sure that we have enough frames to mix one full buffer.
+ // enforce this condition only once to enable draining the buffer in case the client
+ // app does not call stop() and relies on underrun to stop:
+ // hence the test on (track->mRetryCount >= kMaxTrackRetries) meaning the track was mixed
+ // during last round
uint32_t minFrames = 1;
- if (!track->isStopped() && !track->isPausing()) {
+ if (!track->isStopped() && !track->isPausing() &&
+ (track->mRetryCount >= kMaxTrackRetries)) {
if (t->sampleRate() == (int)mSampleRate) {
minFrames = mFrameCount;
} else {