diff --git a/dom/media/MediaDecoderStateMachine.cpp b/dom/media/MediaDecoderStateMachine.cpp index 3fce5a8e3f7e..b11419110655 100644 --- a/dom/media/MediaDecoderStateMachine.cpp +++ b/dom/media/MediaDecoderStateMachine.cpp @@ -197,7 +197,6 @@ public: virtual void HandleAudioWaited(MediaData::Type aType); virtual void HandleVideoWaited(MediaData::Type aType); virtual void HandleNotWaited(const WaitForDataRejectValue& aRejection); - virtual void HandleEndOfStream() {} virtual void HandleAudioCaptured() {} virtual void HandleWaitingForAudio() @@ -213,7 +212,6 @@ public: virtual void HandleEndOfAudio() { AudioQueue().Finish(); - HandleEndOfStream(); } virtual void HandleWaitingForVideo() @@ -229,7 +227,6 @@ public: virtual void HandleEndOfVideo() { VideoQueue().Finish(); - HandleEndOfStream(); } virtual RefPtr HandleSeek(SeekTarget aTarget); @@ -662,7 +659,8 @@ public: CheckSlowDecoding(aDecodeStart); } - void HandleEndOfStream() override; + void HandleEndOfAudio() override; + void HandleEndOfVideo() override; void HandleWaitingForAudio() override { @@ -1646,7 +1644,8 @@ public: mMaster->ScheduleStateMachine(); } - void HandleEndOfStream() override; + void HandleEndOfAudio() override; + void HandleEndOfVideo() override; void HandleVideoSuspendTimeout() override { @@ -2102,8 +2101,21 @@ DecodingState::Enter() void MediaDecoderStateMachine:: -DecodingState::HandleEndOfStream() +DecodingState::HandleEndOfAudio() { + AudioQueue().Finish(); + if (mMaster->CheckIfDecodeComplete()) { + SetState(); + } else { + MaybeStopPrerolling(); + } +} + +void +MediaDecoderStateMachine:: +DecodingState::HandleEndOfVideo() +{ + VideoQueue().Finish(); if (mMaster->CheckIfDecodeComplete()) { SetState(); } else { @@ -2274,8 +2286,22 @@ BufferingState::Step() void MediaDecoderStateMachine:: -BufferingState::HandleEndOfStream() +BufferingState::HandleEndOfAudio() { + AudioQueue().Finish(); + if (mMaster->CheckIfDecodeComplete()) { + SetState(); + } else { + // Check if we can exit buffering. + mMaster->ScheduleStateMachine(); + } +} + +void +MediaDecoderStateMachine:: +BufferingState::HandleEndOfVideo() +{ + VideoQueue().Finish(); if (mMaster->CheckIfDecodeComplete()) { SetState(); } else {