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).
This commit is contained in:
Paul Adenot 2014-08-29 20:26:29 +02:00
Родитель eee60d5ec4
Коммит 9edc44ff65
1 изменённых файлов: 4 добавлений и 0 удалений

Просмотреть файл

@ -508,6 +508,10 @@ MediaStreamGraphImpl::UpdateStreamOrder()
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;