| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 // FIXME: Find a way to make the following const-correct: | 139 // FIXME: Find a way to make the following const-correct: |
| 140 bus->setChannelMemory(0, buffer, numberOfSourceFrames); | 140 bus->setChannelMemory(0, buffer, numberOfSourceFrames); |
| 141 | 141 |
| 142 m_sourceProvider->provideInput(bus.get(), numberOfSourceFrames); | 142 m_sourceProvider->provideInput(bus.get(), numberOfSourceFrames); |
| 143 } | 143 } |
| 144 | 144 |
| 145 namespace { | 145 namespace { |
| 146 | 146 |
| 147 // BufferSourceProvider is an AudioSourceProvider wrapping an in-memory buffer. | 147 // BufferSourceProvider is an AudioSourceProvider wrapping an in-memory buffer. |
| 148 | 148 |
| 149 class BufferSourceProvider : public AudioSourceProvider { | 149 class BufferSourceProvider FINAL : public AudioSourceProvider { |
| 150 public: | 150 public: |
| 151 BufferSourceProvider(const float* source, size_t numberOfSourceFrames) | 151 BufferSourceProvider(const float* source, size_t numberOfSourceFrames) |
| 152 : m_source(source) | 152 : m_source(source) |
| 153 , m_sourceFramesAvailable(numberOfSourceFrames) | 153 , m_sourceFramesAvailable(numberOfSourceFrames) |
| 154 { | 154 { |
| 155 } | 155 } |
| 156 | 156 |
| 157 // Consumes samples from the in-memory buffer. | 157 // Consumes samples from the in-memory buffer. |
| 158 virtual void provideInput(AudioBus* bus, size_t framesToProcess) | 158 virtual void provideInput(AudioBus* bus, size_t framesToProcess) OVERRIDE |
| 159 { | 159 { |
| 160 ASSERT(m_source && bus); | 160 ASSERT(m_source && bus); |
| 161 if (!m_source || !bus) | 161 if (!m_source || !bus) |
| 162 return; | 162 return; |
| 163 | 163 |
| 164 float* buffer = bus->channel(0)->mutableData(); | 164 float* buffer = bus->channel(0)->mutableData(); |
| 165 | 165 |
| 166 // Clamp to number of frames available and zero-pad. | 166 // Clamp to number of frames available and zero-pad. |
| 167 size_t framesToCopy = min(m_sourceFramesAvailable, framesToProcess); | 167 size_t framesToCopy = min(m_sourceFramesAvailable, framesToProcess); |
| 168 memcpy(buffer, m_source, sizeof(float) * framesToCopy); | 168 memcpy(buffer, m_source, sizeof(float) * framesToCopy); |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 | 465 |
| 466 // Step (4) | 466 // Step (4) |
| 467 // Refresh the buffer with more input. | 467 // Refresh the buffer with more input. |
| 468 consumeSource(r5, m_blockSize); | 468 consumeSource(r5, m_blockSize); |
| 469 } | 469 } |
| 470 } | 470 } |
| 471 | 471 |
| 472 } // namespace WebCore | 472 } // namespace WebCore |
| 473 | 473 |
| 474 #endif // ENABLE(WEB_AUDIO) | 474 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |