Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b3cb72a1 authored by Eric Laurent's avatar Eric Laurent
Browse files

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
parent 15ad2470
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -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);
    }
}