Bug 881959 - Handle self-connection. r=ehsan, a=akeybl
authorPaul Adenot <paul@paul.cx>
Mon, 16 Sep 2013 17:37:27 +0200
changeset 154106 29d6ea0f191aaba853599b90e06bd5f3f022cefb
parent 154105 f9164302e0c30a6c307843dac51b4913a64da8d3
child 154107 b09d09f596110eb15163f22dbcc5ed48b87085be
push id1
push usersledru@mozilla.com
push dateThu, 04 Dec 2014 17:57:20 +0000
reviewersehsan, akeybl
bugs881959
milestone25.0
Bug 881959 - Handle self-connection. r=ehsan, a=akeybl
content/media/MediaStreamGraph.cpp
--- a/content/media/MediaStreamGraph.cpp
+++ b/content/media/MediaStreamGraph.cpp
@@ -485,25 +485,32 @@ MediaStreamGraphImpl::UpdateStreamOrderF
         if (ns && ns->Engine()->AsDelayNodeEngine()) {
           delayNodePresent = true;
         }
         iter = iter->getPrevious();
       } while (iter && iter != stream);
     }
     if (cycleFound && !delayNodePresent) {
       // If we have detected a cycle, the previous loop should exit with stream
-      // == iter. Go back in the cycle and mute all nodes we find.
-      MOZ_ASSERT(iter);
-      do {
-        // There can't be non-AudioNodeStream here, MediaStreamAudio{Source,
-        // Destination}Node are connected to regular MediaStreams, but they can't be
-        // in a cycle (there is no content API to do so).
-        MOZ_ASSERT(iter->AsAudioNodeStream());
+      // == iter, or the node is connected to itself. Go back in the cycle and
+      // mute all nodes we find, or just mute the node itself.
+      if (!iter) {
+        // The node is connected to itself.
+        iter = aStack->getLast();
         iter->AsAudioNodeStream()->Mute();
-      } while((iter = iter->getNext()));
+      } else {
+        MOZ_ASSERT(iter);
+        do {
+          // There can't be non-AudioNodeStream here, MediaStreamAudio{Source,
+          // Destination}Node are connected to regular MediaStreams, but they can't be
+          // in a cycle (there is no content API to do so).
+          MOZ_ASSERT(iter->AsAudioNodeStream());
+          iter->AsAudioNodeStream()->Mute();
+        } while((iter = iter->getNext()));
+      }
     }
     return;
   }
   ProcessedMediaStream* ps = stream->AsProcessedStream();
   if (ps) {
     aStack->insertBack(stream);
     stream->mIsOnOrderingStack = true;
     for (uint32_t i = 0; i < ps->mInputs.Length(); ++i) {