Bug 1135170 - Move some work from MDSM::Seek to MDSM::InitiateSeek. r=mattwoodrow
This has two implications: * We no longer need to pipe mQueuedSeekTarget through MDSM::Seek to get the appropriate clamping. * MDSM::Seek doesn't _need_ to be called on the main thread anymore.
This commit is contained in:
@@ -483,7 +483,7 @@ void MediaDecoder::UpdateStreamBlockingForStateMachinePlaying()
|
|||||||
void MediaDecoder::RecreateDecodedStream(int64_t aStartTimeUSecs)
|
void MediaDecoder::RecreateDecodedStream(int64_t aStartTimeUSecs)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
GetReentrantMonitor().AssertCurrentThreadIn();
|
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
|
||||||
DECODER_LOG("RecreateDecodedStream aStartTimeUSecs=%lld!", aStartTimeUSecs);
|
DECODER_LOG("RecreateDecodedStream aStartTimeUSecs=%lld!", aStartTimeUSecs);
|
||||||
|
|
||||||
DestroyDecodedStream();
|
DestroyDecodedStream();
|
||||||
|
|||||||
@@ -1701,29 +1701,10 @@ void MediaDecoderStateMachine::Seek(const SeekTarget& aTarget)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mQueuedSeekTarget.Reset();
|
mQueuedSeekTarget.Reset();
|
||||||
|
mSeekTarget = aTarget;
|
||||||
// Bound the seek time to be inside the media range.
|
|
||||||
int64_t end = GetEndTime();
|
|
||||||
NS_ASSERTION(mStartTime != -1, "Should know start time by now");
|
|
||||||
NS_ASSERTION(end != -1, "Should know end time by now");
|
|
||||||
int64_t seekTime = aTarget.mTime + mStartTime;
|
|
||||||
seekTime = std::min(seekTime, end);
|
|
||||||
seekTime = std::max(mStartTime, seekTime);
|
|
||||||
NS_ASSERTION(seekTime >= mStartTime && seekTime <= end,
|
|
||||||
"Can only seek in range [0,duration]");
|
|
||||||
mSeekTarget = SeekTarget(seekTime, aTarget.mType, aTarget.mEventVisibility);
|
|
||||||
|
|
||||||
DECODER_LOG("Changed state to SEEKING (to %lld)", mSeekTarget.mTime);
|
DECODER_LOG("Changed state to SEEKING (to %lld)", mSeekTarget.mTime);
|
||||||
SetState(DECODER_STATE_SEEKING);
|
SetState(DECODER_STATE_SEEKING);
|
||||||
|
|
||||||
// TODO: We should re-create the decoded stream after seek completed as we do
|
|
||||||
// for audio thread since it is until then we know which position we seek to
|
|
||||||
// as far as fast-seek is concerned. It also fix the problem where stream
|
|
||||||
// clock seems to go backwards during seeking.
|
|
||||||
if (mAudioCaptured) {
|
|
||||||
mDecoder->RecreateDecodedStream(seekTime - mStartTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
ScheduleStateMachine();
|
ScheduleStateMachine();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1877,6 +1858,29 @@ MediaDecoderStateMachine::InitiateSeek()
|
|||||||
|
|
||||||
mCurrentSeekTarget = mSeekTarget;
|
mCurrentSeekTarget = mSeekTarget;
|
||||||
mSeekTarget.Reset();
|
mSeekTarget.Reset();
|
||||||
|
|
||||||
|
// Bound the seek time to be inside the media range.
|
||||||
|
int64_t end = GetEndTime();
|
||||||
|
NS_ASSERTION(mStartTime != -1, "Should know start time by now");
|
||||||
|
NS_ASSERTION(end != -1, "Should know end time by now");
|
||||||
|
int64_t seekTime = mCurrentSeekTarget.mTime + mStartTime;
|
||||||
|
seekTime = std::min(seekTime, end);
|
||||||
|
seekTime = std::max(mStartTime, seekTime);
|
||||||
|
NS_ASSERTION(seekTime >= mStartTime && seekTime <= end,
|
||||||
|
"Can only seek in range [0,duration]");
|
||||||
|
mCurrentSeekTarget.mTime = seekTime;
|
||||||
|
|
||||||
|
if (mAudioCaptured) {
|
||||||
|
// TODO: We should re-create the decoded stream after seek completed as we do
|
||||||
|
// for audio thread since it is until then we know which position we seek to
|
||||||
|
// as far as fast-seek is concerned. It also fix the problem where stream
|
||||||
|
// clock seems to go backwards during seeking.
|
||||||
|
nsCOMPtr<nsIRunnable> event =
|
||||||
|
NS_NewRunnableMethodWithArg<int64_t>(mDecoder, &MediaDecoder::RecreateDecodedStream,
|
||||||
|
seekTime - mStartTime);
|
||||||
|
NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
mDropAudioUntilNextDiscontinuity = HasAudio();
|
mDropAudioUntilNextDiscontinuity = HasAudio();
|
||||||
mDropVideoUntilNextDiscontinuity = HasVideo();
|
mDropVideoUntilNextDiscontinuity = HasVideo();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user