From 2d85f097d653b21d1ff2c34f0b732c674d20ccc2 Mon Sep 17 00:00:00 2001 From: Andy Hung Date: Wed, 7 Jan 2015 12:45:13 -0800 Subject: Fix cumulative error in setPositionNotificationPeriod Time for AudioTrackThread sleep due to periodic notification needs to be computed from actual position. External reported AOSP issue 65807. Change-Id: Ic46b64588e6c5803afcd8252cde8837eb3fbf6ff --- media/libmedia/AudioTrack.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'media/libmedia') diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp index ca36143..99750bd 100644 --- a/media/libmedia/AudioTrack.cpp +++ b/media/libmedia/AudioTrack.cpp @@ -1746,10 +1746,11 @@ nsecs_t AudioTrack::processAudioBuffer() minFrames = markerPosition - position; } if (loopPeriod > 0 && loopPeriod < minFrames) { + // loopPeriod is already adjusted for actual position. minFrames = loopPeriod; } - if (updatePeriod > 0 && updatePeriod < minFrames) { - minFrames = updatePeriod; + if (updatePeriod > 0) { + minFrames = min(minFrames, uint32_t(newPosition - position)); } // If > 0, poll periodically to recover from a stuck server. A good value is 2. -- cgit v1.1