NuPlayer: fix av discontinuity race
Assumption:
NuPlayer must see both (a/v) discontinuities before resuming.
Example issue:
Suppose we're changing the video track, so the video source queues a
DISCONTINUITY_FORMATCHANGE, and the audio source queues a DISCONTINUITY_NONE.
Consider this sequence of events without this change:
1. audio discontinuity seen by player
2. mFlushingAudio = FLUSHED
3. video discontinuity seen by player
4. mFlushingAudio != NONE so no performScanSources is queued
5. video decoding shuts down without being restarted
Bug: 15153976
Change-Id: I659550d9c0f883828103142abead857f576f25b1
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
index adc5f33..58d0138 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
@@ -1230,14 +1230,15 @@
mTimeDiscontinuityPending =
mTimeDiscontinuityPending || timeChange;
+ if (mFlushingAudio == NONE && mFlushingVideo == NONE) {
+ // And we'll resume scanning sources once we're done
+ // flushing.
+ mDeferredActions.push_front(
+ new SimpleAction(
+ &NuPlayer::performScanSources));
+ }
+
if (formatChange || timeChange) {
- if (mFlushingAudio == NONE && mFlushingVideo == NONE) {
- // And we'll resume scanning sources once we're done
- // flushing.
- mDeferredActions.push_front(
- new SimpleAction(
- &NuPlayer::performScanSources));
- }
sp<AMessage> newFormat = mSource->getFormat(audio);
sp<Decoder> &decoder = audio ? mAudioDecoder : mVideoDecoder;