OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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_GT(static_cast<int>(numberOfRenderingConnections()), 1); |
Raymond Toy
2016/07/25 16:56:52
Maybe use
DCHECK_GT(numberOfRenderingConnections()
HyungwookLee
2016/07/26 00:42:40
Done.
| |
176 DCHECK_NE(handler().internalChannelCountMode(), AudioHandler::Max); | |
176 | 177 |
177 ASSERT(summingBus); | 178 DCHECK(summingBus); |
178 if (!summingBus) | 179 if (!summingBus) |
179 return; | 180 return; |
180 | 181 |
181 summingBus->zero(); | 182 summingBus->zero(); |
182 | 183 |
183 AudioBus::ChannelInterpretation interpretation = handler().internalChannelIn terpretation(); | 184 AudioBus::ChannelInterpretation interpretation = handler().internalChannelIn terpretation(); |
184 | 185 |
185 for (unsigned i = 0; i < numberOfRenderingConnections(); ++i) { | 186 for (unsigned i = 0; i < numberOfRenderingConnections(); ++i) { |
186 AudioNodeOutput* output = renderingOutput(i); | 187 AudioNodeOutput* output = renderingOutput(i); |
187 ASSERT(output); | 188 DCHECK(output); |
188 | 189 |
189 // Render audio from this output. | 190 // Render audio from this output. |
190 AudioBus* connectionBus = output->pull(0, framesToProcess); | 191 AudioBus* connectionBus = output->pull(0, framesToProcess); |
191 | 192 |
192 // Sum, with unity-gain. | 193 // Sum, with unity-gain. |
193 summingBus->sumFrom(*connectionBus, interpretation); | 194 summingBus->sumFrom(*connectionBus, interpretation); |
194 } | 195 } |
195 } | 196 } |
196 | 197 |
197 AudioBus* AudioNodeInput::pull(AudioBus* inPlaceBus, size_t framesToProcess) | 198 AudioBus* AudioNodeInput::pull(AudioBus* inPlaceBus, size_t framesToProcess) |
198 { | 199 { |
199 ASSERT(deferredTaskHandler().isAudioThread()); | 200 DCHECK(deferredTaskHandler().isAudioThread()); |
200 | 201 |
201 // Handle single connection case. | 202 // Handle single connection case. |
202 if (numberOfRenderingConnections() == 1 && handler().internalChannelCountMod e() == AudioHandler::Max) { | 203 if (numberOfRenderingConnections() == 1 && handler().internalChannelCountMod e() == AudioHandler::Max) { |
203 // The output will optimize processing using inPlaceBus if it's able. | 204 // The output will optimize processing using inPlaceBus if it's able. |
204 AudioNodeOutput* output = this->renderingOutput(0); | 205 AudioNodeOutput* output = this->renderingOutput(0); |
205 return output->pull(inPlaceBus, framesToProcess); | 206 return output->pull(inPlaceBus, framesToProcess); |
206 } | 207 } |
207 | 208 |
208 AudioBus* internalSummingBus = this->internalSummingBus(); | 209 AudioBus* internalSummingBus = this->internalSummingBus(); |
209 | 210 |
210 if (!numberOfRenderingConnections()) { | 211 if (!numberOfRenderingConnections()) { |
211 // At least, generate silence if we're not connected to anything. | 212 // 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. | 213 // FIXME: if we wanted to get fancy, we could propagate a 'silent hint' here to optimize the downstream graph processing. |
213 internalSummingBus->zero(); | 214 internalSummingBus->zero(); |
214 return internalSummingBus; | 215 return internalSummingBus; |
215 } | 216 } |
216 | 217 |
217 // Handle multiple connections case. | 218 // Handle multiple connections case. |
218 sumAllConnections(internalSummingBus, framesToProcess); | 219 sumAllConnections(internalSummingBus, framesToProcess); |
219 | 220 |
220 return internalSummingBus; | 221 return internalSummingBus; |
221 } | 222 } |
222 | 223 |
223 } // namespace blink | 224 } // namespace blink |
224 | 225 |
OLD | NEW |