| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2015 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 14 matching lines...) Expand all Loading... |
| 25 for (Buffer* buffer : free_list_) { | 25 for (Buffer* buffer : free_list_) { |
| 26 delete buffer; | 26 delete buffer; |
| 27 } | 27 } |
| 28 } | 28 } |
| 29 | 29 |
| 30 size_t BufferQueue::size() const { | 30 size_t BufferQueue::size() const { |
| 31 CritScope cs(&crit_); | 31 CritScope cs(&crit_); |
| 32 return queue_.size(); | 32 return queue_.size(); |
| 33 } | 33 } |
| 34 | 34 |
| 35 void BufferQueue::Clear() { |
| 36 CritScope cs(&crit_); |
| 37 while (!queue_.empty()) { |
| 38 free_list_.push_back(queue_.front()); |
| 39 queue_.pop_front(); |
| 40 } |
| 41 } |
| 42 |
| 35 bool BufferQueue::ReadFront(void* buffer, size_t bytes, size_t* bytes_read) { | 43 bool BufferQueue::ReadFront(void* buffer, size_t bytes, size_t* bytes_read) { |
| 36 CritScope cs(&crit_); | 44 CritScope cs(&crit_); |
| 37 if (queue_.empty()) { | 45 if (queue_.empty()) { |
| 38 return false; | 46 return false; |
| 39 } | 47 } |
| 40 | 48 |
| 41 bool was_writable = queue_.size() < capacity_; | 49 bool was_writable = queue_.size() < capacity_; |
| 42 Buffer* packet = queue_.front(); | 50 Buffer* packet = queue_.front(); |
| 43 queue_.pop_front(); | 51 queue_.pop_front(); |
| 44 | 52 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 75 *bytes_written = bytes; | 83 *bytes_written = bytes; |
| 76 } | 84 } |
| 77 queue_.push_back(packet); | 85 queue_.push_back(packet); |
| 78 if (!was_readable) { | 86 if (!was_readable) { |
| 79 NotifyReadableForTest(); | 87 NotifyReadableForTest(); |
| 80 } | 88 } |
| 81 return true; | 89 return true; |
| 82 } | 90 } |
| 83 | 91 |
| 84 } // namespace rtc | 92 } // namespace rtc |
| OLD | NEW |