Merge backout
authorMatthew Gregan <kinetik@flim.org>
Fri, 26 Feb 2010 15:11:52 -0800
changeset 38770 32c9e45bdf374e28ed015e93b24fbfed0c13eb10
parent 38767 1f8d93376db0184870667af70b1b8b85009229e3 (current diff)
parent 38768 0d981e2a7a258d653ad5130e8a2bca23673f6d25 (diff)
child 38771 c0a7a30a8a3055c29892b479dadb6435eb30393b
push idunknown
push userunknown
push dateunknown
milestone1.9.3a2pre
Merge backout
content/media/ogg/nsOggDecoder.cpp
--- a/content/media/ogg/nsOggDecoder.cpp
+++ b/content/media/ogg/nsOggDecoder.cpp
@@ -1079,16 +1079,19 @@ 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;
@@ -1099,16 +1102,19 @@ 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;
  }
@@ -1117,16 +1123,18 @@ 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;
@@ -1496,19 +1504,16 @@ 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;