Bug 1161742 - Use lambdas for Seek. r=jww

This commit is contained in:
Bobby Holley 2015-05-05 17:25:14 -07:00
parent 2d85ff9631
commit 2f01b6eb5e
2 changed files with 15 additions and 30 deletions

View File

@ -1910,12 +1910,24 @@ MediaDecoderStateMachine::InitiateSeek()
Reset(); Reset();
// Do the seek. // Do the seek.
nsRefPtr<MediaDecoderStateMachine> self = this;
mSeekRequest.Begin(ProxyMediaCall(DecodeTaskQueue(), mReader.get(), __func__, mSeekRequest.Begin(ProxyMediaCall(DecodeTaskQueue(), mReader.get(), __func__,
&MediaDecoderReader::Seek, mCurrentSeek.mTarget.mTime, &MediaDecoderReader::Seek, mCurrentSeek.mTarget.mTime,
GetEndTime()) GetEndTime())
->RefableThen(TaskQueue(), __func__, this, ->RefableThen(TaskQueue(), __func__,
&MediaDecoderStateMachine::OnSeekCompleted, [self] (int64_t) -> void {
&MediaDecoderStateMachine::OnSeekFailed)); 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 nsresult
@ -2395,30 +2407,6 @@ MediaDecoderStateMachine::FinishDecodeFirstFrame()
return NS_OK; 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 void
MediaDecoderStateMachine::SeekCompleted() MediaDecoderStateMachine::SeekCompleted()
{ {

View File

@ -427,9 +427,6 @@ public:
OnNotDecoded(MediaData::VIDEO_DATA, aReason); 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 // Resets all state related to decoding and playback, emptying all buffers
// and aborting all pending operations on the decode task queue. // and aborting all pending operations on the decode task queue.
void Reset(); void Reset();