Bug 1160695 - Clean up SetDuration and remove negative duration case. r=jww

This commit is contained in:
Bobby Holley 2015-06-02 19:51:45 -07:00
Родитель 5d37b9d6aa
Коммит 8bdb81bbd6
2 изменённых файлов: 8 добавлений и 12 удалений

Просмотреть файл

@ -1491,7 +1491,7 @@ void MediaDecoderStateMachine::RecomputeDuration()
fireDurationChanged = true;
}
SetDuration(duration.ToMicroseconds());
SetDuration(duration);
if (fireDurationChanged) {
nsCOMPtr<nsIRunnable> event =
@ -1500,29 +1500,25 @@ void MediaDecoderStateMachine::RecomputeDuration()
}
}
void MediaDecoderStateMachine::SetDuration(int64_t aDuration)
void MediaDecoderStateMachine::SetDuration(TimeUnit aDuration)
{
MOZ_ASSERT(OnTaskQueue());
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
if (aDuration < 0) {
mDurationSet = false;
return;
}
MOZ_ASSERT(aDuration.ToMicroseconds() >= 0);
mDurationSet = true;
if (mStartTime == -1) {
SetStartTime(0);
}
if (aDuration == INT64_MAX) {
if (aDuration.IsInfinite()) {
mEndTime = -1;
return;
}
mEndTime = mStartTime + aDuration;
mEndTime = mStartTime + aDuration.ToMicroseconds();
if (mDecoder && mEndTime >= 0 && mEndTime < mCurrentPosition.ReadOnWrongThread()) {
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.

Просмотреть файл

@ -204,7 +204,7 @@ public:
// media metadata. The decoder monitor must be obtained before calling this.
// aDuration is in microseconds.
// A value of INT64_MAX will be treated as infinity.
void SetDuration(int64_t aDuration);
void SetDuration(media::TimeUnit aDuration);
// Functions used by assertions to ensure we're calling things
// on the appropriate threads.