| 137 | } |
| 138 | |
| 139 | AudioBus * AudioNodeInput::pull(ContextRenderLock & r, AudioBus * inPlaceBus, int bufferSize) |
| 140 | { |
| 141 | updateRenderingState(r); |
| 142 | m_destinationNode->checkNumberOfChannelsForInput(r, this); |
| 143 | |
| 144 | size_t num_connections = numberOfRenderingConnections(r); |
| 145 | |
| 146 | // Handle single connection case. |
| 147 | if (num_connections == 1) |
| 148 | { |
| 149 | // If this input is simply passing data through, then immediately delegate the pull request to it. |
| 150 | auto output = renderingOutput(r, 0); |
| 151 | if (output) |
| 152 | { |
| 153 | return output->pull(r, inPlaceBus, bufferSize); |
| 154 | } |
| 155 | |
| 156 | num_connections = 0; // if there's a single input, but it has no output; treat this input as silent. |
| 157 | } |
| 158 | |
| 159 | if (num_connections == 0) |
| 160 | { |
| 161 | // Generate silence if we're not connected to anything, and return the silent bus |
| 162 | /// @TODO a possible optimization is to flag silence and propagate it to consumers of this input. |
| 163 | m_internalSummingBus->zero(); |
| 164 | return m_internalSummingBus.get(); |
| 165 | } |
| 166 | |
| 167 | // multiple connections |
| 168 | m_internalSummingBus->zero(); |
| 169 | |
| 170 | for (int i = 0; i < num_connections; ++i) |
| 171 | { |
| 172 | auto output = renderingOutput(r, i); |
| 173 | if (output) |
| 174 | { |
| 175 | // Render audio from this output. |
| 176 | AudioBus * connectionBus = output->pull(r, 0, bufferSize); |
| 177 | |
| 178 | // Sum, with unity-gain. |
| 179 | m_internalSummingBus->sumFrom(*connectionBus); |
| 180 | } |
| 181 | } |
| 182 | return m_internalSummingBus.get(); |
| 183 | } |
| 184 | |
| 185 | } // namespace lab |
no test coverage detected