From be797e327fd3f9977ca900279632807370cf5cf8 Mon Sep 17 00:00:00 2001 From: JW Wang Date: Wed, 17 May 2017 16:00:46 +0800 Subject: [PATCH] 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 --HG-- extra : rebase_source : b95887154a2392ca5a6fcb45b4c2dad60fb65b70 --- dom/media/MediaDecoderStateMachine.cpp | 19 ++++--------------- dom/media/MediaDecoderStateMachine.h | 9 --------- 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/dom/media/MediaDecoderStateMachine.cpp b/dom/media/MediaDecoderStateMachine.cpp index 2b4eed3bbce7..384547dd7515 100644 --- a/dom/media/MediaDecoderStateMachine.cpp +++ b/dom/media/MediaDecoderStateMachine.cpp @@ -2166,7 +2166,10 @@ DecodeMetadataState::OnMetadataRead(MetadataHolder* aMetadata) MOZ_ASSERT(mMaster->mDuration.Ref().isSome()); - mMaster->EnqueueLoadedMetadataEvent(); + mMaster->mMetadataLoadedEvent.Notify( + nsAutoPtr(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 @@ -2681,7 +2684,6 @@ MediaDecoderStateMachine::MediaDecoderStateMachine(MediaDecoder* aDecoder, mAmpleAudioThreshold(detail::AMPLE_AUDIO_THRESHOLD), mAudioCaptured(false), mMinimizePreroll(aDecoder->GetMinimizePreroll()), - mSentLoadedMetadataEvent(false), mSentFirstFrameLoadedEvent(false), mVideoDecodeSuspended(false), mVideoDecodeSuspendTimer(mTaskQueue), @@ -3466,19 +3468,6 @@ MediaDecoderStateMachine::DecodeError(const MediaResult& aError) mOnPlaybackErrorEvent.Notify(aError); } -void -MediaDecoderStateMachine::EnqueueLoadedMetadataEvent() -{ - MOZ_ASSERT(OnTaskQueue()); - MediaDecoderEventVisibility visibility = - mSentLoadedMetadataEvent ? MediaDecoderEventVisibility::Suppressed - : MediaDecoderEventVisibility::Observable; - mMetadataLoadedEvent.Notify(nsAutoPtr(new MediaInfo(Info())), - Move(mMetadataTags), - visibility); - mSentLoadedMetadataEvent = true; -} - void MediaDecoderStateMachine::EnqueueFirstFrameLoadedEvent() { diff --git a/dom/media/MediaDecoderStateMachine.h b/dom/media/MediaDecoderStateMachine.h index 1cd7f918c707..507f97b38d73 100644 --- a/dom/media/MediaDecoderStateMachine.h +++ b/dom/media/MediaDecoderStateMachine.h @@ -423,11 +423,6 @@ protected: // 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. @@ -640,10 +635,6 @@ private: 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