Bug 814308 - MediaDecoder::SetDuration doesn't handle aDuration=inf correctly. r=kinetik

This commit is contained in:
Paul Adenot 2013-01-24 20:28:48 +01:00
Родитель fb545c5be5
Коммит 4be8e0040b
1 изменённых файлов: 9 добавлений и 1 удалений

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

@ -23,6 +23,7 @@
#include <cstdlib> // for std::abs(int/long) #include <cstdlib> // for std::abs(int/long)
#include <cmath> // for std::abs(float/double) #include <cmath> // for std::abs(float/double)
#include <algorithm> #include <algorithm>
#include <mozilla/FloatingPoint.h>
#ifdef MOZ_WMF #ifdef MOZ_WMF
#include "WMFDecoder.h" #include "WMFDecoder.h"
@ -1189,7 +1190,14 @@ void MediaDecoder::DurationChanged()
void MediaDecoder::SetDuration(double aDuration) void MediaDecoder::SetDuration(double aDuration)
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
if (MOZ_DOUBLE_IS_INFINITE(aDuration)) {
SetInfinite(true);
} else if (MOZ_DOUBLE_IS_NaN(aDuration)) {
mDuration = -1;
SetInfinite(true);
} else {
mDuration = static_cast<int64_t>(NS_round(aDuration * static_cast<double>(USECS_PER_S))); mDuration = static_cast<int64_t>(NS_round(aDuration * static_cast<double>(USECS_PER_S)));
}
ReentrantMonitorAutoEnter mon(GetReentrantMonitor()); ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
if (mDecoderStateMachine) { if (mDecoderStateMachine) {