OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 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 |
11 // A ring buffer to hold arbitrary data. Provides no thread safety. Unless | 11 // A ring buffer to hold arbitrary data. Provides no thread safety. Unless |
12 // otherwise specified, functions return 0 on success and -1 on error. | 12 // otherwise specified, functions return 0 on success and -1 on error. |
13 | 13 |
14 #ifndef WEBRTC_COMMON_AUDIO_RING_BUFFER_H_ | 14 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_UTILITY_RING_BUFFER_H_ |
15 #define WEBRTC_COMMON_AUDIO_RING_BUFFER_H_ | 15 #define WEBRTC_MODULES_AUDIO_PROCESSING_UTILITY_RING_BUFFER_H_ |
16 | 16 |
17 #ifdef __cplusplus | 17 #ifdef __cplusplus |
18 extern "C" { | 18 extern "C" { |
19 #endif | 19 #endif |
20 | 20 |
21 #include <stddef.h> // size_t | 21 #include <stddef.h> // size_t |
22 | 22 |
23 typedef struct RingBuffer RingBuffer; | 23 typedef struct RingBuffer RingBuffer; |
24 | 24 |
25 // Creates and initializes the buffer. Returns NULL on failure. | 25 // Creates and initializes the buffer. Returns NULL on failure. |
(...skipping 10 matching lines...) Expand all Loading... |
36 // | 36 // |
37 // To force a copying to |data|, pass a NULL |data_ptr|. | 37 // To force a copying to |data|, pass a NULL |data_ptr|. |
38 // | 38 // |
39 // Returns number of elements read. | 39 // Returns number of elements read. |
40 size_t WebRtc_ReadBuffer(RingBuffer* handle, | 40 size_t WebRtc_ReadBuffer(RingBuffer* handle, |
41 void** data_ptr, | 41 void** data_ptr, |
42 void* data, | 42 void* data, |
43 size_t element_count); | 43 size_t element_count); |
44 | 44 |
45 // Writes |data| to buffer and returns the number of elements written. | 45 // Writes |data| to buffer and returns the number of elements written. |
46 size_t WebRtc_WriteBuffer(RingBuffer* handle, const void* data, | 46 size_t WebRtc_WriteBuffer(RingBuffer* handle, |
| 47 const void* data, |
47 size_t element_count); | 48 size_t element_count); |
48 | 49 |
49 // Moves the buffer read position and returns the number of elements moved. | 50 // Moves the buffer read position and returns the number of elements moved. |
50 // Positive |element_count| moves the read position towards the write position, | 51 // Positive |element_count| moves the read position towards the write position, |
51 // that is, flushing the buffer. Negative |element_count| moves the read | 52 // that is, flushing the buffer. Negative |element_count| moves the read |
52 // position away from the the write position, that is, stuffing the buffer. | 53 // position away from the the write position, that is, stuffing the buffer. |
53 // Returns number of elements moved. | 54 // Returns number of elements moved. |
54 int WebRtc_MoveReadPtr(RingBuffer* handle, int element_count); | 55 int WebRtc_MoveReadPtr(RingBuffer* handle, int element_count); |
55 | 56 |
56 // Returns number of available elements to read. | 57 // Returns number of available elements to read. |
57 size_t WebRtc_available_read(const RingBuffer* handle); | 58 size_t WebRtc_available_read(const RingBuffer* handle); |
58 | 59 |
59 // Returns number of available elements for write. | 60 // Returns number of available elements for write. |
60 size_t WebRtc_available_write(const RingBuffer* handle); | 61 size_t WebRtc_available_write(const RingBuffer* handle); |
61 | 62 |
62 #ifdef __cplusplus | 63 #ifdef __cplusplus |
63 } | 64 } |
64 #endif | 65 #endif |
65 | 66 |
66 #endif // WEBRTC_COMMON_AUDIO_RING_BUFFER_H_ | 67 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_UTILITY_RING_BUFFER_H_ |
OLD | NEW |