diff --git a/dom/media/MediaDecoderStateMachine.cpp b/dom/media/MediaDecoderStateMachine.cpp index 8871ffcf1e..9d6aa124eb 100644 --- a/dom/media/MediaDecoderStateMachine.cpp +++ b/dom/media/MediaDecoderStateMachine.cpp @@ -1906,12 +1906,24 @@ MediaDecoderStateMachine::InitiateSeek() Reset(); // Do the seek. + nsRefPtr self = this; mSeekRequest.Begin(ProxyMediaCall(DecodeTaskQueue(), mReader.get(), __func__, &MediaDecoderReader::Seek, mCurrentSeek.mTarget.mTime, GetEndTime()) - ->RefableThen(TaskQueue(), __func__, this, - &MediaDecoderStateMachine::OnSeekCompleted, - &MediaDecoderStateMachine::OnSeekFailed)); + ->RefableThen(TaskQueue(), __func__, + [self] (int64_t) -> void { + ReentrantMonitorAutoEnter mon(self->mDecoder->GetReentrantMonitor()); + self->mSeekRequest.Complete(); + // We must decode the first samples of active streams, so we can determine + // the new stream time. So dispatch tasks to do that. + self->mDecodeToSeekTarget = true; + self->DispatchDecodeTasksIfNeeded(); + }, [self] (nsresult aResult) -> void { + ReentrantMonitorAutoEnter mon(self->mDecoder->GetReentrantMonitor()); + self->mSeekRequest.Complete(); + MOZ_ASSERT(NS_FAILED(aResult), "Cancels should also disconnect mSeekRequest"); + self->DecodeError(); + })); } nsresult @@ -2399,30 +2411,6 @@ MediaDecoderStateMachine::FinishDecodeFirstFrame() return NS_OK; } -void -MediaDecoderStateMachine::OnSeekCompleted(int64_t aTime) -{ - MOZ_ASSERT(OnTaskQueue()); - ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor()); - mSeekRequest.Complete(); - - // We must decode the first samples of active streams, so we can determine - // the new stream time. So dispatch tasks to do that. - mDecodeToSeekTarget = true; - - DispatchDecodeTasksIfNeeded(); -} - -void -MediaDecoderStateMachine::OnSeekFailed(nsresult aResult) -{ - MOZ_ASSERT(OnTaskQueue()); - ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor()); - mSeekRequest.Complete(); - MOZ_ASSERT(NS_FAILED(aResult), "Cancels should also disconnect mSeekRequest"); - DecodeError(); -} - void MediaDecoderStateMachine::SeekCompleted() { diff --git a/dom/media/MediaDecoderStateMachine.h b/dom/media/MediaDecoderStateMachine.h index 28981260d4..4375812c8c 100644 --- a/dom/media/MediaDecoderStateMachine.h +++ b/dom/media/MediaDecoderStateMachine.h @@ -431,9 +431,6 @@ public: OnNotDecoded(MediaData::VIDEO_DATA, aReason); } - void OnSeekCompleted(int64_t aTime); - void OnSeekFailed(nsresult aResult); - // Resets all state related to decoding and playback, emptying all buffers // and aborting all pending operations on the decode task queue. void Reset();