Bug 525401 - Fix resuming from pause when playing poorly muxed videos. r=chris.double
☠☠ backed out by 0d981e2a7a25 ☠ ☠
authorMatthew Gregan <kinetik@flim.org>
Fri, 05 Feb 2010 17:06:08 +1300
changeset 38763 9b33c91c851d1a722f8c1c64f210c7c593faf6ae
parent 38762 b876c36242dc3bfd4344caffae55a9590ee1b42d
child 38764 d7a32460bb32036be124cf002d8a44e01e26c124
child 38768 0d981e2a7a258d653ad5130e8a2bca23673f6d25
push idunknown
push userunknown
push dateunknown
reviewerschris.double
bugs525401
milestone1.9.3a2pre
Bug 525401 - Fix resuming from pause when playing poorly muxed videos. r=chris.double
content/media/ogg/nsOggDecoder.cpp
--- a/content/media/ogg/nsOggDecoder.cpp
+++ b/content/media/ogg/nsOggDecoder.cpp
@@ -1079,19 +1079,16 @@ void nsOggDecodeStateMachine::StartPlayb
   }
 
   // If we have been paused previously, then compute duration spent paused
   if (!mPauseStartTime.IsNull()) {
     mPauseDuration += TimeStamp::Now() - mPauseStartTime;
     // Null out mPauseStartTime
     mPauseStartTime = TimeStamp();
   }
-  mPlayStartTime = TimeStamp::Now();
-  mPauseDuration = 0;
-
 }
 
 void nsOggDecodeStateMachine::StopPlayback()
 {
   PR_ASSERT_CURRENT_THREAD_IN_MONITOR(mDecoder->GetMonitor());
   mLastFrame = mDecodedFrames.ResetTimes(mCallbackPeriod);
   StopAudio();
   mPlaying = PR_FALSE;
@@ -1102,19 +1099,16 @@ void nsOggDecodeStateMachine::PausePlayb
 {
   if (!mAudioStream) {
     StopPlayback();
     return;
   }
   mAudioStream->Pause();
   mPlaying = PR_FALSE;
   mPauseStartTime = TimeStamp::Now();
-  if (mAudioStream->GetPosition() < 0) {
-    mLastFrame = mDecodedFrames.ResetTimes(mCallbackPeriod);
-  }
 }
 
 void nsOggDecodeStateMachine::ResumePlayback()
 {
  if (!mAudioStream) {
     StartPlayback();
     return;
  }
@@ -1123,18 +1117,16 @@ void nsOggDecodeStateMachine::ResumePlay
  mPlaying = PR_TRUE;
 
  // Compute duration spent paused
  if (!mPauseStartTime.IsNull()) {
    mPauseDuration += TimeStamp::Now() - mPauseStartTime;
    // Null out mPauseStartTime
    mPauseStartTime = TimeStamp();
  }
- mPlayStartTime = TimeStamp::Now();
- mPauseDuration = 0;
 }
 
 void nsOggDecodeStateMachine::UpdatePlaybackPosition(float aTime)
 {
   PR_ASSERT_CURRENT_THREAD_IN_MONITOR(mDecoder->GetMonitor());
   mCurrentFrameTime = aTime - mPlaybackStartTime;
   if (!mPositionChangeQueued) {
     mPositionChangeQueued = PR_TRUE;
@@ -1504,16 +1496,19 @@ nsresult nsOggDecodeStateMachine::Run()
           nsCOMPtr<nsIRunnable> event = new nsOggStepDecodeEvent(this, mPlayer);
           mStepDecodeThread->Dispatch(event, NS_DISPATCH_NORMAL);
         }
 
         // Get the decoded frames and store them in our queue of decoded frames
         QueueDecodedFrames();
         while (mDecodedFrames.IsEmpty() && !mDecodingCompleted &&
                !mBufferExhausted) {
+          if (mPlaying) {
+            PausePlayback();
+          }
           mon.Wait(PR_MillisecondsToInterval(PRInt64(mCallbackPeriod*500)));
           if (mState != DECODER_STATE_DECODING)
             break;
           QueueDecodedFrames();
         }
 
         if (mState != DECODER_STATE_DECODING)
           continue;