Bug 1298515 - Ignore ended tracks for AudioCaptureStreams. r?padenot draft
authorAndreas Pehrson <pehrsons@gmail.com>
Fri, 02 Sep 2016 17:23:26 +0200
changeset 409803 a7f003acfcbb95ceaa604f98e53264fda7f22585
parent 409229 08cda08ce9d222aaa7831b84af4251788db455ea
child 530416 765dfaaeb4fe3af6498bfc4bc1e993aea7cdca2f
push id28552
push userbmo:pehrson@telenordigital.com
push dateMon, 05 Sep 2016 07:36:09 +0000
reviewerspadenot
bugs1298515
milestone51.0a1
Bug 1298515 - Ignore ended tracks for AudioCaptureStreams. r?padenot MozReview-Commit-ID: BamiTYxTCUw
dom/media/AudioCaptureStream.cpp
--- a/dom/media/AudioCaptureStream.cpp
+++ b/dom/media/AudioCaptureStream.cpp
@@ -102,16 +102,21 @@ AudioCaptureStream::ProcessInput(GraphTi
     AudioSegment output;
     for (uint32_t i = 0; i < inputCount; i++) {
       MediaStream* s = mInputs[i]->GetSource();
       StreamTracks::TrackIter tracks(s->GetStreamTracks(), MediaSegment::AUDIO);
       while (!tracks.IsEnded()) {
         AudioSegment* inputSegment = tracks->Get<AudioSegment>();
         StreamTime inputStart = s->GraphTimeToStreamTimeWithBlocking(aFrom);
         StreamTime inputEnd = s->GraphTimeToStreamTimeWithBlocking(aTo);
+        if (tracks->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));
         }
         toMix.Mix(mMixer, MONO, Graph()->GraphRate());
         tracks.Next();