See bug 980506 for an extensive discussion about this. This patch adds
three APIs to AudioNode in order for us to be able to build awesome
devtools on top of it.
* Weak reference API.
This patch allows one to hold a weak reference to all AudioNode's
using Components.utils.getWeakReference(). That way, the devtool's
inspection code would not change the lifetime of AudioNodes.
* AudioNode.id
This is a chrome-only unique and monotonically incrementing ID for
AudioNode objects. It is supposed to be used in order for the
devtools to be able to identify a node without having to keep it
alive.
* webaudio-node-demise
This is an observer notification that is called every time an
AudioNode gets destroyed inside Gecko. The ID of the corresponding
node is passed to this notification.
--HG--
extra : rebase_source : 83246a990489daf44ddc97dd4ea372a8cebe8e00
See bug 980506 for an extensive discussion about this. This patch adds
three APIs to AudioNode in order for us to be able to build awesome
devtools on top of it.
* Weak reference API.
This patch allows one to hold a weak reference to all AudioNode's
using Components.utils.getWeakReference(). That way, the devtool's
inspection code would not change the lifetime of AudioNodes.
* AudioNode.id
This is a chrome-only unique and monotonically incrementing ID for
AudioNode objects. It is supposed to be used in order for the
devtools to be able to identify a node without having to keep it
alive.
* webaudio-node-demise
This is an observer notification that is called every time an
AudioNode gets destroyed inside Gecko. The ID of the corresponding
node is passed to this notification.
These MediaStreams are used as a way to down-mix the input AudioChunks, and
also as a way to get proper stream processing ordering. The MediaStream for
the source AudioNode is an input to these streams, and these streams in turn
are inputs to the MediaStream that the AudioNode that owns the AudioParam owns.
This way, the Media Streams Graph processing code will order the streams so
that by the time that the MediaStream for a given node is processed, all of the
MediaStreams belonging to the AudioNode(s) feeding into the AudioParam have
been processed.
This has a tricky side-effect that those streams also being considered when
determining the input block for the AudioNodeStream belonging to the
AudioParam's owner AudioNode. In order to fix that, we simply special case
those streams and make AudioNodeStream::ObtainInputBlock ignore them.
Here is what this patch does:
* Got rid of the JSBindingFinalized stuff
* Made all nodes wrappercached
* Started to hold a self reference while the AudioBufferSourceNode is playing back
* Converted the input references to weak references
* Got rid of all of the SetProduceOwnOutput and UpdateOutputEnded logic
The nodes are now collected by the cycle collector which calls into
DisconnectFromGraph which drops the references to other nodes and destroys the
media stream. Note that most of the cycles that are now inherent in the
ownership model are between nodes and their AudioParams (that is, the cycles
not created by content.)
This is a mega-patch that was too hard to disentangle. Here's what it does:
-- Create infrastructure around AudioNode::UpdateOutputEnded to detect
when a node can no longer produce any output. When that becomes true,
disconnect it from the AudioNode graph.
-- Have AudioNode implement JSBindingFinalized to use as input in
UpdateOutputEnded.
-- Give every AudioNode a MediaStream, and give every connection
a MediaInputPort.
-- Actually play the audio that reaches the AudioContext's destination node.
-- Force AudioContext to use the audio sample rate defined by MediaStreamGraph.
-- Fix AudioBufferSourceNode's start and stop methods to possibly throw and
take default 'when' parameters.
-- Create an AudioNodeStream for AudioBufferSourceNode and give it a
AudioBufferSourceNodeEngine that does what's needed. Set parameters for
this engine in the start() and stop() methods.
-- Create AudioBuffer::GetThreadSharedChannelsForRate, which is responsible
for stealing the contents of any JS array buffers, and bundling them up
into a thread-shared read-only buffer object which can be used as
part of an AudioChunk. This method will also be responsible for
resampling and caching as necessary.
--HG--
rename : content/media/MediaStreamGraph.cpp => content/media/MediaStreamGraphImpl.h
extra : rebase_source : 9fa0ec0efa304acd6513e427103d6339c78efa53