Bug 1320466 part 3 - implement OnAudioWaited(), OnVideoWaited() and OnNotWaited() callbacks in MDSM; r?jwwang
MozReview-Commit-ID: JA83a23p0Fd
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -2039,16 +2039,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
@@ -2141,24 +2163,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();