Bug 1365520. P1 - remove MDSM::mSentLoadedMetadataEvent and MDSM::EnqueueLoadedMetadataEvent(). r?kaku
The current call flow ensures decoding metadata only happens at most once
and therefore EnqueueLoadedMetadataEvent() will only be called at most once.
We don't need the mSentLoadedMetadataEvent flag.
MozReview-Commit-ID: E95jtRrKupw
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -2161,17 +2161,20 @@ DecodeMetadataState::OnMetadataRead(Meta
SLOG("Video decode isAsync=%d HWAccel=%d videoQueueSize=%d",
Reader()->IsAsync(),
Reader()->VideoIsHardwareAccelerated(),
mMaster->GetAmpleVideoFrames());
}
MOZ_ASSERT(mMaster->mDuration.Ref().isSome());
- mMaster->EnqueueLoadedMetadataEvent();
+ mMaster->mMetadataLoadedEvent.Notify(
+ nsAutoPtr<MediaInfo>(new MediaInfo(aMetadata->mInfo)),
+ Move(mMaster->mMetadataTags),
+ MediaDecoderEventVisibility::Observable);
if (Info().IsEncrypted() && !mMaster->mCDMProxy) {
// Metadata parsing was successful but we're still waiting for CDM caps
// to become available so that we can build the correct decryptor/decoder.
SetState<WaitForCDMState>();
} else {
SetState<DecodingFirstFrameState>();
}
@@ -2676,17 +2679,16 @@ MediaDecoderStateMachine::MediaDecoderSt
mCurrentFrameID(0),
INIT_WATCHABLE(mObservedDuration, TimeUnit()),
mReader(new MediaDecoderReaderWrapper(mTaskQueue, aReader)),
mPlaybackRate(1.0),
mLowAudioThreshold(detail::LOW_AUDIO_THRESHOLD),
mAmpleAudioThreshold(detail::AMPLE_AUDIO_THRESHOLD),
mAudioCaptured(false),
mMinimizePreroll(aDecoder->GetMinimizePreroll()),
- mSentLoadedMetadataEvent(false),
mSentFirstFrameLoadedEvent(false),
mVideoDecodeSuspended(false),
mVideoDecodeSuspendTimer(mTaskQueue),
mOutputStreamManager(new OutputStreamManager()),
mResource(aDecoder->GetResource()),
mVideoDecodeMode(VideoDecodeMode::Normal),
mIsMSE(aDecoder->IsMSE()),
INIT_MIRROR(mBuffered, TimeIntervals()),
@@ -3462,29 +3464,16 @@ MediaDecoderStateMachine::DecodeError(co
MOZ_ASSERT(OnTaskQueue());
MOZ_ASSERT(!IsShutdown());
LOGW("Decode error");
// Notify the decode error and MediaDecoder will shut down MDSM.
mOnPlaybackErrorEvent.Notify(aError);
}
void
-MediaDecoderStateMachine::EnqueueLoadedMetadataEvent()
-{
- MOZ_ASSERT(OnTaskQueue());
- MediaDecoderEventVisibility visibility =
- mSentLoadedMetadataEvent ? MediaDecoderEventVisibility::Suppressed
- : MediaDecoderEventVisibility::Observable;
- mMetadataLoadedEvent.Notify(nsAutoPtr<MediaInfo>(new MediaInfo(Info())),
- Move(mMetadataTags),
- visibility);
- mSentLoadedMetadataEvent = true;
-}
-
-void
MediaDecoderStateMachine::EnqueueFirstFrameLoadedEvent()
{
MOZ_ASSERT(OnTaskQueue());
// Track value of mSentFirstFrameLoadedEvent from before updating it
bool firstFrameBeenLoaded = mSentFirstFrameLoadedEvent;
mSentFirstFrameLoadedEvent = true;
MediaDecoderEventVisibility visibility =
firstFrameBeenLoaded ? MediaDecoderEventVisibility::Suppressed
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -418,21 +418,16 @@ protected:
void MaybeStartPlayback();
// Moves the decoder into the shutdown state, and dispatches an error
// event to the media element. This begins shutting down the decoder.
// The decoder monitor must be held. This is only called on the
// decode thread.
void DecodeError(const MediaResult& aError);
- // Dispatches a LoadedMetadataEvent.
- // This is threadsafe and can be called on any thread.
- // The decoder monitor must be held.
- void EnqueueLoadedMetadataEvent();
-
void EnqueueFirstFrameLoadedEvent();
// Start a task to decode audio.
void RequestAudioData();
// Start a task to decode video.
void RequestVideoData(bool aSkipToNextKeyframe,
const media::TimeUnit& aCurrentTime);
@@ -635,20 +630,16 @@ private:
// Stores presentation info required for playback.
Maybe<MediaInfo> mInfo;
nsAutoPtr<MetadataTags> mMetadataTags;
mozilla::MediaMetadataManager mMetadataManager;
- // True if we are back from DECODER_STATE_DORMANT state and
- // LoadedMetadataEvent was already sent.
- bool mSentLoadedMetadataEvent;
-
// True if we've decoded first frames (thus having the start time) and
// notified the FirstFrameLoaded event. Note we can't initiate seek until the
// start time is known which happens when the first frames are decoded or we
// are playing an MSE stream (the start time is always assumed 0).
bool mSentFirstFrameLoadedEvent;
// True if video decoding is suspended.
bool mVideoDecodeSuspended;