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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 DCHECK(m_params.isEmpty()); | 63 DCHECK(m_params.isEmpty()); |
64 } | 64 } |
65 | 65 |
66 void AudioNodeOutput::setNumberOfChannels(unsigned numberOfChannels) { | 66 void AudioNodeOutput::setNumberOfChannels(unsigned numberOfChannels) { |
67 DCHECK_LE(numberOfChannels, BaseAudioContext::maxNumberOfChannels()); | 67 DCHECK_LE(numberOfChannels, BaseAudioContext::maxNumberOfChannels()); |
68 ASSERT(deferredTaskHandler().isGraphOwner()); | 68 ASSERT(deferredTaskHandler().isGraphOwner()); |
69 | 69 |
70 m_desiredNumberOfChannels = numberOfChannels; | 70 m_desiredNumberOfChannels = numberOfChannels; |
71 | 71 |
72 if (deferredTaskHandler().isAudioThread()) { | 72 if (deferredTaskHandler().isAudioThread()) { |
73 // If we're in the audio thread then we can take care of it right away (we s
hould be at the very start or end of a rendering quantum). | 73 // If we're in the audio thread then we can take care of it right away (we |
| 74 // should be at the very start or end of a rendering quantum). |
74 updateNumberOfChannels(); | 75 updateNumberOfChannels(); |
75 } else { | 76 } else { |
76 DCHECK(!m_didCallDispose); | 77 DCHECK(!m_didCallDispose); |
77 // Let the context take care of it in the audio thread in the pre and post r
ender tasks. | 78 // Let the context take care of it in the audio thread in the pre and post |
| 79 // render tasks. |
78 deferredTaskHandler().markAudioNodeOutputDirty(this); | 80 deferredTaskHandler().markAudioNodeOutputDirty(this); |
79 } | 81 } |
80 } | 82 } |
81 | 83 |
82 void AudioNodeOutput::updateInternalBus() { | 84 void AudioNodeOutput::updateInternalBus() { |
83 if (numberOfChannels() == m_internalBus->numberOfChannels()) | 85 if (numberOfChannels() == m_internalBus->numberOfChannels()) |
84 return; | 86 return; |
85 | 87 |
86 m_internalBus = AudioBus::create(numberOfChannels(), | 88 m_internalBus = AudioBus::create(numberOfChannels(), |
87 AudioHandler::ProcessingSizeInFrames); | 89 AudioHandler::ProcessingSizeInFrames); |
(...skipping 14 matching lines...) Expand all Loading... |
102 updateInternalBus(); | 104 updateInternalBus(); |
103 propagateChannelCount(); | 105 propagateChannelCount(); |
104 } | 106 } |
105 } | 107 } |
106 | 108 |
107 void AudioNodeOutput::propagateChannelCount() { | 109 void AudioNodeOutput::propagateChannelCount() { |
108 DCHECK(deferredTaskHandler().isAudioThread()); | 110 DCHECK(deferredTaskHandler().isAudioThread()); |
109 ASSERT(deferredTaskHandler().isGraphOwner()); | 111 ASSERT(deferredTaskHandler().isGraphOwner()); |
110 | 112 |
111 if (isChannelCountKnown()) { | 113 if (isChannelCountKnown()) { |
112 // Announce to any nodes we're connected to that we changed our channel coun
t for its input. | 114 // Announce to any nodes we're connected to that we changed our channel |
| 115 // count for its input. |
113 for (AudioNodeInput* i : m_inputs) | 116 for (AudioNodeInput* i : m_inputs) |
114 i->handler().checkNumberOfChannelsForInput(i); | 117 i->handler().checkNumberOfChannelsForInput(i); |
115 } | 118 } |
116 } | 119 } |
117 | 120 |
118 AudioBus* AudioNodeOutput::pull(AudioBus* inPlaceBus, size_t framesToProcess) { | 121 AudioBus* AudioNodeOutput::pull(AudioBus* inPlaceBus, size_t framesToProcess) { |
119 DCHECK(deferredTaskHandler().isAudioThread()); | 122 DCHECK(deferredTaskHandler().isAudioThread()); |
120 DCHECK(m_renderingFanOutCount > 0 || m_renderingParamFanOutCount > 0); | 123 DCHECK(m_renderingFanOutCount > 0 || m_renderingParamFanOutCount > 0); |
121 | 124 |
122 // Causes our AudioNode to process if it hasn't already for this render quantu
m. | 125 // Causes our AudioNode to process if it hasn't already for this render |
123 // We try to do in-place processing (using inPlaceBus) if at all possible, | 126 // quantum. We try to do in-place processing (using inPlaceBus) if at all |
124 // but we can't process in-place if we're connected to more than one input (fa
n-out > 1). | 127 // possible, but we can't process in-place if we're connected to more than one |
125 // In this case pull() is called multiple times per rendering quantum, and the
processIfNecessary() call below will | 128 // input (fan-out > 1). In this case pull() is called multiple times per |
126 // cause our node to process() only the first time, caching the output in m_in
ternalOutputBus for subsequent calls. | 129 // rendering quantum, and the processIfNecessary() call below will cause our |
| 130 // node to process() only the first time, caching the output in |
| 131 // m_internalOutputBus for subsequent calls. |
127 | 132 |
128 m_isInPlace = inPlaceBus && | 133 m_isInPlace = inPlaceBus && |
129 inPlaceBus->numberOfChannels() == numberOfChannels() && | 134 inPlaceBus->numberOfChannels() == numberOfChannels() && |
130 (m_renderingFanOutCount + m_renderingParamFanOutCount) == 1; | 135 (m_renderingFanOutCount + m_renderingParamFanOutCount) == 1; |
131 | 136 |
132 m_inPlaceBus = m_isInPlace ? inPlaceBus : 0; | 137 m_inPlaceBus = m_isInPlace ? inPlaceBus : 0; |
133 | 138 |
134 handler().processIfNecessary(framesToProcess); | 139 handler().processIfNecessary(framesToProcess); |
135 return bus(); | 140 return bus(); |
136 } | 141 } |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 ASSERT(deferredTaskHandler().isGraphOwner()); | 238 ASSERT(deferredTaskHandler().isGraphOwner()); |
234 | 239 |
235 if (!m_isEnabled) { | 240 if (!m_isEnabled) { |
236 m_isEnabled = true; | 241 m_isEnabled = true; |
237 for (AudioNodeInput* i : m_inputs) | 242 for (AudioNodeInput* i : m_inputs) |
238 i->enable(*this); | 243 i->enable(*this); |
239 } | 244 } |
240 } | 245 } |
241 | 246 |
242 } // namespace blink | 247 } // namespace blink |
OLD | NEW |