Bug 816664. Don't call NotifyPull if we already have all the data buffered in the stream that we need. r=jesup
authorRobert O'Callahan <robert@ocallahan.org>
Sat, 08 Dec 2012 00:06:55 +1300
changeset 115341 be0058cf546a325f751a27d67cedf608360b07fc
parent 115340 55d5f3cd5c8514837024d5bc57ebc197429ff89c
child 115342 bd48592613470c231eae5b34591c441806ab5050
push id24003
push usereakhgari@mozilla.com
push dateSun, 09 Dec 2012 18:17:18 +0000
treeherdermozilla-central@725eb8792d27 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup
bugs816664
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 816664. Don't call NotifyPull if we already have all the data buffered in the stream that we need. r=jesup
content/media/MediaStreamGraph.cpp
--- a/content/media/MediaStreamGraph.cpp
+++ b/content/media/MediaStreamGraph.cpp
@@ -582,29 +582,32 @@ MediaStreamGraphImpl::UpdateConsumptionS
 void
 MediaStreamGraphImpl::ExtractPendingInput(SourceMediaStream* aStream,
                                           GraphTime aDesiredUpToTime,
                                           bool* aEnsureNextIteration)
 {
   bool finished;
   {
     MutexAutoLock lock(aStream->mMutex);
-    if (aStream->mPullEnabled && !aStream->mFinished) {
-      for (uint32_t j = 0; j < aStream->mListeners.Length(); ++j) {
-        MediaStreamListener* l = aStream->mListeners[j];
-        {
-          // Compute how much stream time we'll need assuming we don't block
-          // the stream at all between mBlockingDecisionsMadeUntilTime and
-          // aDesiredUpToTime.
-          StreamTime t =
-            GraphTimeToStreamTime(aStream, mStateComputedTime) +
-            (aDesiredUpToTime - mStateComputedTime);
-          MutexAutoUnlock unlock(aStream->mMutex);
-          l->NotifyPull(this, t);
-          *aEnsureNextIteration = true;
+    if (aStream->mPullEnabled && !aStream->mFinished &&
+        !aStream->mListeners.IsEmpty()) {
+      // Compute how much stream time we'll need assuming we don't block
+      // the stream at all between mBlockingDecisionsMadeUntilTime and
+      // aDesiredUpToTime.
+      StreamTime t =
+        GraphTimeToStreamTime(aStream, mStateComputedTime) +
+        (aDesiredUpToTime - mStateComputedTime);
+      if (t > aStream->mBuffer.GetEnd()) {
+        *aEnsureNextIteration = true;
+        for (uint32_t j = 0; j < aStream->mListeners.Length(); ++j) {
+          MediaStreamListener* l = aStream->mListeners[j];
+          {
+            MutexAutoUnlock unlock(aStream->mMutex);
+            l->NotifyPull(this, t);
+          }
         }
       }
     }
     finished = aStream->mUpdateFinished;
     for (int32_t i = aStream->mUpdateTracks.Length() - 1; i >= 0; --i) {
       SourceMediaStream::TrackData* data = &aStream->mUpdateTracks[i];
       for (uint32_t j = 0; j < aStream->mListeners.Length(); ++j) {
         MediaStreamListener* l = aStream->mListeners[j];