Bug 1292917 - Ended tracks should still keep the AudioCaptureStream going. r?padenot
MozReview-Commit-ID: GRvJ33EU2yY
--- 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();
}