Bug 1131884 - Video buffering calculation fails for some MP4 videos - r=jya a=lmandel
authorChris Double <chris.double@double.co.nz>
Mon, 09 Mar 2015 12:16:58 +1300
changeset 250404 bb7b546e6188
parent 250403 fe5932c2b378
child 250405 297e2e626fe9
child 250408 c04edbbdb3cc
child 250410 f41e32dec66c
push id4576
push usercdouble@mozilla.com
push date2015-03-16 23:47 +0000
treeherdermozilla-beta@bb7b546e6188 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya, lmandel
bugs1131884
milestone37.0
Bug 1131884 - Video buffering calculation fails for some MP4 videos - r=jya a=lmandel Playback position used in calculating buffering time is set during metadata reading. This is at end of file for the video in the bug. As a result the buffering data is always wrong. Changed to not setting position during metadata - it is set during frame playback anyway. Also changes buffering timeout to 15s from 30s.
dom/media/MediaDecoder.cpp
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -1485,32 +1485,31 @@ void MediaDecoder::StopProgressUpdates()
 
 void MediaDecoder::StartProgressUpdates()
 {
   MOZ_ASSERT(OnStateMachineThread() || OnDecodeThread());
   GetReentrantMonitor().AssertCurrentThreadIn();
   mIgnoreProgressData = false;
   if (mResource) {
     mResource->SetReadMode(MediaCacheStream::MODE_PLAYBACK);
-    mDecoderPosition = mPlaybackPosition = mResource->Tell();
   }
 }
 
 void MediaDecoder::SetLoadInBackground(bool aLoadInBackground)
 {
   MOZ_ASSERT(NS_IsMainThread());
   if (mResource) {
     mResource->SetLoadInBackground(aLoadInBackground);
   }
 }
 
 void MediaDecoder::UpdatePlaybackOffset(int64_t aOffset)
 {
   ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
-  mPlaybackPosition = std::max(aOffset, mPlaybackPosition);
+  mPlaybackPosition = aOffset;
 }
 
 bool MediaDecoder::OnStateMachineThread() const
 {
   return mDecoderStateMachine->OnStateMachineThread();
 }
 
 void MediaDecoder::SetPlaybackRate(double aPlaybackRate)
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -257,17 +257,17 @@ MediaDecoderStateMachine::MediaDecoderSt
     Preferences::AddUintVarCache(&sVideoQueueDefaultSize,
                                  "media.video-queue.default-size",
                                  MAX_VIDEO_QUEUE_SIZE);
     Preferences::AddUintVarCache(&sVideoQueueHWAccelSize,
                                  "media.video-queue.hw-accel-size",
                                  MIN_VIDEO_QUEUE_SIZE);
   }
 
-  mBufferingWait = IsRealTime() ? 0 : 30;
+  mBufferingWait = IsRealTime() ? 0 : 15;
   mLowDataThresholdUsecs = IsRealTime() ? 0 : detail::LOW_DATA_THRESHOLD_USECS;
 
 #ifdef XP_WIN
   // Ensure high precision timers are enabled on Windows, otherwise the state
   // machine thread isn't woken up at reliable intervals to set the next frame,
   // and we drop frames while painting. Note that multiple calls to this
   // function per-process is OK, provided each call is matched by a corresponding
   // timeEndPeriod() call.