From cb2129b3b568a4e31bcbda3545a468024bc972fe Mon Sep 17 00:00:00 2001 From: Andy Hung Date: Tue, 11 Nov 2014 12:17:22 -0800 Subject: Fix missing loop count for static tracks. StaticAudioTrackServerProxy::framesReady() previously returned only the contiguous frames, update to return the total available frames. This resolves short-count looping in SoundPool for FastTracks. Also (1) Removes the racy condition of reading two variables and (2) Fixes buffer->mNonContig to return the correct value and (3) Restores behavior that loop count of 1 goes back to loopStart once during playback. Bug: 11830751 Bug: 12070295 Bug: 17456842 Change-Id: I64906e6036bb00a1d7375b03efe6deb69d6478ca --- include/private/media/AudioTrackShared.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/private/media/AudioTrackShared.h b/include/private/media/AudioTrackShared.h index fa1b20a..31dff36 100644 --- a/include/private/media/AudioTrackShared.h +++ b/include/private/media/AudioTrackShared.h @@ -450,7 +450,14 @@ private: ssize_t pollPosition(); // poll for state queue update, and return current position StaticAudioTrackSingleStateQueue::Observer mObserver; size_t mPosition; // server's current play position in frames, relative to 0 - size_t mEnd; // cached value computed from mState, safe for asynchronous read + + size_t mFramesReadySafe; // Assuming size_t read/writes are atomic on 32 / 64 bit + // processors, this is a thread-safe version of + // mFramesReady. + int64_t mFramesReady; // The number of frames ready in the static buffer + // including loops. This is 64 bits since loop mode + // can cause a track to appear to have a large number + // of frames. INT64_MAX means an infinite loop. bool mFramesReadyIsCalledByMultipleThreads; StaticAudioTrackState mState; }; -- cgit v1.1