Bug 1301341. Part 2 - Remove unused members. draft
authorJW Wang <jwwang@mozilla.com>
Tue, 06 Sep 2016 14:48:29 +0800
changeset 412050 f6eb06c49b374ed825cc1e1647339a0c481afea5
parent 412049 8c7a489337a14d500f19512827084ca1e6e2de5d
child 530861 441c3bdbb33e14409a4db9f73330fcfadabc7c30
push id29034
push userjwwang@mozilla.com
push dateFri, 09 Sep 2016 07:14:23 +0000
bugs1301341
milestone51.0a1
Bug 1301341. Part 2 - Remove unused members. MozReview-Commit-ID: 3S9hw6w0k1T
dom/media/MediaDecoderStateMachine.cpp
dom/media/MediaDecoderStateMachine.h
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -1835,33 +1835,16 @@ void MediaDecoderStateMachine::BufferedR
 
 void MediaDecoderStateMachine::ReaderSuspendedChanged()
 {
   MOZ_ASSERT(OnTaskQueue());
   DECODER_LOG("ReaderSuspendedChanged: %d", mIsReaderSuspended.Ref());
   SetDormant(mIsReaderSuspended);
 }
 
-void
-MediaDecoderStateMachine::ReadMetadata()
-{
-  MOZ_ASSERT(OnTaskQueue());
-  MOZ_ASSERT(!IsShutdown());
-  MOZ_ASSERT(mState == DECODER_STATE_DECODING_METADATA);
-  MOZ_ASSERT(!mMetadataRequest.Exists());
-
-  DECODER_LOG("Dispatching AsyncReadMetadata");
-  // Set mode to METADATA since we are about to read metadata.
-  mResource->SetReadMode(MediaCacheStream::MODE_METADATA);
-  mMetadataRequest.Begin(mReader->ReadMetadata()
-    ->Then(OwnerThread(), __func__, this,
-           &MediaDecoderStateMachine::OnMetadataRead,
-           &MediaDecoderStateMachine::OnMetadataNotRead));
-}
-
 RefPtr<MediaDecoder::SeekPromise>
 MediaDecoderStateMachine::Seek(SeekTarget aTarget)
 {
   MOZ_ASSERT(OnTaskQueue());
 
   if (IsShutdown()) {
     return MediaDecoder::SeekPromise::CreateAndReject(/* aIgnored = */ true, __func__);
   }
@@ -2307,93 +2290,16 @@ MediaDecoderStateMachine::DecodeError()
   MOZ_ASSERT(OnTaskQueue());
   MOZ_ASSERT(!IsShutdown());
   DECODER_WARN("Decode error");
   // Notify the decode error and MediaDecoder will shut down MDSM.
   mOnPlaybackEvent.Notify(MediaEventType::DecodeError);
 }
 
 void
