Diff
Modified: trunk/Source/WebCore/ChangeLog (106422 => 106423)
--- trunk/Source/WebCore/ChangeLog 2012-02-01 03:21:24 UTC (rev 106422)
+++ trunk/Source/WebCore/ChangeLog 2012-02-01 03:23:12 UTC (rev 106423)
@@ -1,3 +1,27 @@
+2012-01-31 Raymond Liu <[email protected]>
+
+ Dynamic allocate AudioBus with required number of channels for AudioNodeInput
+ https://bugs.webkit.org/show_bug.cgi?id=76516
+
+ Reviewed by Kenneth Russell.
+
+ No new tests required.
+
+ * webaudio/AudioBasicProcessorNode.cpp:
+ (WebCore::AudioBasicProcessorNode::checkNumberOfChannelsForInput):
+ * webaudio/AudioChannelMerger.cpp:
+ (WebCore::AudioChannelMerger::checkNumberOfChannelsForInput):
+ * webaudio/AudioGainNode.cpp:
+ (WebCore::AudioGainNode::checkNumberOfChannelsForInput):
+ * webaudio/AudioNode.cpp:
+ (WebCore::AudioNode::checkNumberOfChannelsForInput):
+ * webaudio/AudioNode.h:
+ * webaudio/AudioNodeInput.cpp:
+ (WebCore::AudioNodeInput::AudioNodeInput):
+ (WebCore::AudioNodeInput::updateInternalBus):
+ (WebCore::AudioNodeInput::internalSummingBus):
+ * webaudio/AudioNodeInput.h:
+
2012-01-31 Alexey Proskuryakov <[email protected]>
REGRESSION (WebKit2): event.keyCode is always zero when typing in Russian
Modified: trunk/Source/WebCore/webaudio/AudioBasicProcessorNode.cpp (106422 => 106423)
--- trunk/Source/WebCore/webaudio/AudioBasicProcessorNode.cpp 2012-02-01 03:21:24 UTC (rev 106422)
+++ trunk/Source/WebCore/webaudio/AudioBasicProcessorNode.cpp 2012-02-01 03:23:12 UTC (rev 106423)
@@ -127,6 +127,8 @@
processor()->setNumberOfChannels(numberOfChannels);
initialize();
}
+
+ AudioNode::checkNumberOfChannelsForInput(input);
}
unsigned AudioBasicProcessorNode::numberOfChannels()
Modified: trunk/Source/WebCore/webaudio/AudioChannelMerger.cpp (106422 => 106423)
--- trunk/Source/WebCore/webaudio/AudioChannelMerger.cpp 2012-02-01 03:21:24 UTC (rev 106422)
+++ trunk/Source/WebCore/webaudio/AudioChannelMerger.cpp 2012-02-01 03:23:12 UTC (rev 106423)
@@ -89,7 +89,7 @@
// Any time a connection or disconnection happens on any of our inputs, we potentially need to change the
// number of channels of our output.
-void AudioChannelMerger::checkNumberOfChannelsForInput(AudioNodeInput*)
+void AudioChannelMerger::checkNumberOfChannelsForInput(AudioNodeInput* input)
{
ASSERT(context()->isAudioThread() && context()->isGraphOwner());
@@ -105,6 +105,8 @@
AudioNodeOutput* output = this->output(0);
ASSERT(output);
output->setNumberOfChannels(numberOfOutputChannels);
+
+ AudioNode::checkNumberOfChannelsForInput(input);
}
} // namespace WebCore
Modified: trunk/Source/WebCore/webaudio/AudioGainNode.cpp (106422 => 106423)
--- trunk/Source/WebCore/webaudio/AudioGainNode.cpp 2012-02-01 03:21:24 UTC (rev 106422)
+++ trunk/Source/WebCore/webaudio/AudioGainNode.cpp 2012-02-01 03:23:12 UTC (rev 106423)
@@ -110,6 +110,8 @@
output(0)->setNumberOfChannels(numberOfChannels);
initialize();
}
+
+ AudioNode::checkNumberOfChannelsForInput(input);
}
} // namespace WebCore
Modified: trunk/Source/WebCore/webaudio/AudioNode.cpp (106422 => 106423)
--- trunk/Source/WebCore/webaudio/AudioNode.cpp 2012-02-01 03:21:24 UTC (rev 106422)
+++ trunk/Source/WebCore/webaudio/AudioNode.cpp 2012-02-01 03:23:12 UTC (rev 106423)
@@ -182,6 +182,17 @@
}
}
+void AudioNode::checkNumberOfChannelsForInput(AudioNodeInput* input)
+{
+ ASSERT(context()->isAudioThread() && context()->isGraphOwner());
+
+ ASSERT(m_inputs.contains(input));
+ if (!m_inputs.contains(input))
+ return;
+
+ input->updateInternalBus();
+}
+
void AudioNode::pullInputs(size_t framesToProcess)
{
ASSERT(context()->isAudioThread());
Modified: trunk/Source/WebCore/webaudio/AudioNode.h (106422 => 106423)
--- trunk/Source/WebCore/webaudio/AudioNode.h 2012-02-01 03:21:24 UTC (rev 106422)
+++ trunk/Source/WebCore/webaudio/AudioNode.h 2012-02-01 03:23:12 UTC (rev 106423)
@@ -129,7 +129,7 @@
// Called when a new connection has been made to one of our inputs or the connection number of channels has changed.
// This potentially gives us enough information to perform a lazy initialization or, if necessary, a re-initialization.
// Called from main thread.
- virtual void checkNumberOfChannelsForInput(AudioNodeInput*) { }
+ virtual void checkNumberOfChannelsForInput(AudioNodeInput*);
#if DEBUG_AUDIONODE_REFERENCES
static void printNodeCounts();
Modified: trunk/Source/WebCore/webaudio/AudioNodeInput.cpp (106422 => 106423)
--- trunk/Source/WebCore/webaudio/AudioNodeInput.cpp 2012-02-01 03:21:24 UTC (rev 106422)
+++ trunk/Source/WebCore/webaudio/AudioNodeInput.cpp 2012-02-01 03:23:12 UTC (rev 106423)
@@ -41,8 +41,8 @@
: m_node(node)
, m_renderingStateNeedUpdating(false)
{
- m_monoSummingBus = adoptPtr(new AudioBus(1, AudioNode::ProcessingSizeInFrames));
- m_stereoSummingBus = adoptPtr(new AudioBus(2, AudioNode::ProcessingSizeInFrames));
+ // Set to mono by default.
+ m_internalSummingBus = adoptPtr(new AudioBus(1, AudioNode::ProcessingSizeInFrames));
}
void AudioNodeInput::connect(AudioNodeOutput* output)
@@ -159,6 +159,18 @@
}
}
+void AudioNodeInput::updateInternalBus()
+{
+ ASSERT(context()->isAudioThread() && context()->isGraphOwner());
+
+ unsigned numberOfInputChannels = numberOfChannels();
+
+ if (numberOfInputChannels == m_internalSummingBus->numberOfChannels())
+ return;
+
+ m_internalSummingBus = adoptPtr(new AudioBus(numberOfInputChannels, AudioNode::ProcessingSizeInFrames));
+}
+
unsigned AudioNodeInput::numberOfChannels() const
{
// Find the number of channels of the connection with the largest number of channels.
@@ -201,17 +213,9 @@
{
ASSERT(context()->isAudioThread());
- // We must pick a summing bus which is the right size to handle the largest connection.
- switch (numberOfRenderingChannels()) {
- case 1:
- return m_monoSummingBus.get();
- case 2:
- return m_stereoSummingBus.get();
- // FIXME: could implement more than just mono and stereo mixing in the future
- }
-
- ASSERT_NOT_REACHED();
- return 0;
+ ASSERT(numberOfRenderingChannels() == m_internalSummingBus->numberOfChannels());
+
+ return m_internalSummingBus.get();
}
void AudioNodeInput::sumAllConnections(AudioBus* summingBus, size_t framesToProcess)
Modified: trunk/Source/WebCore/webaudio/AudioNodeInput.h (106422 => 106423)
--- trunk/Source/WebCore/webaudio/AudioNodeInput.h 2012-02-01 03:21:24 UTC (rev 106422)
+++ trunk/Source/WebCore/webaudio/AudioNodeInput.h 2012-02-01 03:23:12 UTC (rev 106423)
@@ -72,6 +72,10 @@
// This must be called when we own the context's graph lock in the audio thread at the very start or end of the render quantum.
void updateRenderingState();
+ // updateInternalBus() updates m_internalSummingBus appropriately for the number of channels.
+ // This must be called when we own the context's graph lock in the audio thread at the very start or end of the render quantum.
+ void updateInternalBus();
+
// Rendering code accesses its version of the current connections here.
unsigned numberOfRenderingConnections() const { return m_renderingOutputs.size(); }
AudioNodeOutput* renderingOutput(unsigned i) { return m_renderingOutputs[i]; }
@@ -116,8 +120,7 @@
AudioBus* internalSummingBus();
void sumAllConnections(AudioBus* summingBus, size_t framesToProcess);
- OwnPtr<AudioBus> m_monoSummingBus;
- OwnPtr<AudioBus> m_stereoSummingBus;
+ OwnPtr<AudioBus> m_internalSummingBus;
};
} // namespace WebCore