OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | |
3 * | |
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 | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_CIRCULAR_BUFFER_H_ | |
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_CIRCULAR_BUFFER_H_ | |
13 | |
14 #include <vector> | |
15 | |
16 #include "webrtc/base/optional.h" | |
17 | |
18 namespace webrtc { | |
19 | |
20 // Ring buffer containing floating point values. | |
21 struct CircularBuffer { | |
22 public: | |
23 explicit CircularBuffer(size_t size); | |
24 CircularBuffer(CircularBuffer&& other); | |
25 ~CircularBuffer(); | |
26 | |
27 void Push(float value); | |
28 rtc::Optional<float> Pop(); | |
29 size_t buffer_size() { return buffer_size_; } | |
peah-webrtc
2016/10/19 14:45:25
I think you could rename buffer_size() to Size().
ivoc
2016/10/20 14:04:35
Done.
| |
30 // This function fills the buffer with zeros, but does not change its size. | |
31 void Clear(); | |
32 | |
33 private: | |
34 std::vector<float> buffer_; | |
35 size_t next_insertion_index_ = 0; | |
36 // This is the number of elements that have been pushed into the circular | |
37 // buffer, not the allocated buffer size. | |
38 size_t buffer_size_ = 0; | |
39 }; | |
40 | |
41 } // namespace webrtc | |
42 | |
43 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_CIRCULAR_BUFFER_H_ | |
OLD | NEW |