-MediaDecoderStateMachine::OnMetadataRead(MetadataHolder* aMetadata)
-{
-  MOZ_ASSERT(OnTaskQueue());
-  MOZ_ASSERT(mState == DECODER_STATE_DECODING_METADATA);
-  mMetadataRequest.Complete();
-
-  if (mPendingDormant) {
-    mPendingDormant = false;
-    SetDormant(true);
-    return;
-  }
-
-  // Set mode to PLAYBACK after reading metadata.
-  mResource->SetReadMode(MediaCacheStream::MODE_PLAYBACK);
-  mInfo = aMetadata->mInfo;
-  mMetadataTags = aMetadata->mTags.forget();
-  RefPtr<MediaDecoderStateMachine> self = this;
-
-  if (mInfo.mMetadataDuration.isSome()) {
-    RecomputeDuration();
-  } else if (mInfo.mUnadjustedMetadataEndTime.isSome()) {
-    mReader->AwaitStartTime()->Then(OwnerThread(), __func__,
-      [self] () -> void {
-        NS_ENSURE_TRUE_VOID(!self->IsShutdown());
-        TimeUnit unadjusted = self->mInfo.mUnadjustedMetadataEndTime.ref();
-        TimeUnit adjustment = self->mReader->StartTime();
-        self->mInfo.mMetadataDuration.emplace(unadjusted - adjustment);
-        self->RecomputeDuration();
-      }, [] () -> void { NS_WARNING("Adjusting metadata end time failed"); }
-    );
-  }
-
-  if (HasVideo()) {
-    DECODER_LOG("Video decode isAsync=%d HWAccel=%d videoQueueSize=%d",
-                mReader->IsAsync(),
-                mReader->VideoIsHardwareAccelerated(),
-                GetAmpleVideoFrames());
-  }
-
-  // In general, we wait until we know the duration before notifying the decoder.
-  // However, we notify  unconditionally in this case without waiting for the start
-  // time, since the caller might be waiting on metadataloaded to be fired before
-  // feeding in the CDM, which we need to decode the first frame (and
-  // thus get the metadata). We could fix this if we could compute the start
-  // time by demuxing without necessaring decoding.
-  bool waitingForCDM =
-#ifdef MOZ_EME
-    mInfo.IsEncrypted() && !mCDMProxy;
-#else
-    false;
-#endif
-  mNotifyMetadataBeforeFirstFrame = mDuration.Ref().isSome() || waitingForCDM;
-  if (mNotifyMetadataBeforeFirstFrame) {
-    EnqueueLoadedMetadataEvent();
-  }
-
-  if (waitingForCDM) {
-    // 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(DECODER_STATE_WAIT_FOR_CDM);
-    return;
-  }
-
-  SetState(DECODER_STATE_DECODING_FIRSTFRAME);
-}
-
-void
-MediaDecoderStateMachine::OnMetadataNotRead(ReadMetadataFailureReason aReason)
-{
-  MOZ_ASSERT(OnTaskQueue());
-  MOZ_ASSERT(mState == DECODER_STATE_DECODING_METADATA);
-  mMetadataRequest.Complete();
-  DECODER_WARN("Decode metadata failed, shutting down decoder");
-  DecodeError();
-}
-
-void
 MediaDecoderStateMachine::EnqueueLoadedMetadataEvent()
 {
   MOZ_ASSERT(OnTaskQueue());
   MediaDecoderEventVisibility visibility =
     mSentLoadedMetadataEvent ? MediaDecoderEventVisibility::Suppressed
                              : MediaDecoderEventVisibility::Observable;
   mMetadataLoadedEvent.Notify(nsAutoPtr<MediaInfo>(new MediaInfo(mInfo)),
                               Move(mMetadataTags),
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -273,18 +273,16 @@ private:
   // task that gets run on the task queue, and is dispatched from the MDSM
   // constructor immediately after the task queue is created.
   void InitializationTask(MediaDecoder* aDecoder);
 
   void SetDormant(bool aDormant);
 
   void SetAudioCaptured(bool aCaptured);
 
-  void ReadMetadata();
-
   RefPtr<MediaDecoder::SeekPromise> Seek(SeekTarget aTarget);
 
   RefPtr<ShutdownPromise> Shutdown();
 
   RefPtr<ShutdownPromise> FinishShutdown();
 
   // Update the playback position. This can result in a timeupdate event
   // and an invalidate of the frame being dispatched asynchronously if
@@ -532,20 +530,16 @@ protected:
   // decoded and playable. This is the sum of the number of usecs of audio which
   // is decoded and in the reader's audio queue, and the usecs of unplayed audio
   // which has been pushed to the audio hardware for playback. Note that after
   // calling this, the audio hardware may play some of the audio pushed to
   // hardware, so this can only be used as a upper bound. The decoder monitor
   // must be held when calling this. Called on the decode thread.
   int64_t GetDecodedAudioDuration();
 
-  // Promise callbacks for metadata reading.
-  void OnMetadataRead(MetadataHolder* aMetadata);
-  void OnMetadataNotRead(ReadMetadataFailureReason aReason);
-
   // Notify FirstFrameLoaded if having decoded first frames and
   // transition to SEEKING if there is any pending seek, or DECODING otherwise.
   void MaybeFinishDecodeFirstFrame();
 
   void FinishDecodeFirstFrame();
 
   // Completes the seek operation, moves onto the next appropriate state.
   void SeekCompleted();
@@ -811,21 +805,16 @@ private:
   // the state machine thread. Synchronised via decoder monitor.
   // When data is being sent to a MediaStream, this is true when all data has
   // been written to the MediaStream.
   Watchable<bool> mAudioCompleted;
 
   // True if all video frames are already rendered.
   Watchable<bool> mVideoCompleted;
 
-  // True if we need to enter dormant state after reading metadata. Note that
-  // we can't enter dormant state until reading metadata is done for some
-  // limitations of the reader.
-  bool mPendingDormant = false;
-
   // Flag whether we notify metadata before decoding the first frame or after.
   //
   // Note that the odd semantics here are designed to replicate the current
   // behavior where we notify the decoder each time we come out of dormant, but
   // send suppressed event visibility for those cases. This code can probably be
   // simplified.
   bool mNotifyMetadataBeforeFirstFrame;
 
@@ -848,19 +837,16 @@ private:
   // memory and CPU overhead.
   bool mMinimizePreroll;
 
   // True if the decode thread has gone filled its buffers and is now
   // waiting to be awakened before it continues decoding. Synchronized
   // by the decoder monitor.
   bool mDecodeThreadWaiting;
 
-  // Track our request for metadata from the reader.
-  MozPromiseRequestHolder<MediaDecoderReader::MetadataPromise> mMetadataRequest;
-
   // Stores presentation info required for playback. The decoder monitor
   // must be held when accessing this.
   MediaInfo mInfo;
 
   nsAutoPtr<MetadataTags> mMetadataTags;
 
   mozilla::MediaMetadataManager mMetadataManager;