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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 source[0] = m_lastValues[0]; | 87 source[0] = m_lastValues[0]; |
88 source[1] = m_lastValues[1]; | 88 source[1] = m_lastValues[1]; |
89 } | 89 } |
90 | 90 |
91 // Make a local copy. | 91 // Make a local copy. |
92 double virtualReadIndex = m_virtualReadIndex; | 92 double virtualReadIndex = m_virtualReadIndex; |
93 | 93 |
94 // Sanity check source buffer access. | 94 // Sanity check source buffer access. |
95 ASSERT(framesToProcess > 0); | 95 ASSERT(framesToProcess > 0); |
96 ASSERT(virtualReadIndex >= 0 && | 96 ASSERT(virtualReadIndex >= 0 && |
97 1 + static_cast<unsigned>(virtualReadIndex + | 97 1 + |
98 (framesToProcess - 1) * rate) < | 98 static_cast<unsigned>(virtualReadIndex + |
| 99 (framesToProcess - 1) * rate) < |
99 m_sourceBuffer.size()); | 100 m_sourceBuffer.size()); |
100 | 101 |
101 // Do the linear interpolation. | 102 // Do the linear interpolation. |
102 int n = framesToProcess; | 103 int n = framesToProcess; |
103 while (n--) { | 104 while (n--) { |
104 unsigned readIndex = static_cast<unsigned>(virtualReadIndex); | 105 unsigned readIndex = static_cast<unsigned>(virtualReadIndex); |
105 double interpolationFactor = virtualReadIndex - readIndex; | 106 double interpolationFactor = virtualReadIndex - readIndex; |
106 | 107 |
107 double sample1 = source[readIndex]; | 108 double sample1 = source[readIndex]; |
108 double sample2 = source[readIndex + 1]; | 109 double sample2 = source[readIndex + 1]; |
(...skipping 25 matching lines...) Expand all Loading... |
134 m_fillIndex = 0; | 135 m_fillIndex = 0; |
135 m_lastValues[0] = 0.0f; | 136 m_lastValues[0] = 0.0f; |
136 m_lastValues[1] = 0.0f; | 137 m_lastValues[1] = 0.0f; |
137 } | 138 } |
138 | 139 |
139 double AudioResamplerKernel::rate() const { | 140 double AudioResamplerKernel::rate() const { |
140 return m_resampler->rate(); | 141 return m_resampler->rate(); |
141 } | 142 } |
142 | 143 |
143 } // namespace blink | 144 } // namespace blink |
OLD | NEW |