From 5f72c89a07f3a8881a4b9536221a5f9883d8a3b6 Mon Sep 17 00:00:00 2001 From: Sumit Bhattacharya Date: Thu, 19 Nov 2015 12:56:41 +0530 Subject: AudioFlinger: Fix re-use of fast-track When a fast-track using shared buffer is restarted, we need to call obtainbuffer if frameReady has already become zero, even if track is still active. This is required to reset mFramesReadySafe. Otherwise mFramesReadySafe remain at 0 and fastmixer can't consume data from the track when it is re-used. Change-Id: I5d6f364f8f31baad3341bd4f51bf8a8b147cd7d7 --- services/audioflinger/Tracks.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'services/audioflinger') diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp index 98eb87f..4eb13dc 100644 --- a/services/audioflinger/Tracks.cpp +++ b/services/audioflinger/Tracks.cpp @@ -707,10 +707,11 @@ status_t AudioFlinger::PlaybackThread::Track::start(AudioSystem::sync_event_t ev mState = state; } } - // track was already in the active list, not a problem - if (status == ALREADY_EXISTS) { - status = NO_ERROR; - } else { + // If track was already in the active list, not a problem unless + // track is fast and sharedBuffer is used and frameReady has already become 0. + // In such case we need to call obtainbuffer() to refresh the framesReady value. + if ((status != ALREADY_EXISTS) || + (isFastTrack() && (mSharedBuffer != 0) && (framesReady() == 0))) { // Acknowledge any pending flush(), so that subsequent new data isn't discarded. // It is usually unsafe to access the server proxy from a binder thread. // But in this case we know the mixer thread (whether normal mixer or fast mixer) @@ -720,6 +721,9 @@ status_t AudioFlinger::PlaybackThread::Track::start(AudioSystem::sync_event_t ev buffer.mFrameCount = 1; (void) mAudioTrackServerProxy->obtainBuffer(&buffer, true /*ackFlush*/); } + + if (status == ALREADY_EXISTS) + status = NO_ERROR; } else { status = BAD_VALUE; } -- cgit v1.1