Bug 1405025. P2 - revert
Bug 1390443 P1.
Since we don't use state-mirroring to dispatch nextFrameStatus changes, we
can now revert the workaround of
bug 1390443 P1. See
bug 1390443 comment 0
for more details.
MozReview-Commit-ID: FRxXUnGC3x2
--- a/dom/media/MediaDecoder.h
+++ b/dom/media/MediaDecoder.h
@@ -377,19 +377,19 @@ private:
void UpdateReadyState()
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
GetOwner()->UpdateReadyState();
}
- virtual MediaDecoderOwner::NextFrameStatus NextFrameStatus()
+ MediaDecoderOwner::NextFrameStatus NextFrameStatus() const
{
- return !IsEnded() ? mNextFrameStatus : MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE;
+ return mNextFrameStatus;
}
virtual MediaDecoderOwner::NextFrameStatus NextFrameBufferedStatus();
// Returns a string describing the state of the media player internal
// data. Used for debugging purposes.
virtual void GetMozDebugReaderData(nsACString& aString);
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -1942,16 +1942,20 @@ public:
auto clockTime =
std::max(mMaster->AudioEndTime(), mMaster->VideoEndTime());
if (mMaster->mDuration.Ref()->IsInfinite()) {
// We have a finite duration when playback reaches the end.
mMaster->mDuration = Some(clockTime);
}
mMaster->UpdatePlaybackPosition(clockTime);
+ // Ensure readyState is updated before firing the 'ended' event.
+ mMaster->mOnNextFrameStatus.Notify(
+ MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE);
+
mMaster->mOnPlaybackEvent.Notify(MediaEventType::PlaybackEnded);
mSentPlaybackEndedEvent = true;
// MediaSink::GetEndTime() must be called before stopping playback.
mMaster->StopMediaSink();
}
}