Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(717)

Side by Side Diff: webrtc/common_audio/ring_buffer.h

Issue 1862513007: Moved struct definition to the header file for the ring buffer. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/common_audio/ring_buffer.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_COMMON_AUDIO_RING_BUFFER_H_
15 #define WEBRTC_COMMON_AUDIO_RING_BUFFER_H_ 15 #define WEBRTC_COMMON_AUDIO_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 enum Wrap { SAME_WRAP, DIFF_WRAP };
24
25 typedef struct RingBuffer {
26 size_t read_pos;
27 size_t write_pos;
28 size_t element_count;
29 size_t element_size;
30 enum Wrap rw_wrap;
31 char* data;
32 } RingBuffer;
24 33
25 // Creates and initializes the buffer. Returns NULL on failure. 34 // Creates and initializes the buffer. Returns NULL on failure.
26 RingBuffer* WebRtc_CreateBuffer(size_t element_count, size_t element_size); 35 RingBuffer* WebRtc_CreateBuffer(size_t element_count, size_t element_size);
27 void WebRtc_InitBuffer(RingBuffer* handle); 36 void WebRtc_InitBuffer(RingBuffer* handle);
28 void WebRtc_FreeBuffer(void* handle); 37 void WebRtc_FreeBuffer(void* handle);
29 38
30 // Reads data from the buffer. The |data_ptr| will point to the address where 39 // Reads data from the buffer. The |data_ptr| will point to the address where
31 // it is located. If all |element_count| data are feasible to read without 40 // it is located. If all |element_count| data are feasible to read without
32 // buffer wrap around |data_ptr| will point to the location in the buffer. 41 // buffer wrap around |data_ptr| will point to the location in the buffer.
33 // Otherwise, the data will be copied to |data| (memory allocation done by the 42 // Otherwise, the data will be copied to |data| (memory allocation done by the
(...skipping 23 matching lines...) Expand all
57 size_t WebRtc_available_read(const RingBuffer* handle); 66 size_t WebRtc_available_read(const RingBuffer* handle);
58 67
59 // Returns number of available elements for write. 68 // Returns number of available elements for write.
60 size_t WebRtc_available_write(const RingBuffer* handle); 69 size_t WebRtc_available_write(const RingBuffer* handle);
61 70
62 #ifdef __cplusplus 71 #ifdef __cplusplus
63 } 72 }
64 #endif 73 #endif
65 74
66 #endif // WEBRTC_COMMON_AUDIO_RING_BUFFER_H_ 75 #endif // WEBRTC_COMMON_AUDIO_RING_BUFFER_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/common_audio/ring_buffer.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698