Backout fix for bug 922601 (changeset a36ab6c7f174) to fix regressions,a=lblakk
authorRobert O'Callahan <robert@ocallahan.org>
Tue, 17 Dec 2013 14:28:41 +1300
changeset 167746 344287e4c1cfc8aed374167fcb088a6e72d365c4
parent 167745 df7c72278682d3e8e062b1f49c2d077e0b6db958
child 167751 0610a4bd7f258c81ae4434e8f81ee9cc95bc0719
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslblakk
bugs922601
milestone27.0
Backout fix for bug 922601 (changeset a36ab6c7f174) to fix regressions,a=lblakk
content/media/MediaStreamGraph.cpp
--- a/content/media/MediaStreamGraph.cpp
+++ b/content/media/MediaStreamGraph.cpp
@@ -342,17 +342,16 @@ MediaStreamGraphImpl::UpdateCurrentTime(
   if (prevCurrentTime >= nextCurrentTime) {
     NS_ASSERTION(prevCurrentTime == nextCurrentTime, "Time can't go backwards!");
     // This could happen due to low clock resolution, maybe?
     LOG(PR_LOG_DEBUG, ("Time did not advance"));
     // There's not much left to do here, but the code below that notifies
     // listeners that streams have ended still needs to run.
   }
 
-  nsTArray<MediaStream*> streamsReadyToFinish;
   for (uint32_t i = 0; i < mStreams.Length(); ++i) {
     MediaStream* stream = mStreams[i];
 
     // Calculate blocked time and fire Blocked/Unblocked events
     GraphTime blockedTime = 0;
     GraphTime t = prevCurrentTime;
     while (t < nextCurrentTime) {
       GraphTime end;
@@ -378,38 +377,32 @@ MediaStreamGraphImpl::UpdateCurrentTime(
 
     if (blockedTime < nextCurrentTime - prevCurrentTime) {
       for (uint32_t i = 0; i < stream->mListeners.Length(); ++i) {
         MediaStreamListener* l = stream->mListeners[i];
         l->NotifyOutput(this);
       }
     }
 
-    if (stream->mFinished && !stream->mNotifiedFinished) {
-      streamsReadyToFinish.AppendElement(stream);
-    }
-    LOG(PR_LOG_DEBUG+1, ("MediaStream %p bufferStartTime=%f blockedTime=%f",
-                         stream, MediaTimeToSeconds(stream->mBufferStartTime),
-                         MediaTimeToSeconds(blockedTime)));
-  }
-
-  mCurrentTime = nextCurrentTime;
-
-  // Do this after setting mCurrentTime so that StreamTimeToGraphTime works properly.
-  for (uint32_t i = 0; i < streamsReadyToFinish.Length(); ++i) {
-    MediaStream* stream = streamsReadyToFinish[i];
-    if (StreamTimeToGraphTime(stream, stream->GetBufferEnd()) <= mCurrentTime) {
+    if (stream->mFinished && !stream->mNotifiedFinished &&
+        stream->mBufferStartTime + stream->GetBufferEnd() <= nextCurrentTime) {
       stream->mNotifiedFinished = true;
       stream->mLastPlayedVideoFrame.SetNull();
       for (uint32_t j = 0; j < stream->mListeners.Length(); ++j) {
         MediaStreamListener* l = stream->mListeners[j];
         l->NotifyFinished(this);
       }
     }
+
+    LOG(PR_LOG_DEBUG+1, ("MediaStream %p bufferStartTime=%f blockedTime=%f",
+                         stream, MediaTimeToSeconds(stream->mBufferStartTime),
+                         MediaTimeToSeconds(blockedTime)));
   }
+
+  mCurrentTime = nextCurrentTime;
 }
 
 bool
 MediaStreamGraphImpl::WillUnderrun(MediaStream* aStream, GraphTime aTime,
                                    GraphTime aEndBlockingDecisions, GraphTime* aEnd)
 {
   // Finished streams can't underrun. ProcessedMediaStreams also can't cause
   // underrun currently, since we'll always be able to produce data for them