From a045dcafd2b77036210f5b72e79d745ad4c1b848 Mon Sep 17 00:00:00 2001 From: Jean-Michel Trivi Date: Tue, 16 Oct 2012 10:29:01 -0700 Subject: Fix track estimation for presentation complete Audio tracks were not using the right latency estimation for signalling the completion of their presetation. This caused the synchronization mechanism between playback and record to be off, and a synchronized recording would contain some of the audio that was meant to be over once recording would start. Use the playback thread's latency reporting which takes the audio pipe into account. Bug 7237669 Change-Id: I23a907a53ad0b0d68d246789ec595a77a79fced5 --- services/audioflinger/AudioFlinger.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp index aa30864e..6a350531 100644 --- a/services/audioflinger/AudioFlinger.cpp +++ b/services/audioflinger/AudioFlinger.cpp @@ -3275,8 +3275,7 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::MixerThread::prepareTrac // Remove it from the list of active tracks. // TODO: use actual buffer filling status instead of latency when available from // audio HAL - size_t audioHALFrames = - (mOutput->stream->get_latency(mOutput->stream)*mSampleRate) / 1000; + size_t audioHALFrames = (latency_l() * mSampleRate) / 1000; size_t framesWritten = mBytesWritten / audio_stream_frame_size(&mOutput->stream->common); if (track->presentationComplete(framesWritten, audioHALFrames)) { @@ -3799,8 +3798,7 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::DirectOutputThread::prep // We have consumed all the buffers of this track. // Remove it from the list of active tracks. // TODO: implement behavior for compressed audio - size_t audioHALFrames = - (mOutput->stream->get_latency(mOutput->stream)*mSampleRate) / 1000; + size_t audioHALFrames = (latency_l() * mSampleRate) / 1000; size_t framesWritten = mBytesWritten / audio_stream_frame_size(&mOutput->stream->common); if (track->presentationComplete(framesWritten, audioHALFrames)) { -- cgit v1.2.3