Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1725)

Unified Diff: Source/modules/webaudio/AudioNodeInput.cpp

Issue 386343004: WebAudio: Use references instead of pointers in AudioNodeInput and AudioNodeOutput. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/webaudio/AudioNodeInput.h ('k') | Source/modules/webaudio/AudioNodeOutput.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/webaudio/AudioNodeInput.cpp
diff --git a/Source/modules/webaudio/AudioNodeInput.cpp b/Source/modules/webaudio/AudioNodeInput.cpp
index bb157c7c74c70cc1a0022d80bd5c5def17776896..b8fd053d3cc352713943d7a3d67443f4fefd0418 100644
--- a/Source/modules/webaudio/AudioNodeInput.cpp
+++ b/Source/modules/webaudio/AudioNodeInput.cpp
@@ -34,58 +34,50 @@
namespace WebCore {
-inline AudioNodeInput::AudioNodeInput(AudioNode* node)
- : AudioSummingJunction(node->context())
+inline AudioNodeInput::AudioNodeInput(AudioNode& node)
+ : AudioSummingJunction(node.context())
, m_node(node)
{
// Set to mono by default.
m_internalSummingBus = AudioBus::create(1, AudioNode::ProcessingSizeInFrames);
}
-PassOwnPtr<AudioNodeInput> AudioNodeInput::create(AudioNode* node)
+PassOwnPtr<AudioNodeInput> AudioNodeInput::create(AudioNode& node)
{
return adoptPtr(new AudioNodeInput(node));
}
-void AudioNodeInput::connect(AudioNodeOutput* output)
+void AudioNodeInput::connect(AudioNodeOutput& output)
{
ASSERT(context()->isGraphOwner());
- ASSERT(output && node());
- if (!output || !node())
- return;
-
// Check if we're already connected to this output.
- if (m_outputs.contains(output))
+ if (m_outputs.contains(&output))
return;
- output->addInput(this);
- m_outputs.add(output);
+ output.addInput(*this);
+ m_outputs.add(&output);
changedOutputs();
}
-void AudioNodeInput::disconnect(AudioNodeOutput* output)
+void AudioNodeInput::disconnect(AudioNodeOutput& output)
{
ASSERT(context()->isGraphOwner());
- ASSERT(output && node());
- if (!output || !node())
- return;
-
// First try to disconnect from "active" connections.
- if (m_outputs.contains(output)) {
- m_outputs.remove(output);
+ if (m_outputs.contains(&output)) {
+ m_outputs.remove(&output);
changedOutputs();
- output->removeInput(this);
+ output.removeInput(*this);
// Note: it's important to return immediately after removeInput() calls
// since the node may be deleted.
return;
}
// Otherwise, try to disconnect from disabled connections.
- if (m_disabledOutputs.contains(output)) {
- m_disabledOutputs.remove(output);
- output->removeInput(this);
+ if (m_disabledOutputs.contains(&output)) {
+ m_disabledOutputs.remove(&output);
+ output.removeInput(*this);
// Note: it's important to return immediately after all removeInput() calls
// since the node may be deleted.
return;
@@ -94,46 +86,36 @@ void AudioNodeInput::disconnect(AudioNodeOutput* output)
ASSERT_NOT_REACHED();
}
-void AudioNodeInput::disable(AudioNodeOutput* output)
+void AudioNodeInput::disable(AudioNodeOutput& output)
{
ASSERT(context()->isGraphOwner());
+ ASSERT(m_outputs.contains(&output));
- ASSERT(output && node());
- if (!output || !node())
- return;
-
- ASSERT(m_outputs.contains(output));
-
- m_disabledOutputs.add(output);
- m_outputs.remove(output);
+ m_disabledOutputs.add(&output);
+ m_outputs.remove(&output);
changedOutputs();
// Propagate disabled state to outputs.
- node()->disableOutputsIfNecessary();
+ node().disableOutputsIfNecessary();
}
-void AudioNodeInput::enable(AudioNodeOutput* output)
+void AudioNodeInput::enable(AudioNodeOutput& output)
{
ASSERT(context()->isGraphOwner());
-
- ASSERT(output && node());
- if (!output || !node())
- return;
-
- ASSERT(m_disabledOutputs.contains(output));
+ ASSERT(m_disabledOutputs.contains(&output));
// Move output from disabled list to active list.
- m_outputs.add(output);
- m_disabledOutputs.remove(output);
+ m_outputs.add(&output);
+ m_disabledOutputs.remove(&output);
changedOutputs();
// Propagate enabled state to outputs.
- node()->enableOutputsIfNecessary();
+ node().enableOutputsIfNecessary();
}
void AudioNodeInput::didUpdate()
{
- node()->checkNumberOfChannelsForInput(this);
+ node().checkNumberOfChannelsForInput(this);
}
void AudioNodeInput::updateInternalBus()
@@ -150,9 +132,9 @@ void AudioNodeInput::updateInternalBus()
unsigned AudioNodeInput::numberOfChannels() const
{
- AudioNode::ChannelCountMode mode = node()->internalChannelCountMode();
+ AudioNode::ChannelCountMode mode = node().internalChannelCountMode();
if (mode == AudioNode::Explicit)
- return node()->channelCount();
+ return node().channelCount();
// Find the number of channels of the connection with the largest number of channels.
unsigned maxChannels = 1; // one channel is the minimum allowed
@@ -165,7 +147,7 @@ unsigned AudioNodeInput::numberOfChannels() const
}
if (mode == AudioNode::ClampedMax)
- maxChannels = std::min(maxChannels, static_cast<unsigned>(node()->channelCount()));
+ maxChannels = std::min(maxChannels, static_cast<unsigned>(node().channelCount()));
return maxChannels;
}
@@ -175,7 +157,7 @@ AudioBus* AudioNodeInput::bus()
ASSERT(context()->isAudioThread());
// Handle single connection specially to allow for in-place processing.
- if (numberOfRenderingConnections() == 1 && node()->internalChannelCountMode() == AudioNode::Max)
+ if (numberOfRenderingConnections() == 1 && node().internalChannelCountMode() == AudioNode::Max)
return renderingOutput(0)->bus();
// Multiple connections case or complex ChannelCountMode (or no connections).
@@ -194,7 +176,7 @@ void AudioNodeInput::sumAllConnections(AudioBus* summingBus, size_t framesToProc
ASSERT(context()->isAudioThread());
// We shouldn't be calling this method if there's only one connection, since it's less efficient.
- ASSERT(numberOfRenderingConnections() > 1 || node()->internalChannelCountMode() != AudioNode::Max);
+ ASSERT(numberOfRenderingConnections() > 1 || node().internalChannelCountMode() != AudioNode::Max);
ASSERT(summingBus);
if (!summingBus)
@@ -202,7 +184,7 @@ void AudioNodeInput::sumAllConnections(AudioBus* summingBus, size_t framesToProc
summingBus->zero();
- AudioBus::ChannelInterpretation interpretation = node()->internalChannelInterpretation();
+ AudioBus::ChannelInterpretation interpretation = node().internalChannelInterpretation();
for (unsigned i = 0; i < numberOfRenderingConnections(); ++i) {
AudioNodeOutput* output = renderingOutput(i);
@@ -221,7 +203,7 @@ AudioBus* AudioNodeInput::pull(AudioBus* inPlaceBus, size_t framesToProcess)
ASSERT(context()->isAudioThread());
// Handle single connection case.
- if (numberOfRenderingConnections() == 1 && node()->internalChannelCountMode() == AudioNode::Max) {
+ if (numberOfRenderingConnections() == 1 && node().internalChannelCountMode() == AudioNode::Max) {
// The output will optimize processing using inPlaceBus if it's able.
AudioNodeOutput* output = this->renderingOutput(0);
return output->pull(inPlaceBus, framesToProcess);
« no previous file with comments | « Source/modules/webaudio/AudioNodeInput.h ('k') | Source/modules/webaudio/AudioNodeOutput.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698