| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 | 120 |
| 121 m_internalSummingBus = AudioBus::create(numberOfInputChannels, | 121 m_internalSummingBus = AudioBus::create(numberOfInputChannels, |
| 122 AudioHandler::ProcessingSizeInFrames); | 122 AudioHandler::ProcessingSizeInFrames); |
| 123 } | 123 } |
| 124 | 124 |
| 125 unsigned AudioNodeInput::numberOfChannels() const { | 125 unsigned AudioNodeInput::numberOfChannels() const { |
| 126 AudioHandler::ChannelCountMode mode = handler().internalChannelCountMode(); | 126 AudioHandler::ChannelCountMode mode = handler().internalChannelCountMode(); |
| 127 if (mode == AudioHandler::Explicit) | 127 if (mode == AudioHandler::Explicit) |
| 128 return handler().channelCount(); | 128 return handler().channelCount(); |
| 129 | 129 |
| 130 // Find the number of channels of the connection with the largest number of ch
annels. | 130 // Find the number of channels of the connection with the largest number of |
| 131 // channels. |
| 131 unsigned maxChannels = 1; // one channel is the minimum allowed | 132 unsigned maxChannels = 1; // one channel is the minimum allowed |
| 132 | 133 |
| 133 for (AudioNodeOutput* output : m_outputs) { | 134 for (AudioNodeOutput* output : m_outputs) { |
| 134 // Use output()->numberOfChannels() instead of output->bus()->numberOfChanne
ls(), | 135 // Use output()->numberOfChannels() instead of |
| 135 // because the calling of AudioNodeOutput::bus() is not safe here. | 136 // output->bus()->numberOfChannels(), because the calling of |
| 137 // AudioNodeOutput::bus() is not safe here. |
| 136 maxChannels = std::max(maxChannels, output->numberOfChannels()); | 138 maxChannels = std::max(maxChannels, output->numberOfChannels()); |
| 137 } | 139 } |
| 138 | 140 |
| 139 if (mode == AudioHandler::ClampedMax) | 141 if (mode == AudioHandler::ClampedMax) |
| 140 maxChannels = | 142 maxChannels = |
| 141 std::min(maxChannels, static_cast<unsigned>(handler().channelCount())); | 143 std::min(maxChannels, static_cast<unsigned>(handler().channelCount())); |
| 142 | 144 |
| 143 return maxChannels; | 145 return maxChannels; |
| 144 } | 146 } |
| 145 | 147 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 158 AudioBus* AudioNodeInput::internalSummingBus() { | 160 AudioBus* AudioNodeInput::internalSummingBus() { |
| 159 DCHECK(deferredTaskHandler().isAudioThread()); | 161 DCHECK(deferredTaskHandler().isAudioThread()); |
| 160 | 162 |
| 161 return m_internalSummingBus.get(); | 163 return m_internalSummingBus.get(); |
| 162 } | 164 } |
| 163 | 165 |
| 164 void AudioNodeInput::sumAllConnections(AudioBus* summingBus, | 166 void AudioNodeInput::sumAllConnections(AudioBus* summingBus, |
| 165 size_t framesToProcess) { | 167 size_t framesToProcess) { |
| 166 DCHECK(deferredTaskHandler().isAudioThread()); | 168 DCHECK(deferredTaskHandler().isAudioThread()); |
| 167 | 169 |
| 168 // We shouldn't be calling this method if there's only one connection, since i
t's less efficient. | 170 // We shouldn't be calling this method if there's only one connection, since |
| 169 // DCHECK(numberOfRenderingConnections() > 1 || handler().internalChannelCo
untMode() != AudioHandler::Max); | 171 // it's less efficient. |
| 172 // DCHECK(numberOfRenderingConnections() > 1 || |
| 173 // handler().internalChannelCountMode() != AudioHandler::Max); |
| 170 | 174 |
| 171 DCHECK(summingBus); | 175 DCHECK(summingBus); |
| 172 if (!summingBus) | 176 if (!summingBus) |
| 173 return; | 177 return; |
| 174 | 178 |
| 175 summingBus->zero(); | 179 summingBus->zero(); |
| 176 | 180 |
| 177 AudioBus::ChannelInterpretation interpretation = | 181 AudioBus::ChannelInterpretation interpretation = |
| 178 handler().internalChannelInterpretation(); | 182 handler().internalChannelInterpretation(); |
| 179 | 183 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 197 handler().internalChannelCountMode() == AudioHandler::Max) { | 201 handler().internalChannelCountMode() == AudioHandler::Max) { |
| 198 // The output will optimize processing using inPlaceBus if it's able. | 202 // The output will optimize processing using inPlaceBus if it's able. |
| 199 AudioNodeOutput* output = this->renderingOutput(0); | 203 AudioNodeOutput* output = this->renderingOutput(0); |
| 200 return output->pull(inPlaceBus, framesToProcess); | 204 return output->pull(inPlaceBus, framesToProcess); |
| 201 } | 205 } |
| 202 | 206 |
| 203 AudioBus* internalSummingBus = this->internalSummingBus(); | 207 AudioBus* internalSummingBus = this->internalSummingBus(); |
| 204 | 208 |
| 205 if (!numberOfRenderingConnections()) { | 209 if (!numberOfRenderingConnections()) { |
| 206 // At least, generate silence if we're not connected to anything. | 210 // At least, generate silence if we're not connected to anything. |
| 207 // FIXME: if we wanted to get fancy, we could propagate a 'silent hint' here
to optimize the downstream graph processing. | 211 // FIXME: if we wanted to get fancy, we could propagate a 'silent hint' here |
| 212 // to optimize the downstream graph processing. |
| 208 internalSummingBus->zero(); | 213 internalSummingBus->zero(); |
| 209 return internalSummingBus; | 214 return internalSummingBus; |
| 210 } | 215 } |
| 211 | 216 |
| 212 // Handle multiple connections case. | 217 // Handle multiple connections case. |
| 213 sumAllConnections(internalSummingBus, framesToProcess); | 218 sumAllConnections(internalSummingBus, framesToProcess); |
| 214 | 219 |
| 215 return internalSummingBus; | 220 return internalSummingBus; |
| 216 } | 221 } |
| 217 | 222 |
| 218 } // namespace blink | 223 } // namespace blink |
| OLD | NEW |