bug 1207003 only create track for external AudioNodeStreams r=padenot
authorKarl Tomlinson <karlt+@karlt.net>
Fri, 18 Sep 2015 17:07:40 +1200
changeset 263986 15e7ac19b26ed6bdb5813479b914897e6c0ec82b
parent 263985 63b1064ba50057c5ed2d3d80a2458ba2b947e281
child 263987 88067e5193f024cddba80453677ca209d10a15fe
push id29423
push userkwierso@gmail.com
push dateWed, 23 Sep 2015 20:13:47 +0000
treeherdermozilla-central@bcbfa80a0dc7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1207003
milestone44.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 1207003 only create track for external AudioNodeStreams r=padenot IsFinishedOnGraphThread() was unnecessary due to the !mFinished test.
dom/media/webaudio/AudioNodeExternalInputStream.cpp
dom/media/webaudio/AudioNodeStream.cpp
--- a/dom/media/webaudio/AudioNodeExternalInputStream.cpp
+++ b/dom/media/webaudio/AudioNodeExternalInputStream.cpp
@@ -126,17 +126,16 @@ AudioNodeExternalInputStream::ProcessInp
 {
   // According to spec, number of outputs is always 1.
   MOZ_ASSERT(mLastChunks.Length() == 1);
 
   // GC stuff can result in our input stream being destroyed before this stream.
   // Handle that.
   if (!IsEnabled() || mInputs.IsEmpty() || mPassThrough) {
     mLastChunks[0].SetNull(WEBAUDIO_BLOCK_SIZE);
-    AdvanceOutputSegment();
     return;
   }
 
   MOZ_ASSERT(mInputs.Length() == 1);
 
   MediaStream* source = mInputs[0]->GetSource();
   nsAutoTArray<AudioSegment,1> audioSegments;
   uint32_t inputChannels = 0;
@@ -200,19 +199,16 @@ AudioNodeExternalInputStream::ProcessInp
         AccumulateInputChunk(accumulateIndex, tmpChunk, &mLastChunks[0], &downmixBuffer);
         accumulateIndex++;
       }
     }
   }
   if (accumulateIndex == 0) {
     mLastChunks[0].SetNull(WEBAUDIO_BLOCK_SIZE);
   }
-
-  // Using AudioNodeStream's AdvanceOutputSegment to push the media stream graph along with null data.
-  AdvanceOutputSegment();
 }
 
 bool
 AudioNodeExternalInputStream::IsEnabled()
 {
   return ((MediaStreamAudioSourceNodeEngine*)Engine())->IsEnabled();
 }
 
--- a/dom/media/webaudio/AudioNodeStream.cpp
+++ b/dom/media/webaudio/AudioNodeStream.cpp
@@ -560,22 +560,27 @@ AudioNodeStream::ProcessInput(GraphTime 
       for (uint32_t i = 0; i < outputCount; ++i) {
         mLastChunks[i].SetNull(WEBAUDIO_BLOCK_SIZE);
       }
     }
   }
 
   if (!mFinished) {
     // Don't output anything while finished
-    AdvanceOutputSegment();
+    if (mFlags & EXTERNAL_OUTPUT) {
+      AdvanceOutputSegment();
+    }
     if (mMarkAsFinishedAfterThisBlock && (aFlags & ALLOW_FINISH)) {
       // This stream was finished the last time that we looked at it, and all
       // of the depending streams have finished their output as well, so now
       // it's time to mark this stream as finished.
-      FinishOutput();
+      if (mFlags & EXTERNAL_OUTPUT) {
+        FinishOutput();
+      }
+      FinishOnGraphThread();
     }
   }
 }
 
 void
 AudioNodeStream::ProduceOutputBeforeInput(GraphTime aFrom)
 {
   MOZ_ASSERT(mEngine->AsDelayNodeEngine());
@@ -600,17 +605,17 @@ void
 AudioNodeStream::AdvanceOutputSegment()
 {
   StreamBuffer::Track* track = EnsureTrack(AUDIO_TRACK);
   // No more tracks will be coming
   mBuffer.AdvanceKnownTracksTime(STREAM_TIME_MAX);
 
   AudioSegment* segment = track->Get<AudioSegment>();
 
-  if (mFlags & EXTERNAL_OUTPUT && !mLastChunks[0].IsNull()) {
+  if (!mLastChunks[0].IsNull()) {
     segment->AppendAndConsumeChunk(mLastChunks[0].AsMutableChunk());
   } else {
     segment->AppendNullData(mLastChunks[0].GetDuration());
   }
 
   for (uint32_t j = 0; j < mListeners.Length(); ++j) {
     MediaStreamListener* l = mListeners[j];
     AudioChunk copyChunk = mLastChunks[0].AsAudioChunk();
@@ -619,23 +624,18 @@ AudioNodeStream::AdvanceOutputSegment()
     l->NotifyQueuedTrackChanges(Graph(), AUDIO_TRACK,
                                 segment->GetDuration(), 0, tmpSegment);
   }
 }
 
 void
 AudioNodeStream::FinishOutput()
 {
-  if (IsFinishedOnGraphThread()) {
-    return;
-  }
-
   StreamBuffer::Track* track = EnsureTrack(AUDIO_TRACK);
   track->SetEnded();
-  FinishOnGraphThread();
 
   for (uint32_t j = 0; j < mListeners.Length(); ++j) {
     MediaStreamListener* l = mListeners[j];
     AudioSegment emptySegment;
     l->NotifyQueuedTrackChanges(Graph(), AUDIO_TRACK,
                                 track->GetSegment()->GetDuration(),
                                 MediaStreamListener::TRACK_EVENT_ENDED, emptySegment);
   }