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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 if (m_numberOfChannels != m_desiredNumberOfChannels) { | 88 if (m_numberOfChannels != m_desiredNumberOfChannels) { |
89 m_numberOfChannels = m_desiredNumberOfChannels; | 89 m_numberOfChannels = m_desiredNumberOfChannels; |
90 updateInternalBus(); | 90 updateInternalBus(); |
91 propagateChannelCount(); | 91 propagateChannelCount(); |
92 } | 92 } |
93 } | 93 } |
94 | 94 |
95 void AudioNodeOutput::propagateChannelCount() | 95 void AudioNodeOutput::propagateChannelCount() |
96 { | 96 { |
97 ASSERT(context()->isAudioThread() && context()->isGraphOwner()); | 97 ASSERT(context()->isAudioThread() && context()->isGraphOwner()); |
98 | 98 |
99 if (isChannelCountKnown()) { | 99 if (isChannelCountKnown()) { |
100 // Announce to any nodes we're connected to that we changed our channel
count for its input. | 100 // Announce to any nodes we're connected to that we changed our channel
count for its input. |
101 for (InputsIterator i = m_inputs.begin(); i != m_inputs.end(); ++i) { | 101 for (InputsIterator i = m_inputs.begin(); i != m_inputs.end(); ++i) { |
102 AudioNodeInput* input = *i; | 102 AudioNodeInput* input = *i; |
103 AudioNode* connectionNode = input->node(); | 103 AudioNode* connectionNode = input->node(); |
104 connectionNode->checkNumberOfChannelsForInput(input); | 104 connectionNode->checkNumberOfChannelsForInput(input); |
105 } | 105 } |
106 } | 106 } |
107 } | 107 } |
108 | 108 |
109 AudioBus* AudioNodeOutput::pull(AudioBus* inPlaceBus, size_t framesToProcess) | 109 AudioBus* AudioNodeOutput::pull(AudioBus* inPlaceBus, size_t framesToProcess) |
110 { | 110 { |
111 ASSERT(context()->isAudioThread()); | 111 ASSERT(context()->isAudioThread()); |
112 ASSERT(m_renderingFanOutCount > 0 || m_renderingParamFanOutCount > 0); | 112 ASSERT(m_renderingFanOutCount > 0 || m_renderingParamFanOutCount > 0); |
113 | 113 |
114 // Causes our AudioNode to process if it hasn't already for this render quan
tum. | 114 // Causes our AudioNode to process if it hasn't already for this render quan
tum. |
115 // We try to do in-place processing (using inPlaceBus) if at all possible, | 115 // We try to do in-place processing (using inPlaceBus) if at all possible, |
116 // but we can't process in-place if we're connected to more than one input (
fan-out > 1). | 116 // but we can't process in-place if we're connected to more than one input (
fan-out > 1). |
117 // In this case pull() is called multiple times per rendering quantum, and t
he processIfNecessary() call below will | 117 // In this case pull() is called multiple times per rendering quantum, and t
he processIfNecessary() call below will |
118 // cause our node to process() only the first time, caching the output in m_
internalOutputBus for subsequent calls. | 118 // cause our node to process() only the first time, caching the output in m_
internalOutputBus for subsequent calls. |
119 | 119 |
120 m_isInPlace = inPlaceBus && inPlaceBus->numberOfChannels() == numberOfChanne
ls() && (m_renderingFanOutCount + m_renderingParamFanOutCount) == 1; | 120 m_isInPlace = inPlaceBus && inPlaceBus->numberOfChannels() == numberOfChanne
ls() && (m_renderingFanOutCount + m_renderingParamFanOutCount) == 1; |
121 | 121 |
122 m_inPlaceBus = m_isInPlace ? inPlaceBus : 0; | 122 m_inPlaceBus = m_isInPlace ? inPlaceBus : 0; |
123 | 123 |
124 node()->processIfNecessary(framesToProcess); | 124 node()->processIfNecessary(framesToProcess); |
125 return bus(); | 125 return bus(); |
126 } | 126 } |
127 | 127 |
128 AudioBus* AudioNodeOutput::bus() const | 128 AudioBus* AudioNodeOutput::bus() const |
129 { | 129 { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 ASSERT(input); | 171 ASSERT(input); |
172 if (!input) | 172 if (!input) |
173 return; | 173 return; |
174 | 174 |
175 m_inputs.remove(input); | 175 m_inputs.remove(input); |
176 } | 176 } |
177 | 177 |
178 void AudioNodeOutput::disconnectAllInputs() | 178 void AudioNodeOutput::disconnectAllInputs() |
179 { | 179 { |
180 ASSERT(context()->isGraphOwner()); | 180 ASSERT(context()->isGraphOwner()); |
181 | 181 |
182 // AudioNodeInput::disconnect() changes m_inputs by calling removeInput(). | 182 // AudioNodeInput::disconnect() changes m_inputs by calling removeInput(). |
183 while (!m_inputs.isEmpty()) { | 183 while (!m_inputs.isEmpty()) { |
184 AudioNodeInput* input = *m_inputs.begin(); | 184 AudioNodeInput* input = *m_inputs.begin(); |
185 input->disconnect(this); | 185 input->disconnect(this); |
186 } | 186 } |
187 } | 187 } |
188 | 188 |
189 void AudioNodeOutput::addParam(AudioParam* param) | 189 void AudioNodeOutput::addParam(AudioParam* param) |
190 { | 190 { |
191 ASSERT(context()->isGraphOwner()); | 191 ASSERT(context()->isGraphOwner()); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 AudioNodeInput* input = *i; | 247 AudioNodeInput* input = *i; |
248 input->enable(this); | 248 input->enable(this); |
249 } | 249 } |
250 m_isEnabled = true; | 250 m_isEnabled = true; |
251 } | 251 } |
252 } | 252 } |
253 | 253 |
254 } // namespace WebCore | 254 } // namespace WebCore |
255 | 255 |
256 #endif // ENABLE(WEB_AUDIO) | 256 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |