From 49be5fa3b72c3fe0ce80423099057e49335f0178 Mon Sep 17 00:00:00 2001 From: Yamit Mehta Date: Sun, 12 Jul 2015 13:14:52 +0530 Subject: libmedia: avoid processing stale callback events when track recycled when track is reused from SoundPool and started again, the previous callback events could be processed immediately after track started, the new playback will be stopped then clear the stale cblk flags when recycled track is started again to avoid triggering unexpected callback events Change-Id: Ifc6fd973c655e9c7866391e7004016a7df9a9b9c CRs-Fixed: 819973 --- media/libmedia/AudioTrack.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'media/libmedia/AudioTrack.cpp') diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp index 64eba73..fccc6dd 100644 --- a/media/libmedia/AudioTrack.cpp +++ b/media/libmedia/AudioTrack.cpp @@ -533,6 +533,12 @@ status_t AudioTrack::start() // force refresh of remaining frames by processAudioBuffer() as last // write before stop could be partial. mRefreshRemaining = true; + + // for static track, clear the old flags when start from stopped state + if (mSharedBuffer != 0) + android_atomic_and( + ~(CBLK_LOOP_CYCLE | CBLK_LOOP_FINAL | CBLK_BUFFER_END), + &mCblk->mFlags); } mNewPosition = mPosition + mUpdatePeriod; int32_t flags = android_atomic_and(~CBLK_DISABLED, &mCblk->mFlags); -- cgit v1.1