Bug 1292917 - Ended tracks should still keep the AudioCaptureStream going. r?padenot draft
authorAndreas Pehrson <pehrsons@gmail.com>
Wed, 02 Nov 2016 16:15:56 +0100
changeset 433273 9c340950703092299ce00977e076450d99321c42
parent 433272 0c44ad902fea625744bada2648b118f91984c96d
child 535842 22977af415e7a87c580cc144d27acfa68ecf0358
push id34525
push userbmo:pehrson@telenordigital.com
push dateThu, 03 Nov 2016 10:23:18 +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();
   }