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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 72 |
73 void SyncBuffer::GetNextAudioInterleaved(size_t requested_len, | 73 void SyncBuffer::GetNextAudioInterleaved(size_t requested_len, |
74 AudioFrame* output) { | 74 AudioFrame* output) { |
75 RTC_DCHECK(output); | 75 RTC_DCHECK(output); |
76 const size_t samples_to_read = std::min(FutureLength(), requested_len); | 76 const size_t samples_to_read = std::min(FutureLength(), requested_len); |
77 output->Reset(); | 77 output->Reset(); |
78 const size_t tot_samples_read = | 78 const size_t tot_samples_read = |
79 ReadInterleavedFromIndex(next_index_, samples_to_read, output->data_); | 79 ReadInterleavedFromIndex(next_index_, samples_to_read, output->data_); |
80 const size_t samples_read_per_channel = tot_samples_read / Channels(); | 80 const size_t samples_read_per_channel = tot_samples_read / Channels(); |
81 next_index_ += samples_read_per_channel; | 81 next_index_ += samples_read_per_channel; |
82 output->interleaved_ = true; | |
83 output->num_channels_ = Channels(); | 82 output->num_channels_ = Channels(); |
84 output->samples_per_channel_ = samples_read_per_channel; | 83 output->samples_per_channel_ = samples_read_per_channel; |
85 } | 84 } |
86 | 85 |
87 void SyncBuffer::IncreaseEndTimestamp(uint32_t increment) { | 86 void SyncBuffer::IncreaseEndTimestamp(uint32_t increment) { |
88 end_timestamp_ += increment; | 87 end_timestamp_ += increment; |
89 } | 88 } |
90 | 89 |
91 void SyncBuffer::Flush() { | 90 void SyncBuffer::Flush() { |
92 Zeros(Size()); | 91 Zeros(Size()); |
93 next_index_ = Size(); | 92 next_index_ = Size(); |
94 end_timestamp_ = 0; | 93 end_timestamp_ = 0; |
95 dtmf_index_ = 0; | 94 dtmf_index_ = 0; |
96 } | 95 } |
97 | 96 |
98 void SyncBuffer::set_next_index(size_t value) { | 97 void SyncBuffer::set_next_index(size_t value) { |
99 // Cannot set |next_index_| larger than the size of the buffer. | 98 // Cannot set |next_index_| larger than the size of the buffer. |
100 next_index_ = std::min(value, Size()); | 99 next_index_ = std::min(value, Size()); |
101 } | 100 } |
102 | 101 |
103 void SyncBuffer::set_dtmf_index(size_t value) { | 102 void SyncBuffer::set_dtmf_index(size_t value) { |
104 // Cannot set |dtmf_index_| larger than the size of the buffer. | 103 // Cannot set |dtmf_index_| larger than the size of the buffer. |
105 dtmf_index_ = std::min(value, Size()); | 104 dtmf_index_ = std::min(value, Size()); |
106 } | 105 } |
107 | 106 |
108 } // namespace webrtc | 107 } // namespace webrtc |
OLD | NEW |