| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 new_data[channel][i] = i; | 133 new_data[channel][i] = i; |
| 134 } | 134 } |
| 135 } | 135 } |
| 136 // Push back |new_data| into |sync_buffer|. This operation should pop out | 136 // Push back |new_data| into |sync_buffer|. This operation should pop out |
| 137 // data from the front of |sync_buffer|, so that the size of the buffer | 137 // data from the front of |sync_buffer|, so that the size of the buffer |
| 138 // remains the same. The |next_index_| should also move with the same length. | 138 // remains the same. The |next_index_| should also move with the same length. |
| 139 sync_buffer.PushBack(new_data); | 139 sync_buffer.PushBack(new_data); |
| 140 | 140 |
| 141 // Read to interleaved output. Read in two batches, where each read operation | 141 // Read to interleaved output. Read in two batches, where each read operation |
| 142 // should automatically update the |net_index_| in the SyncBuffer. | 142 // should automatically update the |net_index_| in the SyncBuffer. |
| 143 int16_t output[kChannels * kNewLen]; | |
| 144 // Note that |samples_read| is the number of samples read from each channel. | 143 // Note that |samples_read| is the number of samples read from each channel. |
| 145 // That is, the number of samples written to |output| is | 144 // That is, the number of samples written to |output| is |
| 146 // |samples_read| * |kChannels|. | 145 // |samples_read| * |kChannels|. |
| 147 size_t samples_read = sync_buffer.GetNextAudioInterleaved(kNewLen / 2, | 146 AudioFrame output1; |
| 148 output); | 147 sync_buffer.GetNextAudioInterleaved(kNewLen / 2, &output1); |
| 149 samples_read += | 148 EXPECT_EQ(kChannels, output1.num_channels_); |
| 150 sync_buffer.GetNextAudioInterleaved(kNewLen / 2, | 149 EXPECT_EQ(kNewLen / 2, output1.samples_per_channel_); |
| 151 &output[samples_read * kChannels]); | 150 |
| 152 EXPECT_EQ(kNewLen, samples_read); | 151 AudioFrame output2; |
| 152 sync_buffer.GetNextAudioInterleaved(kNewLen / 2, &output2); |
| 153 EXPECT_EQ(kChannels, output2.num_channels_); |
| 154 EXPECT_EQ(kNewLen / 2, output2.samples_per_channel_); |
| 153 | 155 |
| 154 // Verify the data. | 156 // Verify the data. |
| 155 int16_t* output_ptr = output; | 157 int16_t* output_ptr = output1.data_; |
| 156 for (size_t i = 0; i < kNewLen; ++i) { | 158 for (size_t i = 0; i < kNewLen / 2; ++i) { |
| 157 for (size_t channel = 0; channel < kChannels; ++channel) { | 159 for (size_t channel = 0; channel < kChannels; ++channel) { |
| 158 EXPECT_EQ(new_data[channel][i], *output_ptr); | 160 EXPECT_EQ(new_data[channel][i], *output_ptr); |
| 159 ++output_ptr; | 161 ++output_ptr; |
| 162 } |
| 163 } |
| 164 output_ptr = output2.data_; |
| 165 for (size_t i = kNewLen / 2; i < kNewLen; ++i) { |
| 166 for (size_t channel = 0; channel < kChannels; ++channel) { |
| 167 EXPECT_EQ(new_data[channel][i], *output_ptr); |
| 168 ++output_ptr; |
| 160 } | 169 } |
| 161 } | 170 } |
| 162 } | 171 } |
| 163 | 172 |
| 164 } // namespace webrtc | 173 } // namespace webrtc |
| OLD | NEW |