OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 25 matching lines...) Expand all Loading... |
36 // over again from the beginning of the array. This is done to simplify | 36 // over again from the beginning of the array. This is done to simplify |
37 // the reading process when reading over the end of the loop. | 37 // the reading process when reading over the end of the loop. |
38 memcpy(&audio_array_[samples_read], audio_array_.get(), | 38 memcpy(&audio_array_[samples_read], audio_array_.get(), |
39 block_length_samples * sizeof(int16_t)); | 39 block_length_samples * sizeof(int16_t)); |
40 | 40 |
41 loop_length_samples_ = samples_read; | 41 loop_length_samples_ = samples_read; |
42 block_length_samples_ = block_length_samples; | 42 block_length_samples_ = block_length_samples; |
43 return true; | 43 return true; |
44 } | 44 } |
45 | 45 |
46 const int16_t* AudioLoop::GetNextBlock() { | 46 rtc::ArrayView<const int16_t> AudioLoop::GetNextBlock() { |
47 // Check that the AudioLoop is initialized. | 47 // Check that the AudioLoop is initialized. |
48 if (block_length_samples_ == 0) return NULL; | 48 if (block_length_samples_ == 0) |
| 49 return rtc::ArrayView<const int16_t>(); |
49 | 50 |
50 const int16_t* output_ptr = &audio_array_[next_index_]; | 51 const int16_t* output_ptr = &audio_array_[next_index_]; |
51 next_index_ = (next_index_ + block_length_samples_) % loop_length_samples_; | 52 next_index_ = (next_index_ + block_length_samples_) % loop_length_samples_; |
52 return output_ptr; | 53 return rtc::ArrayView<const int16_t>(output_ptr, block_length_samples_); |
53 } | 54 } |
54 | 55 |
55 | 56 |
56 } // namespace test | 57 } // namespace test |
57 } // namespace webrtc | 58 } // namespace webrtc |
OLD | NEW |