Bug 1292917 - Ended tracks should still keep the AudioCaptureStream going. r=padenot
authorAndreas Pehrson <pehrsons@gmail.com>
Wed, 02 Nov 2016 16:15:56 +0100
changeset 321661 c6b2839bcfa84d2937b69f4a4f53f638a66550af
parent 321660 c78bef5d7961a10ed0333aaf0b045a5bcd0697b9
child 321662 53049dd09053d96543932c00a2bdcee7bc3118b7
push id21
push usermaklebus@msu.edu
push dateThu, 01 Dec 2016 06:22:08 +0000
reviewerspadenot
bugs1292917
milestone52.0a1
Bug 1292917 - Ended tracks should still keep the AudioCaptureStream going. r=padenot MozReview-Commit-ID: GRvJ33EU2yY
dom/media/AudioCaptureStream.cpp
--- a/dom/media/AudioCaptureStream.cpp
+++ b/dom/media/AudioCaptureStream.cpp
@@ -97,32 +97,36 @@ AudioCaptureStream::ProcessInput(GraphTi
     track->Get<AudioSegment>()->AppendNullData(aTo - aFrom);
   } else {
     // We mix down all the tracks of all inputs, to a stereo track. Everything
     // is {up,down}-mixed to stereo.
     mMixer.StartMixing();
     AudioSegment output;
     for (uint32_t i = 0; i < inputCount; i++) {
       MediaStream* s = mInputs[i]->GetSource();
-      for (StreamTracks::TrackIter track(s->GetStreamTracks(),
-                                         MediaSegment::AUDIO);
-           !track.IsEnded(); track.Next()) {
+      StreamTracks::TrackIter track(s->GetStreamTracks(), MediaSegment::AUDIO);
+      if (track.IsEnded()) {
+        // No tracks for this input. Still we append data to trigger the mixer.
+        AudioSegment toMix;
+        toMix.AppendNullData(aTo - aFrom);
+        toMix.Mix(mMixer, MONO, Graph()->GraphRate());
+      }
+      for (; !track.IsEnded(); track.Next()) {
         AudioSegment* inputSegment = track->Get<AudioSegment>();
         StreamTime inputStart = s->GraphTimeToStreamTimeWithBlocking(aFrom);
         StreamTime inputEnd = s->GraphTimeToStreamTimeWithBlocking(aTo);
-        if (track->IsEnded() && inputSegment->GetDuration() <= inputEnd) {
-          // If the input track has ended and we have consumed all its data it
-          // can be ignored.
-          continue;
-        }
         AudioSegment toMix;
-        toMix.AppendSlice(*inputSegment, inputStart, inputEnd);
-        // Care for streams blocked in the [aTo, aFrom] range.
-        if (inputEnd - inputStart < aTo - aFrom) {
-          toMix.AppendNullData((aTo - aFrom) - (inputEnd - inputStart));
+        if (track->IsEnded() && inputSegment->GetDuration() <= inputStart) {
+          toMix.AppendNullData(aTo - aFrom);
+        } else {
+          toMix.AppendSlice(*inputSegment, inputStart, inputEnd);
+          // Care for streams blocked in the [aTo, aFrom] range.
+          if (inputEnd - inputStart < aTo - aFrom) {
+            toMix.AppendNullData((aTo - aFrom) - (inputEnd - inputStart));
+          }
         }
         toMix.Mix(mMixer, MONO, Graph()->GraphRate());
       }
     }
     // This calls MixerCallback below
     mMixer.FinishMixing();
   }