Bug 1189506. Fix multi-track MediaStream audio output. r=karlt
authorRobert O'Callahan <robert@ocallahan.org>
Fri, 04 Sep 2015 17:58:26 +1200
changeset 295500 386e8ef862dc75d76c88c043a1cea0f14b22db28
parent 295499 63e927ca87fb0aa80432d11ee90389e9cb2313d4
child 295501 3d1060db7ddb09a37deaab6e7723abe533927d76
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs1189506
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1189506. Fix multi-track MediaStream audio output. r=karlt
dom/media/MediaStreamGraph.cpp
--- a/dom/media/MediaStreamGraph.cpp
+++ b/dom/media/MediaStreamGraph.cpp
@@ -810,34 +810,33 @@ MediaStreamGraphImpl::CreateOrDestroyAud
 }
 
 StreamTime
 MediaStreamGraphImpl::PlayAudio(MediaStream* aStream,
                                 GraphTime aFrom, GraphTime aTo)
 {
   MOZ_ASSERT(mRealtime, "Should only attempt to play audio in realtime mode");
 
-  StreamTime ticksWritten = 0;
-  // We compute the number of needed ticks by converting a difference of graph
-  // time rather than by substracting two converted stream time to ensure that
-  // the rounding between {Graph,Stream}Time and track ticks is not dependant
-  // on the absolute value of the {Graph,Stream}Time, and so that number of
-  // ticks to play is the same for each cycle.
-  StreamTime ticksNeeded = aTo - aFrom;
-
-  if (aStream->mAudioOutputStreams.IsEmpty()) {
-    return 0;
-  }
-
   float volume = 0.0f;
   for (uint32_t i = 0; i < aStream->mAudioOutputs.Length(); ++i) {
     volume += aStream->mAudioOutputs[i].mVolume;
   }
 
+  StreamTime ticksWritten = 0;
+
   for (uint32_t i = 0; i < aStream->mAudioOutputStreams.Length(); ++i) {
+    ticksWritten = 0;
+
+    // We compute the number of needed ticks by converting a difference of graph
+    // time rather than by subtracting two converted stream times to ensure that
+    // the rounding between {Graph,Stream}Time and track ticks is not dependant
+    // on the absolute value of the {Graph,Stream}Time, and so that number of
+    // ticks to play is the same for each cycle.
+    StreamTime ticksNeeded = aTo - aFrom;
+
     MediaStream::AudioOutputStream& audioOutput = aStream->mAudioOutputStreams[i];
     StreamBuffer::Track* track = aStream->mBuffer.FindTrack(audioOutput.mTrackID);
     AudioSegment* audio = track->Get<AudioSegment>();
     AudioSegment output;
 
     // offset and audioOutput.mLastTickWritten can differ by at most one sample,
     // because of the rounding issue. We track that to ensure we don't skip a
     // sample. One sample may be played twice, but this should not happen