summaryrefslogtreecommitdiffstats
path: root/services/audioflinger
diff options
context:
space:
mode:
authorAndy Hung <hunga@google.com>2014-11-18 02:30:50 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-11-18 02:30:50 +0000
commita3e2c146eda841d84faa0093d26d7414de78bbaa (patch)
treeab6390e2954dba0c3d03188f0fe8420978f13e51 /services/audioflinger
parent1c764234f30941ab18ef2ba55299e2ce036c34b6 (diff)
parent4d0a5985fb5e7ea5a1f9a605afea2b7534ebc16b (diff)
downloadframeworks_av-a3e2c146eda841d84faa0093d26d7414de78bbaa.zip
frameworks_av-a3e2c146eda841d84faa0093d26d7414de78bbaa.tar.gz
frameworks_av-a3e2c146eda841d84faa0093d26d7414de78bbaa.tar.bz2
am 4d0a5985: Merge "Prevent stopped audio tracks from mixing data" into lmp-mr1-dev
* commit '4d0a5985fb5e7ea5a1f9a605afea2b7534ebc16b': Prevent stopped audio tracks from mixing data
Diffstat (limited to 'services/audioflinger')
-rw-r--r--services/audioflinger/Tracks.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp
index b9308fa..037c73b 100644
--- a/services/audioflinger/Tracks.cpp
+++ b/services/audioflinger/Tracks.cpp
@@ -611,15 +611,16 @@ status_t AudioFlinger::PlaybackThread::Track::getNextBuffer(
// ExtendedAudioBufferProvider interface
-// Note that framesReady() takes a mutex on the control block using tryLock().
-// This could result in priority inversion if framesReady() is called by the normal mixer,
-// as the normal mixer thread runs at lower
-// priority than the client's callback thread: there is a short window within framesReady()
-// during which the normal mixer could be preempted, and the client callback would block.
-// Another problem can occur if framesReady() is called by the fast mixer:
-// the tryLock() could block for up to 1 ms, and a sequence of these could delay fast mixer.
-// FIXME Replace AudioTrackShared control block implementation by a non-blocking FIFO queue.
+// framesReady() may return an approximation of the number of frames if called
+// from a different thread than the one calling Proxy->obtainBuffer() and
+// Proxy->releaseBuffer(). Also note there is no mutual exclusion in the
+// AudioTrackServerProxy so be especially careful calling with FastTracks.
size_t AudioFlinger::PlaybackThread::Track::framesReady() const {
+ if (mSharedBuffer != 0 && (isStopped() || isStopping())) {
+ // Static tracks return zero frames immediately upon stopping (for FastTracks).
+ // The remainder of the buffer is not drained.
+ return 0;
+ }
return mAudioTrackServerProxy->framesReady();
}