--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -2510,32 +2510,16 @@ MediaDecoderStateMachine::NeedToDecodeAu
return IsAudioDecoding() &&
mState != DECODER_STATE_SEEKING &&
((!mSentFirstFrameLoadedEvent && AudioQueue().GetSize() == 0) ||
(!mMinimizePreroll && !HaveEnoughDecodedAudio()));
}
void
-MediaDecoderStateMachine::OnAudioDecoded(MediaData* aAudio)
-{
- MOZ_ASSERT(OnTaskQueue());
- MOZ_ASSERT(aAudio);
-
- mAudioDataRequest.Complete();
-
- // audio->GetEndTime() is not always mono-increasing in chained ogg.
- mDecodedAudioEndTime = std::max(aAudio->GetEndTime(), mDecodedAudioEndTime);
-
- SAMPLE_LOG("OnAudioDecoded [%lld,%lld]", aAudio->mTime, aAudio->GetEndTime());
-
- mStateObj->HandleAudioDecoded(aAudio);
-}
-
-void
MediaDecoderStateMachine::Push(MediaData* aSample)
{
MOZ_ASSERT(OnTaskQueue());
MOZ_ASSERT(aSample);
if (aSample->mType == MediaData::AUDIO_DATA) {
// TODO: Send aSample to MSG and recalculate readystate before pushing,
// otherwise AdvanceFrame may pop the sample before we have a chance
@@ -2564,74 +2548,16 @@ MediaDecoderStateMachine::OnAudioPopped(
void
MediaDecoderStateMachine::OnVideoPopped(const RefPtr<MediaData>& aSample)
{
MOZ_ASSERT(OnTaskQueue());
mPlaybackOffset = std::max(mPlaybackOffset.Ref(), aSample->mOffset);
DispatchVideoDecodeTaskIfNeeded();
}
-void
-MediaDecoderStateMachine::OnAudioNotDecoded(const MediaResult& aError)
-{
- MOZ_ASSERT(OnTaskQueue());
- SAMPLE_LOG("OnAudioNotDecoded aError=%u", aError.Code());
- mAudioDataRequest.Complete();
- mStateObj->HandleNotDecoded(MediaData::AUDIO_DATA, aError);
-}
-
-void
-MediaDecoderStateMachine::OnVideoNotDecoded(const MediaResult& aError)
-{
- MOZ_ASSERT(OnTaskQueue());
- SAMPLE_LOG("OnVideoNotDecoded aError=%u", aError.Code());
- mVideoDataRequest.Complete();
- mStateObj->HandleNotDecoded(MediaData::VIDEO_DATA, aError);
-}
-
-void
-MediaDecoderStateMachine::OnVideoDecoded(MediaData* aVideo,
- TimeStamp aDecodeStartTime)
-{
- MOZ_ASSERT(OnTaskQueue());
- MOZ_ASSERT(aVideo);
-
- mVideoDataRequest.Complete();
-
- // 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);
- mStateObj->HandleAudioWaited(aType);
-}
-
-void
-MediaDecoderStateMachine::OnVideoWaited(MediaData::Type aType)
-{
- MOZ_ASSERT(OnTaskQueue());
- MOZ_ASSERT(aType == MediaData::VIDEO_DATA);
- mStateObj->HandleVideoWaited(aType);
-}
-
-void
-MediaDecoderStateMachine::OnNotWaited(const WaitForDataRejectValue& aRejection)
-{
- MOZ_ASSERT(OnTaskQueue());
- mStateObj->HandleNotWaited(aRejection);
-}
-
bool
MediaDecoderStateMachine::IsAudioDecoding()
{
MOZ_ASSERT(OnTaskQueue());
return HasAudio() && !AudioQueue().IsFinished();
}
bool
@@ -3039,19 +2965,30 @@ void
MediaDecoderStateMachine::RequestAudioData()
{
MOZ_ASSERT(OnTaskQueue());
SAMPLE_LOG("Queueing audio task - queued=%i, decoder-queued=%o",
AudioQueue().GetSize(), mReader->SizeOfAudioQueueInFrames());
mAudioDataRequest.Begin(
mReader->RequestAudioData()->Then(
- OwnerThread(), __func__, this,
- &MediaDecoderStateMachine::OnAudioDecoded,
- &MediaDecoderStateMachine::OnAudioNotDecoded)
+ OwnerThread(), __func__,
+ [this] (MediaData* aAudio) {
+ MOZ_ASSERT(aAudio);
+ mAudioDataRequest.Complete();
+ // audio->GetEndTime() is not always mono-increasing in chained ogg.
+ mDecodedAudioEndTime = std::max(aAudio->GetEndTime(), mDecodedAudioEndTime);
+ SAMPLE_LOG("OnAudioDecoded [%lld,%lld]", aAudio->mTime, aAudio->GetEndTime());
+ mStateObj->HandleAudioDecoded(aAudio);
+ },
+ [this] (const MediaResult& aError) {
+ SAMPLE_LOG("OnAudioNotDecoded aError=%u", aError.Code());
+ mAudioDataRequest.Complete();
+ mStateObj->HandleNotDecoded(MediaData::AUDIO_DATA, aError);
+ })
);
}
void
MediaDecoderStateMachine::DispatchVideoDecodeTaskIfNeeded()
{
MOZ_ASSERT(OnTaskQueue());
if (!IsShutdown() && NeedToDecodeVideo()) {
@@ -3093,53 +3030,62 @@ MediaDecoderStateMachine::RequestVideoDa
VideoQueue().GetSize(), mReader->SizeOfVideoQueueInFrames(), aSkipToNextKeyframe,
aCurrentTime.ToMicroseconds());
TimeStamp videoDecodeStartTime = TimeStamp::Now();
mVideoDataRequest.Begin(
mReader->RequestVideoData(aSkipToNextKeyframe, aCurrentTime)->Then(
OwnerThread(), __func__,
[this, videoDecodeStartTime] (MediaData* aVideo) {
- OnVideoDecoded(aVideo, videoDecodeStartTime);
+ MOZ_ASSERT(aVideo);
+ mVideoDataRequest.Complete();
+ // Handle abnormal or negative timestamps.
+ mDecodedVideoEndTime = std::max(mDecodedVideoEndTime, aVideo->GetEndTime());
+ SAMPLE_LOG("OnVideoDecoded [%lld,%lld]", aVideo->mTime, aVideo->GetEndTime());
+ mStateObj->HandleVideoDecoded(aVideo, videoDecodeStartTime);
},
[this] (const MediaResult& aError) {
- OnVideoNotDecoded(aError);
+ SAMPLE_LOG("OnVideoNotDecoded aError=%u", aError.Code());
+ mVideoDataRequest.Complete();
+ mStateObj->HandleNotDecoded(MediaData::VIDEO_DATA, aError);
})
);
}
void
MediaDecoderStateMachine::WaitForData(MediaData::Type aType)
{
MOZ_ASSERT(OnTaskQueue());
MOZ_ASSERT(aType == MediaData::AUDIO_DATA || aType == MediaData::VIDEO_DATA);
if (aType == MediaData::AUDIO_DATA) {
mAudioWaitRequest.Begin(
mReader->WaitForData(MediaData::AUDIO_DATA)->Then(
OwnerThread(), __func__,
[this] (MediaData::Type aType) {
mAudioWaitRequest.Complete();
- OnAudioWaited(aType);
+ MOZ_ASSERT(aType == MediaData::AUDIO_DATA);
+ mStateObj->HandleAudioWaited(aType);
},
[this] (const WaitForDataRejectValue& aRejection) {
mAudioWaitRequest.Complete();
- OnNotWaited(aRejection);
+ mStateObj->HandleNotWaited(aRejection);
})
);
} else {
mVideoWaitRequest.Begin(
mReader->WaitForData(MediaData::VIDEO_DATA)->Then(
OwnerThread(), __func__,
[this] (MediaData::Type aType) {
mVideoWaitRequest.Complete();
- OnVideoWaited(aType);
+ MOZ_ASSERT(aType == MediaData::VIDEO_DATA);
+ mStateObj->HandleVideoWaited(aType);
},
[this] (const WaitForDataRejectValue& aRejection) {
mVideoWaitRequest.Complete();
- OnNotWaited(aRejection);
+ mStateObj->HandleNotWaited(aRejection);
})
);
}
}
void
MediaDecoderStateMachine::StartMediaSink()
{
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -319,24 +319,16 @@ private:
// True if shutdown process has begun.
bool IsShutdown() const;
// 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 OnAudioNotDecoded(const MediaResult& aError);
- void OnVideoNotDecoded(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();