Bug 1060311 - Force the use of an AudioCallbackDriver when at least an AudioNodeStream is present in the graph. r=jesup
authorPaul Adenot <paul@paul.cx>
Fri, 29 Aug 2014 20:26:29 +0200
changeset 202744 8fbff7a0882006bd189243cb97bf1f782e4dec5e
parent 202743 dc3942a35b5c8c48c726df578e2fff36f7ff5157
child 202745 bec4694a3c6ff6f766f3e6fb7d037bf57774833f
push id48470
push userpaul@paul.cx
push dateSun, 31 Aug 2014 11:14:06 +0000
treeherdermozilla-inbound@8fbff7a08820 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup
bugs1060311
milestone34.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 1060311 - Force the use of an AudioCallbackDriver when at least an AudioNodeStream is present in the graph. r=jesup This prevent a bug where the graph would be using a SystemClockDriver even if it was rendering Web Audio API content. It went like this: - An AudioContext was created. - Some AudioNodeStream (Web Audio API MediaStreams) were created, but their MediaStreamTrack was not added yet - During the stream ordering, we would see that we were running an AudioCallbackDriver (because the MSG was created using an AudioContext, and we pass in hints regarding the type of MediaStreams that will be added in the future, to open the audio stream as early as we can, because it can take some time, the MSG was created directly using an AudioCallbackDriver) - Also during the stream ordering, we see that none of our MediaStream have an MediaStreamTrack with an audio track. This triggers a switch to a SystemClockDriver, because the graph thinks there is no audio. - During CreateAndDestroyAudioNode, we would not switch to an AudioCallbackDriver on the first iteration (right after the UpdateStreamOrder call), because we would be switching, and not during the iteration after, because we thought we already switched (the first patch makes this more robust). This basically forces an AudioCallbackDriver if there is an AudioNodeStream, which prevents unnecessary GraphDriver switches (and save threads creation destruction, audio stream create and destruction, and all other resources associated with a GraphDriver).
content/media/MediaStreamGraph.cpp
--- a/content/media/MediaStreamGraph.cpp
+++ b/content/media/MediaStreamGraph.cpp
@@ -503,16 +503,20 @@ MediaStreamGraphImpl::UpdateStreamOrder(
   for (uint32_t i = 0; i < mStreams.Length(); ++i) {
     MediaStream* stream = mStreams[i];
     stream->mIsConsumed = false;
     stream->mInBlockingSet = false;
     if (stream->AsSourceStream() &&
         stream->AsSourceStream()->NeedsMixing()) {
       shouldAEC = true;
     }
+    // If this is a AudioNodeStream, force a AudioCallbackDriver.
+    if (stream->AsAudioNodeStream()) {
+      audioTrackPresent = true;
+    }
     for (StreamBuffer::TrackIter tracks(stream->GetStreamBuffer(), MediaSegment::AUDIO);
          !tracks.IsEnded(); tracks.Next()) {
       audioTrackPresent = true;
     }
   }
 
   if (!audioTrackPresent &&
       CurrentDriver()->AsAudioCallbackDriver()) {