Move post-duration-change seeking into MediaDecoder where it belongs

This commit is contained in:
trav90
2017-07-02 04:39:07 -05:00
committed by Roy Tam
parent cf35cc45a2
commit 44d5199751
2 changed files with 4 additions and 30 deletions
-30
View File
@@ -1396,21 +1396,6 @@ int64_t MediaDecoderStateMachine::GetEndTime()
return mEndTime;
}
// Runnable which dispatches an event to the main thread to seek to the new
// aSeekTarget.
class SeekRunnable : public nsRunnable {
public:
SeekRunnable(MediaDecoder* aDecoder, double aSeekTarget)
: mDecoder(aDecoder), mSeekTarget(aSeekTarget) {}
NS_IMETHOD Run() {
mDecoder->Seek(mSeekTarget, SeekTarget::Accurate);
return NS_OK;
}
private:
nsRefPtr<MediaDecoder> mDecoder;
double mSeekTarget;
};
void MediaDecoderStateMachine::RecomputeDuration()
{
MOZ_ASSERT(OnTaskQueue());
@@ -1477,21 +1462,6 @@ void MediaDecoderStateMachine::SetDuration(TimeUnit aDuration)
}
mEndTime = mStartTime + aDuration.ToMicroseconds();
if (mDecoder && mEndTime >= 0 && mEndTime < mCurrentPosition) {
// The current playback position is now past the end of the element duration
// the user agent must also seek to the time of the end of the media
// resource.
if (NS_IsMainThread()) {
// Seek synchronously.
mDecoder->Seek(double(mEndTime) / USECS_PER_S, SeekTarget::Accurate);
} else {
// Queue seek to new end position.
nsCOMPtr<nsIRunnable> task =
new SeekRunnable(mDecoder, double(mEndTime) / USECS_PER_S);
AbstractThread::MainThread()->Dispatch(task.forget());
}
}
}
void MediaDecoderStateMachine::SetFragmentEndTime(int64_t aEndTime)