Bug 651023 - Round up wait times to 1ms to ensure we drop the decoder monitor when presenting video frames. r=kinetik
authorChris Pearce <chris@pearce.org.nz>
Thu, 12 May 2011 14:02:34 +1200
changeset 69373 d15d6f06eeb640e5be38782fedd0dd7c324cab5d
parent 69372 641121a4139e8813be5b11640976dd2a36f1de2e
child 69374 745a8761a2d8df46872760babc03fac11a4f1719
push id19945
push usercpearce@mozilla.com
push dateThu, 12 May 2011 02:14:44 +0000
treeherdermozilla-central@d15d6f06eeb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskinetik
bugs651023
milestone6.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 651023 - Round up wait times to 1ms to ensure we drop the decoder monitor when presenting video frames. r=kinetik
content/media/nsBuiltinDecoderStateMachine.cpp
content/media/nsBuiltinDecoderStateMachine.h
--- a/content/media/nsBuiltinDecoderStateMachine.cpp
+++ b/content/media/nsBuiltinDecoderStateMachine.cpp
@@ -1543,17 +1543,17 @@ void nsBuiltinDecoderStateMachine::Advan
         mState == DECODER_STATE_COMPLETED) {
       mDecoder->GetReentrantMonitor().Wait();
     }
   }
 }
 
 void nsBuiltinDecoderStateMachine::Wait(PRInt64 aUsecs) {
   mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
-  TimeStamp end = TimeStamp::Now() + UsecsToDuration(aUsecs);
+  TimeStamp end = TimeStamp::Now() + UsecsToDuration(PR_MAX(USECS_PER_MS, aUsecs));
   TimeStamp now;
   while ((now = TimeStamp::Now()) < end &&
          mState != DECODER_STATE_SHUTDOWN &&
          mState != DECODER_STATE_SEEKING)
   {
     PRInt64 ms = static_cast<PRInt64>(NS_round((end - now).ToSeconds() * 1000));
     if (ms == 0 || ms > PR_UINT32_MAX) {
       break;
--- a/content/media/nsBuiltinDecoderStateMachine.h
+++ b/content/media/nsBuiltinDecoderStateMachine.h
@@ -282,19 +282,20 @@ protected:
   PRBool HasFutureAudio() const;
 
   // Returns PR_TRUE if we recently exited "quick buffering" mode.
   PRBool JustExitedQuickBuffering();
 
   // Waits on the decoder ReentrantMonitor for aUsecs microseconds. If the decoder
   // monitor is awoken by a Notify() call, we'll continue waiting, unless
   // we've moved into shutdown state. This enables us to ensure that we
-  // wait for a specified 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.
+  // wait for a specified time, and that the myriad of Notify()s we do on
+  // the decoder monitor don't cause the audio thread to be starved. aUsecs
+  // values of less than 1 millisecond are rounded up to 1 millisecond
+  // (see bug 651023). The decoder monitor must be held.
   void Wait(PRInt64 aUsecs);
 
   // Dispatches an asynchronous event to update the media element's ready state.
   void UpdateReadyState();
 
   // Resets playback timing data. Called when we seek, on the state machine
   // thread.
   void ResetPlayback();