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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 79 |
80 void AudioBasicProcessorHandler::process(size_t framesToProcess) { | 80 void AudioBasicProcessorHandler::process(size_t framesToProcess) { |
81 AudioBus* destinationBus = output(0).bus(); | 81 AudioBus* destinationBus = output(0).bus(); |
82 | 82 |
83 if (!isInitialized() || !processor() || | 83 if (!isInitialized() || !processor() || |
84 processor()->numberOfChannels() != numberOfChannels()) { | 84 processor()->numberOfChannels() != numberOfChannels()) { |
85 destinationBus->zero(); | 85 destinationBus->zero(); |
86 } else { | 86 } else { |
87 AudioBus* sourceBus = input(0).bus(); | 87 AudioBus* sourceBus = input(0).bus(); |
88 | 88 |
89 // FIXME: if we take "tail time" into account, then we can avoid calling pro
cessor()->process() once the tail dies down. | 89 // FIXME: if we take "tail time" into account, then we can avoid calling |
| 90 // processor()->process() once the tail dies down. |
90 if (!input(0).isConnected()) | 91 if (!input(0).isConnected()) |
91 sourceBus->zero(); | 92 sourceBus->zero(); |
92 | 93 |
93 processor()->process(sourceBus, destinationBus, framesToProcess); | 94 processor()->process(sourceBus, destinationBus, framesToProcess); |
94 } | 95 } |
95 } | 96 } |
96 | 97 |
97 // Nice optimization in the very common case allowing for "in-place" processing | 98 // Nice optimization in the very common case allowing for "in-place" processing |
98 void AudioBasicProcessorHandler::pullInputs(size_t framesToProcess) { | 99 void AudioBasicProcessorHandler::pullInputs(size_t framesToProcess) { |
99 // Render input stream - suggest to the input to render directly into output b
us for in-place processing in process() if possible. | 100 // Render input stream - suggest to the input to render directly into output |
| 101 // bus for in-place processing in process() if possible. |
100 input(0).pull(output(0).bus(), framesToProcess); | 102 input(0).pull(output(0).bus(), framesToProcess); |
101 } | 103 } |
102 | 104 |
103 // As soon as we know the channel count of our input, we can lazily initialize. | 105 // As soon as we know the channel count of our input, we can lazily initialize. |
104 // Sometimes this may be called more than once with different channel counts, in
which case we must safely | 106 // Sometimes this may be called more than once with different channel counts, in |
105 // uninitialize and then re-initialize with the new channel count. | 107 // which case we must safely uninitialize and then re-initialize with the new |
| 108 // channel count. |
106 void AudioBasicProcessorHandler::checkNumberOfChannelsForInput( | 109 void AudioBasicProcessorHandler::checkNumberOfChannelsForInput( |
107 AudioNodeInput* input) { | 110 AudioNodeInput* input) { |
108 DCHECK(context()->isAudioThread()); | 111 DCHECK(context()->isAudioThread()); |
109 ASSERT(context()->isGraphOwner()); | 112 ASSERT(context()->isGraphOwner()); |
110 | 113 |
111 DCHECK_EQ(input, &this->input(0)); | 114 DCHECK_EQ(input, &this->input(0)); |
112 if (input != &this->input(0)) | 115 if (input != &this->input(0)) |
113 return; | 116 return; |
114 | 117 |
115 DCHECK(processor()); | 118 DCHECK(processor()); |
116 if (!processor()) | 119 if (!processor()) |
117 return; | 120 return; |
118 | 121 |
119 unsigned numberOfChannels = input->numberOfChannels(); | 122 unsigned numberOfChannels = input->numberOfChannels(); |
120 | 123 |
121 if (isInitialized() && numberOfChannels != output(0).numberOfChannels()) { | 124 if (isInitialized() && numberOfChannels != output(0).numberOfChannels()) { |
122 // We're already initialized but the channel count has changed. | 125 // We're already initialized but the channel count has changed. |
123 uninitialize(); | 126 uninitialize(); |
124 } | 127 } |
125 | 128 |
126 if (!isInitialized()) { | 129 if (!isInitialized()) { |
127 // This will propagate the channel count to any nodes connected further down
the chain... | 130 // This will propagate the channel count to any nodes connected further down |
| 131 // the chain... |
128 output(0).setNumberOfChannels(numberOfChannels); | 132 output(0).setNumberOfChannels(numberOfChannels); |
129 | 133 |
130 // Re-initialize the processor with the new channel count. | 134 // Re-initialize the processor with the new channel count. |
131 processor()->setNumberOfChannels(numberOfChannels); | 135 processor()->setNumberOfChannels(numberOfChannels); |
132 initialize(); | 136 initialize(); |
133 } | 137 } |
134 | 138 |
135 AudioHandler::checkNumberOfChannelsForInput(input); | 139 AudioHandler::checkNumberOfChannelsForInput(input); |
136 } | 140 } |
137 | 141 |
138 unsigned AudioBasicProcessorHandler::numberOfChannels() { | 142 unsigned AudioBasicProcessorHandler::numberOfChannels() { |
139 return output(0).numberOfChannels(); | 143 return output(0).numberOfChannels(); |
140 } | 144 } |
141 | 145 |
142 double AudioBasicProcessorHandler::tailTime() const { | 146 double AudioBasicProcessorHandler::tailTime() const { |
143 return m_processor->tailTime(); | 147 return m_processor->tailTime(); |
144 } | 148 } |
145 | 149 |
146 double AudioBasicProcessorHandler::latencyTime() const { | 150 double AudioBasicProcessorHandler::latencyTime() const { |
147 return m_processor->latencyTime(); | 151 return m_processor->latencyTime(); |
148 } | 152 } |
149 | 153 |
150 } // namespace blink | 154 } // namespace blink |
OLD | NEW |