From bdf79ad2b25f1ea9dd607222ba165c8144f798b3 Mon Sep 17 00:00:00 2001 From: Chris Pearce Date: Thu, 24 Mar 2011 11:28:58 +1300 Subject: [PATCH] Bug 628665 - Supress warnings in nsBuiltinDecoderStateMachine. r=roc --- .../media/nsAudioAvailableEventManager.cpp | 2 +- .../media/nsBuiltinDecoderStateMachine.cpp | 19 +++++++++---------- content/media/nsBuiltinDecoderStateMachine.h | 2 +- content/media/nsMediaDecoder.cpp | 3 ++- content/media/ogg/nsOggReader.cpp | 7 ++++--- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/content/media/nsAudioAvailableEventManager.cpp b/content/media/nsAudioAvailableEventManager.cpp index a5e4e8e588e4..0f821e26b289 100644 --- a/content/media/nsAudioAvailableEventManager.cpp +++ b/content/media/nsAudioAvailableEventManager.cpp @@ -96,7 +96,7 @@ nsAudioAvailableEventManager::~nsAudioAvailableEventManager() void nsAudioAvailableEventManager::Init(PRUint32 aChannels, PRUint32 aRate) { NS_ASSERTION(aChannels != 0 && aRate != 0, "Audio metadata not known."); - mSamplesPerSecond = aChannels * aRate; + mSamplesPerSecond = static_cast(aChannels * aRate); } void nsAudioAvailableEventManager::DispatchPendingEvents(PRUint64 aCurrentTime) diff --git a/content/media/nsBuiltinDecoderStateMachine.cpp b/content/media/nsBuiltinDecoderStateMachine.cpp index 7c2133d46534..94b99a5b0acb 100644 --- a/content/media/nsBuiltinDecoderStateMachine.cpp +++ b/content/media/nsBuiltinDecoderStateMachine.cpp @@ -78,7 +78,7 @@ static const PRUint32 LOW_AUDIO_MS = 300; // decoding more audio. If we increase the low audio threshold (see // LOW_AUDIO_MS above) we'll also increase this value to ensure it's not // less than the low audio threshold. -const unsigned AMPLE_AUDIO_MS = 1000; +const PRInt64 AMPLE_AUDIO_MS = 1000; // Maximum number of bytes we'll allocate and write at once to the audio // hardware when the audio stream contains missing samples and we're @@ -330,12 +330,11 @@ void nsBuiltinDecoderStateMachine::DecodeLoop() videoPlaying = mReader->DecodeVideoFrame(skipToNextKeyframe, currentTime); decodeTime = TimeStamp::Now() - start; } - if (THRESHOLD_FACTOR * decodeTime.ToMilliseconds() > lowAudioThreshold && + if (THRESHOLD_FACTOR * DurationToMs(decodeTime) > lowAudioThreshold && !HasLowUndecodedData()) { lowAudioThreshold = - NS_MIN(static_cast(THRESHOLD_FACTOR * decodeTime.ToMilliseconds()), - static_cast(AMPLE_AUDIO_MS)); + NS_MIN(THRESHOLD_FACTOR * DurationToMs(decodeTime), AMPLE_AUDIO_MS); ampleAudioThreshold = NS_MAX(THRESHOLD_FACTOR * lowAudioThreshold, ampleAudioThreshold); LOG(PR_LOG_DEBUG, @@ -1458,7 +1457,7 @@ void nsBuiltinDecoderStateMachine::AdvanceFrame() if (currentFrame) { // Decode one frame and display it. TimeStamp presTime = mPlayStartTime - mPlayDuration + - TimeDuration::FromMilliseconds(currentFrame->mTime - mStartTime); + MsToDuration(currentFrame->mTime - mStartTime); NS_ASSERTION(currentFrame->mTime >= mStartTime, "Should have positive frame time"); { MonitorAutoExit exitMon(mDecoder->GetMonitor()); @@ -1513,21 +1512,21 @@ void nsBuiltinDecoderStateMachine::AdvanceFrame() } } -void nsBuiltinDecoderStateMachine::Wait(PRUint32 aMs) { +void nsBuiltinDecoderStateMachine::Wait(PRInt64 aMs) { mDecoder->GetMonitor().AssertCurrentThreadIn(); - TimeStamp end = TimeStamp::Now() + TimeDuration::FromMilliseconds(aMs); + TimeStamp end = TimeStamp::Now() + MsToDuration(aMs); TimeStamp now; while ((now = TimeStamp::Now()) < end && mState != DECODER_STATE_SHUTDOWN && mState != DECODER_STATE_SEEKING) { - PRInt64 ms = NS_round((end - now).ToSeconds() * 1000); - if (ms == 0) { + PRInt64 ms = static_cast(NS_round((end - now).ToSeconds() * 1000)); + if (ms == 0 || ms > PR_UINT32_MAX) { break; } NS_ASSERTION(ms <= aMs && ms > 0, "nsBuiltinDecoderStateMachine::Wait interval very wrong!"); - mDecoder->GetMonitor().Wait(PR_MillisecondsToInterval(ms)); + mDecoder->GetMonitor().Wait(PR_MillisecondsToInterval(static_cast(ms))); } } diff --git a/content/media/nsBuiltinDecoderStateMachine.h b/content/media/nsBuiltinDecoderStateMachine.h index cb423a889b9c..28a0cde0631f 100644 --- a/content/media/nsBuiltinDecoderStateMachine.h +++ b/content/media/nsBuiltinDecoderStateMachine.h @@ -282,7 +282,7 @@ protected: // time, and that the myriad of Notify()s we do an the decoder monitor // don't cause the audio thread to be starved. The decoder monitor must // be locked. - void Wait(PRUint32 aMs); + void Wait(PRInt64 aMs); // Dispatches an asynchronous event to update the media element's ready state. void UpdateReadyState(); diff --git a/content/media/nsMediaDecoder.cpp b/content/media/nsMediaDecoder.cpp index 4ebfcddf2770..e0b67c6e08ce 100644 --- a/content/media/nsMediaDecoder.cpp +++ b/content/media/nsMediaDecoder.cpp @@ -335,7 +335,8 @@ PRBool nsMediaDecoder::CanPlayThrough() // our download rate or decode rate estimation is otherwise inaccurate, // we don't suddenly discover that we need to buffer. This is particularly // required near the start of the media, when not much data is downloaded. - PRInt64 readAheadMargin = stats.mPlaybackRate * CAN_PLAY_THROUGH_MARGIN; + PRInt64 readAheadMargin = + static_cast(stats.mPlaybackRate * CAN_PLAY_THROUGH_MARGIN); return stats.mTotalBytes == stats.mDownloadPosition || stats.mDownloadPosition > stats.mPlaybackPosition + readAheadMargin; } diff --git a/content/media/ogg/nsOggReader.cpp b/content/media/ogg/nsOggReader.cpp index b0f23f90cacd..2c4fc0991497 100644 --- a/content/media/ogg/nsOggReader.cpp +++ b/content/media/ogg/nsOggReader.cpp @@ -1301,8 +1301,9 @@ PageSync(nsMediaStream* aStream, NS_ASSERTION(buffer, "Must have a buffer"); // Read from the file into the buffer - PRInt64 bytesToRead = NS_MIN(static_cast(PAGE_STEP), - aEndOffset - readHead); + PRUint32 bytesToRead = + static_cast(NS_MIN(static_cast(PAGE_STEP), + aEndOffset - readHead)); if (bytesToRead <= 0) { return PAGE_SYNC_END_OF_RANGE; } @@ -1426,7 +1427,7 @@ nsresult nsOggReader::SeekBisection(PRInt64 aTarget, // offset using an exponential backoff until we determine the time. SEEK_LOG(PR_LOG_DEBUG, ("Backing off %d bytes, backsteps=%d", static_cast(PAGE_STEP * pow(2.0, backsteps)), backsteps)); - guess -= PAGE_STEP * pow(2.0, backsteps); + guess -= PAGE_STEP * static_cast(pow(2.0, backsteps)); backsteps = NS_MIN(backsteps + 1, maxBackStep); // We reset mustBackoff. If we still need to backoff further, it will // be set to PR_TRUE again.