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

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/AudioNodeInput.cpp

Issue 2159403002: Replace ASSERT with DCHECK in WebAudio (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010, Google Inc. All rights reserved. 2 * Copyright (C) 2010, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // since the node may be deleted. 78 // since the node may be deleted.
79 return; 79 return;
80 } 80 }
81 81
82 ASSERT_NOT_REACHED(); 82 ASSERT_NOT_REACHED();
83 } 83 }
84 84
85 void AudioNodeInput::disable(AudioNodeOutput& output) 85 void AudioNodeInput::disable(AudioNodeOutput& output)
86 { 86 {
87 ASSERT(deferredTaskHandler().isGraphOwner()); 87 ASSERT(deferredTaskHandler().isGraphOwner());
88 ASSERT(m_outputs.contains(&output)); 88 DCHECK(m_outputs.contains(&output));
89 89
90 m_disabledOutputs.add(&output); 90 m_disabledOutputs.add(&output);
91 m_outputs.remove(&output); 91 m_outputs.remove(&output);
92 changedOutputs(); 92 changedOutputs();
93 93
94 // Propagate disabled state to outputs. 94 // Propagate disabled state to outputs.
95 handler().disableOutputsIfNecessary(); 95 handler().disableOutputsIfNecessary();
96 } 96 }
97 97
98 void AudioNodeInput::enable(AudioNodeOutput& output) 98 void AudioNodeInput::enable(AudioNodeOutput& output)
99 { 99 {
100 ASSERT(deferredTaskHandler().isGraphOwner()); 100 ASSERT(deferredTaskHandler().isGraphOwner());
101 ASSERT(m_disabledOutputs.contains(&output)); 101 DCHECK(m_disabledOutputs.contains(&output));
102 102
103 // Move output from disabled list to active list. 103 // Move output from disabled list to active list.
104 m_outputs.add(&output); 104 m_outputs.add(&output);
105 m_disabledOutputs.remove(&output); 105 m_disabledOutputs.remove(&output);
106 changedOutputs(); 106 changedOutputs();
107 107
108 // Propagate enabled state to outputs. 108 // Propagate enabled state to outputs.
109 handler().enableOutputsIfNecessary(); 109 handler().enableOutputsIfNecessary();
110 } 110 }
111 111
112 void AudioNodeInput::didUpdate() 112 void AudioNodeInput::didUpdate()
113 { 113 {
114 handler().checkNumberOfChannelsForInput(this); 114 handler().checkNumberOfChannelsForInput(this);
115 } 115 }
116 116
117 void AudioNodeInput::updateInternalBus() 117 void AudioNodeInput::updateInternalBus()
118 { 118 {
119 ASSERT(deferredTaskHandler().isAudioThread()); 119 DCHECK(deferredTaskHandler().isAudioThread());
120 ASSERT(deferredTaskHandler().isGraphOwner()); 120 ASSERT(deferredTaskHandler().isGraphOwner());
121 121
122 unsigned numberOfInputChannels = numberOfChannels(); 122 unsigned numberOfInputChannels = numberOfChannels();
123 123
124 if (numberOfInputChannels == m_internalSummingBus->numberOfChannels()) 124 if (numberOfInputChannels == m_internalSummingBus->numberOfChannels())
125 return; 125 return;
126 126
127 m_internalSummingBus = AudioBus::create(numberOfInputChannels, AudioHandler: :ProcessingSizeInFrames); 127 m_internalSummingBus = AudioBus::create(numberOfInputChannels, AudioHandler: :ProcessingSizeInFrames);
128 } 128 }
129 129
(...skipping 13 matching lines...) Expand all
143 } 143 }
144 144
145 if (mode == AudioHandler::ClampedMax) 145 if (mode == AudioHandler::ClampedMax)
146 maxChannels = std::min(maxChannels, static_cast<unsigned>(handler().chan nelCount())); 146 maxChannels = std::min(maxChannels, static_cast<unsigned>(handler().chan nelCount()));
147 147
148 return maxChannels; 148 return maxChannels;
149 } 149 }
150 150
151 AudioBus* AudioNodeInput::bus() 151 AudioBus* AudioNodeInput::bus()
152 { 152 {
153 ASSERT(deferredTaskHandler().isAudioThread()); 153 DCHECK(deferredTaskHandler().isAudioThread());
154 154
155 // Handle single connection specially to allow for in-place processing. 155 // Handle single connection specially to allow for in-place processing.
156 if (numberOfRenderingConnections() == 1 && handler().internalChannelCountMod e() == AudioHandler::Max) 156 if (numberOfRenderingConnections() == 1 && handler().internalChannelCountMod e() == AudioHandler::Max)
157 return renderingOutput(0)->bus(); 157 return renderingOutput(0)->bus();
158 158
159 // Multiple connections case or complex ChannelCountMode (or no connections) . 159 // Multiple connections case or complex ChannelCountMode (or no connections) .
160 return internalSummingBus(); 160 return internalSummingBus();
161 } 161 }
162 162
163 AudioBus* AudioNodeInput::internalSummingBus() 163 AudioBus* AudioNodeInput::internalSummingBus()
164 { 164 {
165 ASSERT(deferredTaskHandler().isAudioThread()); 165 DCHECK(deferredTaskHandler().isAudioThread());
166 166
167 return m_internalSummingBus.get(); 167 return m_internalSummingBus.get();
168 } 168 }
169 169
170 void AudioNodeInput::sumAllConnections(AudioBus* summingBus, size_t framesToProc ess) 170 void AudioNodeInput::sumAllConnections(AudioBus* summingBus, size_t framesToProc ess)
171 { 171 {
172 ASSERT(deferredTaskHandler().isAudioThread()); 172 DCHECK(deferredTaskHandler().isAudioThread());
173 173
174 // We shouldn't be calling this method if there's only one connection, since it's less efficient. 174 // We shouldn't be calling this method if there's only one connection, since it's less efficient.
175 ASSERT(numberOfRenderingConnections() > 1 || handler().internalChannelCountM ode() != AudioHandler::Max); 175 DCHECK(numberOfRenderingConnections() > 1 || handler().internalChannelCountM ode() != AudioHandler::Max);
Raymond Toy 2016/07/22 14:59:26 Since we're rewriting these anyway, I think I'd pr
HyungwookLee 2016/07/25 00:24:44 Done.
176 176
177 ASSERT(summingBus); 177 DCHECK(summingBus);
178 if (!summingBus) 178 if (!summingBus)
179 return; 179 return;
180 180
181 summingBus->zero(); 181 summingBus->zero();
182 182
183 AudioBus::ChannelInterpretation interpretation = handler().internalChannelIn terpretation(); 183 AudioBus::ChannelInterpretation interpretation = handler().internalChannelIn terpretation();
184 184
185 for (unsigned i = 0; i < numberOfRenderingConnections(); ++i) { 185 for (unsigned i = 0; i < numberOfRenderingConnections(); ++i) {
186 AudioNodeOutput* output = renderingOutput(i); 186 AudioNodeOutput* output = renderingOutput(i);
187 ASSERT(output); 187 DCHECK(output);
188 188
189 // Render audio from this output. 189 // Render audio from this output.
190 AudioBus* connectionBus = output->pull(0, framesToProcess); 190 AudioBus* connectionBus = output->pull(0, framesToProcess);
191 191
192 // Sum, with unity-gain. 192 // Sum, with unity-gain.
193 summingBus->sumFrom(*connectionBus, interpretation); 193 summingBus->sumFrom(*connectionBus, interpretation);
194 } 194 }
195 } 195 }
196 196
197 AudioBus* AudioNodeInput::pull(AudioBus* inPlaceBus, size_t framesToProcess) 197 AudioBus* AudioNodeInput::pull(AudioBus* inPlaceBus, size_t framesToProcess)
198 { 198 {
199 ASSERT(deferredTaskHandler().isAudioThread()); 199 DCHECK(deferredTaskHandler().isAudioThread());
200 200
201 // Handle single connection case. 201 // Handle single connection case.
202 if (numberOfRenderingConnections() == 1 && handler().internalChannelCountMod e() == AudioHandler::Max) { 202 if (numberOfRenderingConnections() == 1 && handler().internalChannelCountMod e() == AudioHandler::Max) {
203 // The output will optimize processing using inPlaceBus if it's able. 203 // The output will optimize processing using inPlaceBus if it's able.
204 AudioNodeOutput* output = this->renderingOutput(0); 204 AudioNodeOutput* output = this->renderingOutput(0);
205 return output->pull(inPlaceBus, framesToProcess); 205 return output->pull(inPlaceBus, framesToProcess);
206 } 206 }
207 207
208 AudioBus* internalSummingBus = this->internalSummingBus(); 208 AudioBus* internalSummingBus = this->internalSummingBus();
209 209
210 if (!numberOfRenderingConnections()) { 210 if (!numberOfRenderingConnections()) {
211 // At least, generate silence if we're not connected to anything. 211 // At least, generate silence if we're not connected to anything.
212 // FIXME: if we wanted to get fancy, we could propagate a 'silent hint' here to optimize the downstream graph processing. 212 // FIXME: if we wanted to get fancy, we could propagate a 'silent hint' here to optimize the downstream graph processing.
213 internalSummingBus->zero(); 213 internalSummingBus->zero();
214 return internalSummingBus; 214 return internalSummingBus;
215 } 215 }
216 216
217 // Handle multiple connections case. 217 // Handle multiple connections case.
218 sumAllConnections(internalSummingBus, framesToProcess); 218 sumAllConnections(internalSummingBus, framesToProcess);
219 219
220 return internalSummingBus; 220 return internalSummingBus;
221 } 221 }
222 222
223 } // namespace blink 223 } // namespace blink
224 224
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/webaudio/AudioNode.cpp ('k') | third_party/WebKit/Source/modules/webaudio/AudioNodeOutput.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698