Bug 1320466 part 3 - implement OnAudioWaited(), OnVideoWaited() and OnNotWaited() callbacks in MDSM; r=jwwang
authorKaku Kuo <kaku@mozilla.com>
Sat, 26 Nov 2016 13:50:51 +0800
changeset 324929 b40ed2eb5cb52584da45233c96398ada0118ceac
parent 324928 3af879aacac7069f3ba3fdf72c6add8b162957df
child 324930 e102e1d94504b6e93256a1613a0f9a9240ae941c
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersjwwang
bugs1320466
milestone53.0a1
Bug 1320466 part 3 - implement OnAudioWaited(), OnVideoWaited() and OnNotWaited() callbacks in MDSM; r=jwwang MozReview-Commit-ID: JA83a23p0Fd
dom/media/MediaDecoderStateMachine.cpp
dom/media/MediaDecoderStateMachine.h
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -1993,16 +1993,38 @@ MediaDecoderStateMachine::OnVideoDecoded
   // Handle abnormal or negative timestamps.
   mDecodedVideoEndTime = std::max(mDecodedVideoEndTime, aVideo->GetEndTime());
 
   SAMPLE_LOG("OnVideoDecoded [%lld,%lld]", aVideo->mTime, aVideo->GetEndTime());
 
   mStateObj->HandleVideoDecoded(aVideo, aDecodeStartTime);
 }
 
+void
+MediaDecoderStateMachine::OnAudioWaited(MediaData::Type aType)
+{
+  MOZ_ASSERT(OnTaskQueue());
+  MOZ_ASSERT(aType == MediaData::AUDIO_DATA);
+  EnsureAudioDecodeTaskQueued();
+}
+
+void
+MediaDecoderStateMachine::OnVideoWaited(MediaData::Type aType)
+{
+  MOZ_ASSERT(OnTaskQueue());
+  MOZ_ASSERT(aType == MediaData::VIDEO_DATA);
+  EnsureVideoDecodeTaskQueued();
+}
+
+void
+MediaDecoderStateMachine::OnNotWaited(const WaitForDataRejectValue& aRejection)
+{
+  MOZ_ASSERT(OnTaskQueue());
+}
+
 bool
 MediaDecoderStateMachine::IsAudioDecoding()
 {
   MOZ_ASSERT(OnTaskQueue());
   return HasAudio() && !AudioQueue().IsFinished();
 }
 
 bool
@@ -2095,24 +2117,28 @@ MediaDecoderStateMachine::SetMediaDecode
     } else {
       OnNotDecoded(MediaData::VIDEO_DATA, aData.as<MediaResult>());
     }
   });
 
   mAudioWaitCallback = mReader->AudioWaitCallback().Connect(
     mTaskQueue, [this] (WaitCallbackData aData) {
     if (aData.is<MediaData::Type>()) {
-      EnsureAudioDecodeTaskQueued();
+      OnAudioWaited(aData.as<MediaData::Type>());
+    } else {
+      OnNotWaited(aData.as<WaitForDataRejectValue>());
     }
   });
 
   mVideoWaitCallback = mReader->VideoWaitCallback().Connect(
     mTaskQueue, [this] (WaitCallbackData aData) {
     if (aData.is<MediaData::Type>()) {
-      EnsureVideoDecodeTaskQueued();
+      OnVideoWaited(aData.as<MediaData::Type>());
+    } else {
+      OnNotWaited(aData.as<WaitForDataRejectValue>());
     }
   });
 }
 
 void
 MediaDecoderStateMachine::CancelMediaDecoderReaderWrapperCallback()
 {
   MOZ_ASSERT(OnTaskQueue());
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -324,16 +324,19 @@ private:
 
   // Returns true if we're currently playing. The decoder monitor must
   // be held.
   bool IsPlaying() const;
 
   void OnAudioDecoded(MediaData* aAudio);
   void OnVideoDecoded(MediaData* aVideo, TimeStamp aDecodeStartTime);
   void OnNotDecoded(MediaData::Type aType, const MediaResult& aError);
+  void OnAudioWaited(MediaData::Type aType);
+  void OnVideoWaited(MediaData::Type aType);
+  void OnNotWaited(const WaitForDataRejectValue& aRejection);
 
   // Resets all state related to decoding and playback, emptying all buffers
   // and aborting all pending operations on the decode task queue.
   void Reset(TrackSet aTracks = TrackSet(TrackInfo::kAudioTrack,
                                          TrackInfo::kVideoTrack));
 
 protected:
   virtual ~MediaDecoderStateMachine();