Prevent old callback events when track is recycled

When a track is reused from SoundPool and started again, the
previous callback events could be done after track started,
then the new playback will be stopped unintentionally.
Clear the old cblk flags when recycled track is started again
to avoid triggering unexpected callback events.

Bug: 112269355
Test: Playback with SoundPool frequently
Change-Id: I111b085d08b73c333fbb0fc2896efe1c013c584c
gugelfrei
Tomoharu Kasahara 7 years ago
parent 25af42f8bf
commit 6e8bf981ac

@ -631,6 +631,13 @@ 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 starting 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_STREAM_END_DONE | CBLK_DISABLED), &mCblk->mFlags);

Loading…
Cancel
Save