From b3cb72a17d9a472883e9e2faa18b42eac533fe99 Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Sat, 12 Oct 2013 17:05:19 -0700 Subject: SoundPool: handle new audio track event If the AudioTrack is torn down, SoundPool will never receive the buffer end event and the track will stay active for ever. The fix consists in stopping the AudioTrack when a new audiotrack event is received. Bug: 11193583. Change-Id: I9876eb2a8f75c601368f669acd67b0accf6e2736 --- media/libmedia/SoundPool.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'media/libmedia') diff --git a/media/libmedia/SoundPool.cpp b/media/libmedia/SoundPool.cpp index 8434d43..22e9fad 100644 --- a/media/libmedia/SoundPool.cpp +++ b/media/libmedia/SoundPool.cpp @@ -744,11 +744,16 @@ void SoundChannel::process(int event, void *info, unsigned long toggle) b->size = count; //ALOGV("buffer=%p, [0]=%d", b->i16, b->i16[0]); } - } else if (event == AudioTrack::EVENT_UNDERRUN || event == AudioTrack::EVENT_BUFFER_END) { - ALOGV("process %p channel %d EVENT_UNDERRUN or EVENT_BUFFER_END", this, mChannelID); + } else if (event == AudioTrack::EVENT_UNDERRUN || event == AudioTrack::EVENT_BUFFER_END || + event == AudioTrack::EVENT_NEW_IAUDIOTRACK) { + ALOGV("process %p channel %d event %s", + this, mChannelID, (event == AudioTrack::EVENT_UNDERRUN) ? "UNDERRUN" : + (event == AudioTrack::EVENT_BUFFER_END) ? "BUFFER_END" : "NEW_IAUDIOTRACK"); mSoundPool->addToStopList(this); } else if (event == AudioTrack::EVENT_LOOP_END) { ALOGV("End loop %p channel %d", this, mChannelID); + } else { + ALOGW("SoundChannel::process unexpected event %d", event); } } -- cgit v1.1