mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
Track explicit (MSE) duration separately
This commit is contained in:
@@ -210,6 +210,8 @@ MediaDecoderStateMachine::MediaDecoderStateMachine(MediaDecoder* aDecoder,
|
||||
mDurationSet(false),
|
||||
mNetworkDuration(mTaskQueue, NullableTimeUnit(),
|
||||
"MediaDecoderStateMachine::mNetworkDuration (Mirror)"),
|
||||
mExplicitDuration(mTaskQueue, Maybe<double>(),
|
||||
"MediaDecoderStateMachine::mExplicitDuration (Mirror)"),
|
||||
mPlayState(mTaskQueue, MediaDecoder::PLAY_STATE_LOADING,
|
||||
"MediaDecoderStateMachine::mPlayState (Mirror)"),
|
||||
mNextPlayState(mTaskQueue, MediaDecoder::PLAY_STATE_PAUSED,
|
||||
@@ -308,6 +310,7 @@ MediaDecoderStateMachine::InitializationTask()
|
||||
|
||||
// Connect mirrors.
|
||||
mNetworkDuration.Connect(mDecoder->CanonicalNetworkDuration());
|
||||
mExplicitDuration.Connect(mDecoder->CanonicalExplicitDuration());
|
||||
mPlayState.Connect(mDecoder->CanonicalPlayState());
|
||||
mNextPlayState.Connect(mDecoder->CanonicalNextPlayState());
|
||||
mLogicallySeeking.Connect(mDecoder->CanonicalLogicallySeeking());
|
||||
@@ -322,6 +325,7 @@ MediaDecoderStateMachine::InitializationTask()
|
||||
mWatchManager.Watch(mLogicalPlaybackRate, &MediaDecoderStateMachine::LogicalPlaybackRateChanged);
|
||||
mWatchManager.Watch(mPreservesPitch, &MediaDecoderStateMachine::PreservesPitchChanged);
|
||||
mWatchManager.Watch(mNetworkDuration, &MediaDecoderStateMachine::RecomputeDuration);
|
||||
mWatchManager.Watch(mExplicitDuration, &MediaDecoderStateMachine::RecomputeDuration);
|
||||
mWatchManager.Watch(mPlayState, &MediaDecoderStateMachine::PlayStateChanged);
|
||||
mWatchManager.Watch(mLogicallySeeking, &MediaDecoderStateMachine::LogicallySeekingChanged);
|
||||
}
|
||||
@@ -1420,7 +1424,16 @@ void MediaDecoderStateMachine::RecomputeDuration()
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
|
||||
if (mInfo.mMetadataDuration.isSome()) {
|
||||
if (mExplicitDuration.Ref().isSome()) {
|
||||
double d = mExplicitDuration.Ref().ref();
|
||||
if (IsNaN(d)) {
|
||||
// We have an explicit duration (which means that we shouldn't look at
|
||||
// any other duration sources), but the duration isn't ready yet.
|
||||
return;
|
||||
}
|
||||
TimeUnit duration = TimeUnit::FromSeconds(d);
|
||||
SetDuration(duration.ToMicroseconds());
|
||||
} else if (mInfo.mMetadataDuration.isSome()) {
|
||||
SetDuration(mInfo.mMetadataDuration.ref().ToMicroseconds());
|
||||
} else if (mInfo.mMetadataEndTime.isSome() && mStartTime >= 0) {
|
||||
SetDuration((mInfo.mMetadataEndTime.ref() - TimeUnit::FromMicroseconds(mStartTime)).ToMicroseconds());
|
||||
@@ -2542,6 +2555,7 @@ MediaDecoderStateMachine::FinishShutdown()
|
||||
|
||||
// Disconnect canonicals and mirrors before shutting down our task queue.
|
||||
mNetworkDuration.DisconnectIfConnected();
|
||||
mExplicitDuration.DisconnectIfConnected();
|
||||
mPlayState.DisconnectIfConnected();
|
||||
mNextPlayState.DisconnectIfConnected();
|
||||
mLogicallySeeking.DisconnectIfConnected();
|
||||
|
||||
Reference in New Issue
Block a user