Changeset 268820 in webkit
- Timestamp:
- Oct 21, 2020, 1:27:52 PM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
-
ChangeLog (modified) (1 diff)
-
Modules/webaudio/AudioNode.cpp (modified) (1 diff)
-
Modules/webaudio/AudioNodeInput.cpp (modified) (5 diffs)
-
Modules/webaudio/AudioParam.cpp (modified) (2 diffs)
-
Modules/webaudio/AudioSummingJunction.cpp (modified) (3 diffs)
-
Modules/webaudio/AudioSummingJunction.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r268819 r268820 1 2020-10-21 Chris Dumez <cdumez@apple.com> 2 3 Add addOutput() / removeOutput() utility functions to AudioSummingJunction 4 https://bugs.webkit.org/show_bug.cgi?id=218045 5 6 Reviewed by Eric Carlson. 7 8 Add addOutput() / removeOutput() utility functions to AudioSummingJunction to add 9 or remove outputs from m_outputs and abstract away the call to changedOutputs(). 10 It was awkward that subclasses were modifying m_outputs directly and had to 11 explicitly call changedOutputs() whenever they did. 12 13 No new tests, no web-facing behavior change. 14 15 * Modules/webaudio/AudioNode.cpp: 16 (WebCore::AudioNode::updateChannelsForInputs): 17 * Modules/webaudio/AudioNodeInput.cpp: 18 (WebCore::AudioNodeInput::connect): 19 (WebCore::AudioNodeInput::disconnect): 20 (WebCore::AudioNodeInput::disable): 21 (WebCore::AudioNodeInput::enable): 22 (WebCore::AudioNodeInput::numberOfChannels const): 23 * Modules/webaudio/AudioParam.cpp: 24 (WebCore::AudioParam::connect): 25 (WebCore::AudioParam::disconnect): 26 * Modules/webaudio/AudioSummingJunction.cpp: 27 (WebCore::AudioSummingJunction::markRenderingStateAsDirty): 28 (WebCore::AudioSummingJunction::addOutput): 29 (WebCore::AudioSummingJunction::removeOutput): 30 (WebCore::AudioSummingJunction::maximumNumberOfChannels const): 31 (WebCore::AudioSummingJunction::changedOutputs): Deleted. 32 * Modules/webaudio/AudioSummingJunction.h: 33 1 34 2020-10-21 Rob Buis <rbuis@igalia.com> 2 35 -
trunk/Source/WebCore/Modules/webaudio/AudioNode.cpp
r268426 r268820 424 424 { 425 425 for (auto& input : m_inputs) 426 input-> changedOutputs();426 input->markRenderingStateAsDirty(); 427 427 } 428 428 -
trunk/Source/WebCore/Modules/webaudio/AudioNodeInput.cpp
r267591 r268820 54 54 return; 55 55 56 auto& outputsMap = output->isEnabled() ? m_outputs : m_disabledOutputs; 57 // Check if we're already connected to this output. 58 if (!outputsMap.add(output).isNewEntry) 59 return; 60 61 output->addInput(this); 62 changedOutputs(); 56 auto addPotentiallyDisabledOutput = [this](AudioNodeOutput& output) { 57 if (output.isEnabled()) 58 return addOutput(output); 59 return m_disabledOutputs.add(&output).isNewEntry; 60 }; 61 62 if (addPotentiallyDisabledOutput(*output)) 63 output->addInput(this); 63 64 } 64 65 … … 72 73 73 74 // First try to disconnect from "active" connections. 74 if (m_outputs.remove(output)) { 75 changedOutputs(); 75 if (removeOutput(*output)) { 76 76 output->removeInput(this); // Note: it's important to return immediately after this since the node may be deleted. 77 77 return; … … 95 95 return; 96 96 97 ASSERT(m_outputs.contains(output));98 99 97 m_disabledOutputs.add(output); 100 m_outputs.remove(output);101 changedOutputs();98 bool wasRemoved = removeOutput(*output); 99 ASSERT_UNUSED(wasRemoved, wasRemoved); 102 100 103 101 // Propagate disabled state to outputs. … … 116 114 117 115 // Move output from disabled list to active list. 118 m_outputs.add(output);116 addOutput(*output); 119 117 m_disabledOutputs.remove(output); 120 changedOutputs();121 118 122 119 // Propagate enabled state to outputs. … … 148 145 149 146 // Find the number of channels of the connection with the largest number of channels. 150 unsigned maxChannels = 1; // one channel is the minimum allowed 151 152 for (auto& output : m_outputs) { 153 // Use output()->numberOfChannels() instead of output->bus()->numberOfChannels(), 154 // because the calling of AudioNodeOutput::bus() is not safe here. 155 maxChannels = std::max(maxChannels, output->numberOfChannels()); 156 } 147 unsigned maxChannels = std::max(maximumNumberOfChannels(), 1u); // One channel is the minimum allowed. 157 148 158 149 if (mode == ChannelCountMode::ClampedMax) -
trunk/Source/WebCore/Modules/webaudio/AudioParam.cpp
r268553 r268820 321 321 return; 322 322 323 if (! m_outputs.add(output).isNewEntry)323 if (!addOutput(*output)) 324 324 return; 325 325 326 326 INFO_LOG(LOGIDENTIFIER, output->node()->nodeType()); 327 328 327 output->addParam(this); 329 changedOutputs();330 328 } 331 329 … … 340 338 INFO_LOG(LOGIDENTIFIER, output->node()->nodeType()); 341 339 342 if (m_outputs.remove(output)) { 343 changedOutputs(); 340 if (removeOutput((*output))) 344 341 output->removeParam(this); 345 }346 342 } 347 343 -
trunk/Source/WebCore/Modules/webaudio/AudioSummingJunction.cpp
r267544 r268820 46 46 } 47 47 48 void AudioSummingJunction:: changedOutputs()48 void AudioSummingJunction::markRenderingStateAsDirty() 49 49 { 50 50 ASSERT(context().isGraphOwner()); … … 53 53 m_renderingStateNeedUpdating = true; 54 54 } 55 } 56 57 bool AudioSummingJunction::addOutput(AudioNodeOutput& output) 58 { 59 ASSERT(context().isGraphOwner()); 60 if (!m_outputs.add(&output).isNewEntry) 61 return false; 62 markRenderingStateAsDirty(); 63 return true; 64 } 65 66 bool AudioSummingJunction::removeOutput(AudioNodeOutput& output) 67 { 68 ASSERT(context().isGraphOwner()); 69 if (!m_outputs.remove(&output)) 70 return false; 71 markRenderingStateAsDirty(); 72 return true; 55 73 } 56 74 … … 74 92 } 75 93 94 unsigned AudioSummingJunction::maximumNumberOfChannels() const 95 { 96 unsigned maxChannels = 0; 97 std::for_each(m_outputs.begin(), m_outputs.end(), [&](auto* output) { 98 // Use output()->numberOfChannels() instead of output->bus()->numberOfChannels(), 99 // because the calling of AudioNodeOutput::bus() is not safe here. 100 maxChannels = std::max(maxChannels, output->numberOfChannels()); 101 }); 102 return maxChannels; 103 } 104 76 105 } // namespace WebCore 77 106 -
trunk/Source/WebCore/Modules/webaudio/AudioSummingJunction.h
r268414 r268820 45 45 const BaseAudioContext& context() const { return m_context; } 46 46 47 // This must be called whenever we modify m_outputs.48 void changedOutputs();49 50 47 // This copies m_outputs to m_renderingOutputs. Please see comments for these lists below. 51 48 // 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. … … 61 58 virtual void didUpdate() = 0; 62 59 60 bool addOutput(AudioNodeOutput&); 61 bool removeOutput(AudioNodeOutput&); 62 63 void markRenderingStateAsDirty(); 64 63 65 protected: 64 66 Ref<BaseAudioContext> m_context; 65 66 // m_outputs contains the AudioNodeOutputs representing current connections which are not disabled.67 // The rendering code should never use this directly, but instead uses m_renderingOutputs.68 HashSet<AudioNodeOutput*> m_outputs;69 67 70 68 // numberOfConnections() should never be called from the audio rendering thread. 71 69 // Instead numberOfRenderingConnections() and renderingOutput() should be used. 72 70 unsigned numberOfConnections() const { return m_outputs.size(); } 71 72 unsigned maximumNumberOfChannels() const; 73 73 74 74 // m_renderingOutputs is a copy of m_outputs which will never be modified during the graph rendering on the audio thread. … … 80 80 // m_renderingStateNeedUpdating keeps track if m_outputs is modified. 81 81 bool m_renderingStateNeedUpdating { false }; 82 83 private: 84 // m_outputs contains the AudioNodeOutputs representing current connections which are not disabled. 85 // The rendering code should never use this directly, but instead uses m_renderingOutputs. 86 HashSet<AudioNodeOutput*> m_outputs; 82 87 }; 83 88
Note:
See TracChangeset
for help on using the changeset viewer.