| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 void* buf_ptr_1 = NULL; | 111 void* buf_ptr_1 = NULL; |
| 112 void* buf_ptr_2 = NULL; | 112 void* buf_ptr_2 = NULL; |
| 113 size_t buf_ptr_bytes_1 = 0; | 113 size_t buf_ptr_bytes_1 = 0; |
| 114 size_t buf_ptr_bytes_2 = 0; | 114 size_t buf_ptr_bytes_2 = 0; |
| 115 const size_t read_count = GetBufferReadRegions(self, | 115 const size_t read_count = GetBufferReadRegions(self, |
| 116 element_count, | 116 element_count, |
| 117 &buf_ptr_1, | 117 &buf_ptr_1, |
| 118 &buf_ptr_bytes_1, | 118 &buf_ptr_bytes_1, |
| 119 &buf_ptr_2, | 119 &buf_ptr_2, |
| 120 &buf_ptr_bytes_2); | 120 &buf_ptr_bytes_2); |
| 121 | |
| 122 if (buf_ptr_bytes_2 > 0) { | 121 if (buf_ptr_bytes_2 > 0) { |
| 123 // We have a wrap around when reading the buffer. Copy the buffer data to | 122 // We have a wrap around when reading the buffer. Copy the buffer data to |
| 124 // |data| and point to it. | 123 // |data| and point to it. |
| 125 memcpy(data, buf_ptr_1, buf_ptr_bytes_1); | 124 memcpy(data, buf_ptr_1, buf_ptr_bytes_1); |
| 126 memcpy(((char*) data) + buf_ptr_bytes_1, buf_ptr_2, buf_ptr_bytes_2); | 125 memcpy(((char*) data) + buf_ptr_bytes_1, buf_ptr_2, buf_ptr_bytes_2); |
| 127 buf_ptr_1 = data; | 126 buf_ptr_1 = data; |
| 128 } else if (!data_ptr) { | 127 } else if (!data_ptr) { |
| 129 // No wrap, but a memcpy was requested. | 128 // No wrap, but a memcpy was requested. |
| 130 memcpy(data, buf_ptr_1, buf_ptr_bytes_1); | 129 memcpy(data, buf_ptr_1, buf_ptr_bytes_1); |
| 131 } | 130 } |
| 132 if (data_ptr) { | 131 if (data_ptr) { |
| 133 // |buf_ptr_1| == |data| in the case of a wrap. | 132 // |buf_ptr_1| == |data| in the case of a wrap. |
| 134 *data_ptr = buf_ptr_1; | 133 *data_ptr = read_count == 0 ? NULL : buf_ptr_1; |
| 135 } | 134 } |
| 136 | 135 |
| 137 // Update read position | 136 // Update read position |
| 138 WebRtc_MoveReadPtr(self, (int) read_count); | 137 WebRtc_MoveReadPtr(self, (int) read_count); |
| 139 | 138 |
| 140 return read_count; | 139 return read_count; |
| 141 } | 140 } |
| 142 } | 141 } |
| 143 | 142 |
| 144 size_t WebRtc_WriteBuffer(RingBuffer* self, | 143 size_t WebRtc_WriteBuffer(RingBuffer* self, |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 } | 223 } |
| 225 } | 224 } |
| 226 | 225 |
| 227 size_t WebRtc_available_write(const RingBuffer* self) { | 226 size_t WebRtc_available_write(const RingBuffer* self) { |
| 228 if (!self) { | 227 if (!self) { |
| 229 return 0; | 228 return 0; |
| 230 } | 229 } |
| 231 | 230 |
| 232 return self->element_count - WebRtc_available_read(self); | 231 return self->element_count - WebRtc_available_read(self); |
| 233 } | 232 } |
| OLD | NEW |