From f2e2db81ac75a3c94f9f92fd6876bedd0c3da69d Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Wed, 21 Jan 2015 21:53:04 -0800 Subject: [PATCH] Bug 1121148 - Make QUICK_BUFFERING_LOW_DATA_USECS a member variable and adjust it appropriately. r=cpearce --- dom/media/MediaDecoderStateMachine.cpp | 10 ++++++++-- dom/media/MediaDecoderStateMachine.h | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/dom/media/MediaDecoderStateMachine.cpp b/dom/media/MediaDecoderStateMachine.cpp index 0c322b454846..3b93471d916d 100644 --- a/dom/media/MediaDecoderStateMachine.cpp +++ b/dom/media/MediaDecoderStateMachine.cpp @@ -162,6 +162,8 @@ static const uint32_t EXHAUSTED_DATA_MARGIN_USECS = 60000; // back to buffering normally. static const uint32_t QUICK_BUFFER_THRESHOLD_USECS = 2000000; +namespace detail { + // If we're quick buffering, we'll remain in buffering mode while we have less than // QUICK_BUFFERING_LOW_DATA_USECS of decoded data available. static const uint32_t QUICK_BUFFERING_LOW_DATA_USECS = 1000000; @@ -170,9 +172,11 @@ static const uint32_t QUICK_BUFFERING_LOW_DATA_USECS = 1000000; // quick buffering in a timely fashion, as the decode pauses when it // reaches AMPLE_AUDIO_USECS decoded data, and thus we'll never reach // QUICK_BUFFERING_LOW_DATA_USECS. -static_assert(QUICK_BUFFERING_LOW_DATA_USECS <= detail::AMPLE_AUDIO_USECS, +static_assert(QUICK_BUFFERING_LOW_DATA_USECS <= AMPLE_AUDIO_USECS, "QUICK_BUFFERING_LOW_DATA_USECS is too large"); +} // namespace detail + // The amount of instability we tollerate in calls to // MediaDecoderStateMachine::UpdateEstimatedDuration(); changes of duration // less than this are ignored, as they're assumed to be the result of @@ -215,6 +219,7 @@ MediaDecoderStateMachine::MediaDecoderStateMachine(MediaDecoder* aDecoder, mAmpleVideoFrames(2), mLowAudioThresholdUsecs(detail::LOW_AUDIO_USECS), mAmpleAudioThresholdUsecs(detail::AMPLE_AUDIO_USECS), + mQuickBufferingLowDataThresholdUsecs(detail::QUICK_BUFFERING_LOW_DATA_USECS), mIsAudioPrerolling(false), mIsVideoPrerolling(false), mAudioRequestStatus(RequestStatus::Idle), @@ -2347,6 +2352,7 @@ MediaDecoderStateMachine::FinishDecodeFirstFrame() // order to reduce memory usage. mAmpleAudioThresholdUsecs /= NO_VIDEO_AMPLE_AUDIO_DIVISOR; mLowAudioThresholdUsecs /= NO_VIDEO_AMPLE_AUDIO_DIVISOR; + mQuickBufferingLowDataThresholdUsecs /= NO_VIDEO_AMPLE_AUDIO_DIVISOR; } // Get potentially updated metadata @@ -2814,7 +2820,7 @@ nsresult MediaDecoderStateMachine::RunStateMachine() bool isLiveStream = resource->GetLength() == -1; if ((isLiveStream || !mDecoder->CanPlayThrough()) && elapsed < TimeDuration::FromSeconds(mBufferingWait * mPlaybackRate) && - (mQuickBuffering ? HasLowDecodedData(QUICK_BUFFERING_LOW_DATA_USECS) + (mQuickBuffering ? HasLowDecodedData(mQuickBufferingLowDataThresholdUsecs) : HasLowUndecodedData(mBufferingWait * USECS_PER_S)) && mDecoder->IsExpectingMoreData()) { diff --git a/dom/media/MediaDecoderStateMachine.h b/dom/media/MediaDecoderStateMachine.h index 9b8224186cf0..5b463de0e212 100644 --- a/dom/media/MediaDecoderStateMachine.h +++ b/dom/media/MediaDecoderStateMachine.h @@ -955,6 +955,10 @@ protected: // we detect that the decode can't keep up with rendering. int64_t mAmpleAudioThresholdUsecs; + // If we're quick buffering, we'll remain in buffering mode while we have less than + // QUICK_BUFFERING_LOW_DATA_USECS of decoded data available. + int64_t mQuickBufferingLowDataThresholdUsecs; + // At the start of decoding we want to "preroll" the decode until we've // got a few frames decoded before we consider whether decode is falling // behind. Otherwise our "we're falling behind" logic will trigger