| 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 unsigned numberOfOutputChannels = outputBus->numberOfChannels(); | 163 unsigned numberOfOutputChannels = outputBus->numberOfChannels(); |
| 164 | 164 |
| 165 bool channelsAreGood = (numberOfInputChannels == m_numberOfInputChannels) && | 165 bool channelsAreGood = (numberOfInputChannels == m_numberOfInputChannels) && |
| 166 (numberOfOutputChannels == m_numberOfOutputChannels); | 166 (numberOfOutputChannels == m_numberOfOutputChannels); |
| 167 DCHECK(channelsAreGood); | 167 DCHECK(channelsAreGood); |
| 168 if (!channelsAreGood) | 168 if (!channelsAreGood) |
| 169 return; | 169 return; |
| 170 | 170 |
| 171 for (unsigned i = 0; i < numberOfInputChannels; ++i) | 171 for (unsigned i = 0; i < numberOfInputChannels; ++i) |
| 172 m_internalInputBus->setChannelMemory( | 172 m_internalInputBus->setChannelMemory( |
| 173 i, inputBuffer->getChannelData(i)->data() + m_bufferReadWriteIndex, | 173 i, |
| 174 inputBuffer->getChannelData(i).view()->data() + m_bufferReadWriteIndex, |
| 174 framesToProcess); | 175 framesToProcess); |
| 175 | 176 |
| 176 if (numberOfInputChannels) | 177 if (numberOfInputChannels) |
| 177 m_internalInputBus->copyFrom(*inputBus); | 178 m_internalInputBus->copyFrom(*inputBus); |
| 178 | 179 |
| 179 // Copy from the output buffer to the output. | 180 // Copy from the output buffer to the output. |
| 180 for (unsigned i = 0; i < numberOfOutputChannels; ++i) | 181 for (unsigned i = 0; i < numberOfOutputChannels; ++i) { |
| 181 memcpy(outputBus->channel(i)->mutableData(), | 182 memcpy( |
| 182 outputBuffer->getChannelData(i)->data() + m_bufferReadWriteIndex, | 183 outputBus->channel(i)->mutableData(), |
| 183 sizeof(float) * framesToProcess); | 184 outputBuffer->getChannelData(i).view()->data() + m_bufferReadWriteIndex, |
| 185 sizeof(float) * framesToProcess); |
| 186 } |
| 184 | 187 |
| 185 // Update the buffering index. | 188 // Update the buffering index. |
| 186 m_bufferReadWriteIndex = | 189 m_bufferReadWriteIndex = |
| 187 (m_bufferReadWriteIndex + framesToProcess) % bufferSize(); | 190 (m_bufferReadWriteIndex + framesToProcess) % bufferSize(); |
| 188 | 191 |
| 189 // m_bufferReadWriteIndex will wrap back around to 0 when the current input | 192 // m_bufferReadWriteIndex will wrap back around to 0 when the current input |
| 190 // and output buffers are full. | 193 // and output buffers are full. |
| 191 // When this happens, fire an event and swap buffers. | 194 // When this happens, fire an event and swap buffers. |
| 192 if (!m_bufferReadWriteIndex) { | 195 if (!m_bufferReadWriteIndex) { |
| 193 // Avoid building up requests on the main thread to fire process events when | 196 // Avoid building up requests on the main thread to fire process events when |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 | 486 |
| 484 // If |onaudioprocess| event handler is defined, the node should not be | 487 // If |onaudioprocess| event handler is defined, the node should not be |
| 485 // GCed even if it is out of scope. | 488 // GCed even if it is out of scope. |
| 486 if (hasEventListeners(EventTypeNames::audioprocess)) | 489 if (hasEventListeners(EventTypeNames::audioprocess)) |
| 487 return true; | 490 return true; |
| 488 | 491 |
| 489 return false; | 492 return false; |
| 490 } | 493 } |
| 491 | 494 |
| 492 } // namespace blink | 495 } // namespace blink |
| OLD | NEW |