Index: third_party/WebKit/Source/platform/audio/AudioResamplerKernel.cpp |
diff --git a/third_party/WebKit/Source/platform/audio/AudioResamplerKernel.cpp b/third_party/WebKit/Source/platform/audio/AudioResamplerKernel.cpp |
index 7936309d0ed0c681fa78dcb8ee2398449fca10b6..b400b1cbb4fa5c534340653bd0a68b093019c6f4 100644 |
--- a/third_party/WebKit/Source/platform/audio/AudioResamplerKernel.cpp |
+++ b/third_party/WebKit/Source/platform/audio/AudioResamplerKernel.cpp |
@@ -10,16 +10,17 @@ |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* |
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY |
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
- * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND |
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
+ * ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE |
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
+ * DAMAGE. |
*/ |
#include "platform/audio/AudioResamplerKernel.h" |
@@ -31,9 +32,9 @@ namespace blink { |
const size_t AudioResamplerKernel::MaxFramesToProcess = 128; |
AudioResamplerKernel::AudioResamplerKernel(AudioResampler* resampler) |
- : m_resampler(resampler) |
- // The buffer size must be large enough to hold up to two extra sample frames for the linear interpolation. |
- , |
+ : m_resampler(resampler), |
+ // The buffer size must be large enough to hold up to two extra sample |
+ // frames for the linear interpolation. |
m_sourceBuffer( |
2 + static_cast<int>(MaxFramesToProcess * AudioResampler::MaxRate)), |
m_virtualReadIndex(0.0), |
@@ -47,15 +48,18 @@ float* AudioResamplerKernel::getSourcePointer( |
size_t* numberOfSourceFramesNeededP) { |
ASSERT(framesToProcess <= MaxFramesToProcess); |
- // Calculate the next "virtual" index. After process() is called, m_virtualReadIndex will equal this value. |
+ // Calculate the next "virtual" index. After process() is called, |
+ // m_virtualReadIndex will equal this value. |
double nextFractionalIndex = m_virtualReadIndex + framesToProcess * rate(); |
- // Because we're linearly interpolating between the previous and next sample we need to round up so we include the next sample. |
+ // Because we're linearly interpolating between the previous and next sample |
+ // we need to round up so we include the next sample. |
int endIndex = static_cast<int>(nextFractionalIndex + |
1.0); // round up to next integer index |
// Determine how many input frames we'll need. |
- // We need to fill the buffer up to and including endIndex (so add 1) but we've already buffered m_fillIndex frames from last time. |
+ // We need to fill the buffer up to and including endIndex (so add 1) but |
+ // we've already buffered m_fillIndex frames from last time. |
size_t framesNeeded = 1 + endIndex - m_fillIndex; |
if (numberOfSourceFramesNeededP) |
*numberOfSourceFramesNeededP = framesNeeded; |
@@ -111,7 +115,8 @@ void AudioResamplerKernel::process(float* destination, size_t framesToProcess) { |
virtualReadIndex += rate; |
} |
- // Save the last two sample-frames which will later be used at the beginning of the source buffer the next time around. |
+ // Save the last two sample-frames which will later be used at the beginning |
+ // of the source buffer the next time around. |
int readIndex = static_cast<int>(virtualReadIndex); |
m_lastValues[0] = source[readIndex]; |
m_lastValues[1] = source[readIndex + 1]; |