Bug 943461. Part 17: MediaDecoderStateMachine::StopPlayback should not set mPlayDuration based on real time, but on whatever we're using for GetClock. r=cpearce
authorRobert O'Callahan <robert@ocallahan.org>
Fri, 13 Dec 2013 01:33:01 +1300
changeset 162334 75ca7a7c5df7cd5bde7f409c412a0a58bc753e04
parent 162333 6a6bae856337e444e5e909e78e692e77bf17ff88
child 162335 0279107b81d321e2c5279d2e7c33fc9563d1be73
push idunknown
push userunknown
push dateunknown
reviewerscpearce
bugs943461
milestone29.0a1
Bug 943461. Part 17: MediaDecoderStateMachine::StopPlayback should not set mPlayDuration based on real time, but on whatever we're using for GetClock. r=cpearce
content/media/MediaDecoderStateMachine.cpp
--- a/content/media/MediaDecoderStateMachine.cpp
+++ b/content/media/MediaDecoderStateMachine.cpp
@@ -1308,17 +1308,17 @@ void MediaDecoderStateMachine::StopPlayb
 {
   DECODER_LOG(PR_LOG_DEBUG, ("%p StopPlayback()", mDecoder.get()));
 
   AssertCurrentThreadInMonitor();
 
   mDecoder->NotifyPlaybackStopped();
 
   if (IsPlaying()) {
-    mPlayDuration += DurationToUsecs(TimeStamp::Now() - mPlayStartTime);
+    mPlayDuration = GetClock();
     mPlayStartTime = TimeStamp();
   }
   // Notify the audio thread, so that it notices that we've stopped playing,
   // so it can pause audio playback.
   mDecoder->GetReentrantMonitor().NotifyAll();
   NS_ASSERTION(!IsPlaying(), "Should report not playing at end of StopPlayback()");
   mDecoder->UpdateStreamBlockingForStateMachinePlaying();
 }
@@ -2417,17 +2417,16 @@ void MediaDecoderStateMachine::RenderVid
   if (container) {
     container->SetCurrentFrame(aData->mDisplay, aData->mImage, aTarget);
   }
 }
 
 int64_t
 MediaDecoderStateMachine::GetAudioClock()
 {
-  NS_ASSERTION(OnStateMachineThread(), "Should be on state machine thread.");
   // We must hold the decoder monitor while using the audio stream off the
   // audio thread to ensure that it doesn't get destroyed on the audio thread
   // while we're using it.
   AssertCurrentThreadInMonitor();
   if (!HasAudio() || mAudioCaptured)
     return -1;
   if (!mAudioStream) {
     // Audio thread hasn't played any data yet.
@@ -2452,18 +2451,18 @@ int64_t MediaDecoderStateMachine::GetVid
   }
 
   int64_t pos = DurationToUsecs(TimeStamp::Now() - mPlayStartTime) + mPlayDuration;
   pos -= mBasePosition;
   NS_ASSERTION(pos >= 0, "Video stream position should be positive.");
   return mBasePosition + pos * mPlaybackRate + mStartTime;
 }
 
-int64_t MediaDecoderStateMachine::GetClock() {
-  NS_ASSERTION(OnStateMachineThread(), "Should be on state machine thread.");
+int64_t MediaDecoderStateMachine::GetClock()
+{
   AssertCurrentThreadInMonitor();
 
   // Determine the clock time. If we've got audio, and we've not reached
   // the end of the audio, use the audio clock. However if we've finished
   // audio, or don't have audio, use the system clock. If our output is being
   // fed to a MediaStream, use that stream as the source of the clock.
   int64_t clock_time = -1;
   DecodedStreamData* stream = mDecoder->GetDecodedStream();