Bug 496147 - Ensure ended is true when video playback is ended. r=doublec,sr=roc
authorChris Pearce <chris@pearce.org.nz>
Fri, 12 Jun 2009 12:56:50 +1200
changeset 29106 b9574b9d769085fbacfd5e6c9b1ca45bd35095a8
parent 29105 497fe6fed36e0c799a466f269e214dbc3df4326e
child 29107 9eed09531a50c5b2db50be13b7de5fdda9ed0e5c
push id7423
push userrocallahan@mozilla.com
push dateFri, 12 Jun 2009 02:16:07 +0000
treeherderautoland@b3c4e464fed7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdoublec, roc
bugs496147
milestone1.9.2a1pre
Bug 496147 - Ensure ended is true when video playback is ended. r=doublec,sr=roc
content/media/video/src/nsOggDecoder.cpp
--- a/content/media/video/src/nsOggDecoder.cpp
+++ b/content/media/video/src/nsOggDecoder.cpp
@@ -905,25 +905,32 @@ void nsOggDecodeStateMachine::PlayFrame(
         // FrameData start again from a time position of 0.
         // Reset the play start time.
         mPlayStartTime = TimeStamp::Now();
         mPauseDuration = TimeDuration(0);
         frame->mState = OGGPLAY_STREAM_INITIALISED;
       }
 
       double time;
+      double prevTime = -1.0;
       for (;;) {
         // Even if the frame has had its audio data written we call
         // PlayAudio to ensure that any data we have buffered in the
         // nsAudioStream is written to the hardware.
         PlayAudio(frame);
         double hwtime = mAudioStream ? mAudioStream->GetPosition() : -1.0;
         time = hwtime < 0.0 ?
           (TimeStamp::Now() - mPlayStartTime - mPauseDuration).ToSeconds() :
           hwtime;
+        // Break out of the loop if we've not played any audio. This can
+        // happen when the frame has no audio, and there's no audio pending
+        // in the nsAudioStream.
+        if (time == prevTime)
+          break;
+        prevTime = time;
         if (time < frame->mTime) {
           mon.Wait(PR_MillisecondsToInterval(PRInt64((frame->mTime - time)*1000)));
           if (mState == DECODER_STATE_SHUTDOWN)
             return;
           continue;
         }
         break;
       }