| 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 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 size_t element_size; | 29 size_t element_size; |
| 30 enum Wrap rw_wrap; | 30 enum Wrap rw_wrap; |
| 31 char* data; | 31 char* data; |
| 32 } RingBuffer; | 32 } RingBuffer; |
| 33 | 33 |
| 34 // Creates and initializes the buffer. Returns null on failure. | 34 // Creates and initializes the buffer. Returns null on failure. |
| 35 RingBuffer* WebRtc_CreateBuffer(size_t element_count, size_t element_size); | 35 RingBuffer* WebRtc_CreateBuffer(size_t element_count, size_t element_size); |
| 36 void WebRtc_InitBuffer(RingBuffer* handle); | 36 void WebRtc_InitBuffer(RingBuffer* handle); |
| 37 void WebRtc_FreeBuffer(void* handle); | 37 void WebRtc_FreeBuffer(void* handle); |
| 38 | 38 |
| 39 // Reads data from the buffer. The |data_ptr| will point to the address where | 39 // Reads data from the buffer. Returns the number of elements that were read. |
| 40 // it is located. If all |element_count| data are feasible to read without | 40 // The |data_ptr| will point to the address where the read data is located. |
| 41 // buffer wrap around |data_ptr| will point to the location in the buffer. | 41 // If no data can be read, |data_ptr| is set to |NULL|. If all data can be read |
| 42 // Otherwise, the data will be copied to |data| (memory allocation done by the | 42 // without buffer wrap around then |data_ptr| will point to the location in the |
| 43 // user) and |data_ptr| points to the address of |data|. |data_ptr| is only | 43 // buffer. Otherwise, the data will be copied to |data| (memory allocation done |
| 44 // guaranteed to be valid until the next call to WebRtc_WriteBuffer(). | 44 // by the user) and |data_ptr| points to the address of |data|. |data_ptr| is |
| 45 // only guaranteed to be valid until the next call to WebRtc_WriteBuffer(). |
| 45 // | 46 // |
| 46 // To force a copying to |data|, pass a null |data_ptr|. | 47 // To force a copying to |data|, pass a null |data_ptr|. |
| 47 // | 48 // |
| 48 // Returns number of elements read. | 49 // Returns number of elements read. |
| 49 size_t WebRtc_ReadBuffer(RingBuffer* handle, | 50 size_t WebRtc_ReadBuffer(RingBuffer* handle, |
| 50 void** data_ptr, | 51 void** data_ptr, |
| 51 void* data, | 52 void* data, |
| 52 size_t element_count); | 53 size_t element_count); |
| 53 | 54 |
| 54 // Writes |data| to buffer and returns the number of elements written. | 55 // Writes |data| to buffer and returns the number of elements written. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 66 size_t WebRtc_available_read(const RingBuffer* handle); | 67 size_t WebRtc_available_read(const RingBuffer* handle); |
| 67 | 68 |
| 68 // Returns number of available elements for write. | 69 // Returns number of available elements for write. |
| 69 size_t WebRtc_available_write(const RingBuffer* handle); | 70 size_t WebRtc_available_write(const RingBuffer* handle); |
| 70 | 71 |
| 71 #ifdef __cplusplus | 72 #ifdef __cplusplus |
| 72 } | 73 } |
| 73 #endif | 74 #endif |
| 74 | 75 |
| 75 #endif // WEBRTC_COMMON_AUDIO_RING_BUFFER_H_ | 76 #endif // WEBRTC_COMMON_AUDIO_RING_BUFFER_H_ |
| OLD | NEW |