| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 // |this| will be passed as |user_priv| to VpxGetFrameBuffer. | 46 // |this| will be passed as |user_priv| to VpxGetFrameBuffer. |
| 47 this)) { | 47 this)) { |
| 48 // Failed to configure libvpx to use Vp9FrameBufferPool. | 48 // Failed to configure libvpx to use Vp9FrameBufferPool. |
| 49 return false; | 49 return false; |
| 50 } | 50 } |
| 51 return true; | 51 return true; |
| 52 } | 52 } |
| 53 | 53 |
| 54 rtc::scoped_refptr<Vp9FrameBufferPool::Vp9FrameBuffer> | 54 rtc::scoped_refptr<Vp9FrameBufferPool::Vp9FrameBuffer> |
| 55 Vp9FrameBufferPool::GetFrameBuffer(size_t min_size) { | 55 Vp9FrameBufferPool::GetFrameBuffer(size_t min_size) { |
| 56 RTC_DCHECK_GT(min_size, 0u); | 56 RTC_DCHECK_GT(min_size, 0); |
| 57 rtc::scoped_refptr<Vp9FrameBuffer> available_buffer = nullptr; | 57 rtc::scoped_refptr<Vp9FrameBuffer> available_buffer = nullptr; |
| 58 { | 58 { |
| 59 rtc::CritScope cs(&buffers_lock_); | 59 rtc::CritScope cs(&buffers_lock_); |
| 60 // Do we have a buffer we can recycle? | 60 // Do we have a buffer we can recycle? |
| 61 for (const auto& buffer : allocated_buffers_) { | 61 for (const auto& buffer : allocated_buffers_) { |
| 62 if (buffer->HasOneRef()) { | 62 if (buffer->HasOneRef()) { |
| 63 available_buffer = buffer; | 63 available_buffer = buffer; |
| 64 break; | 64 break; |
| 65 } | 65 } |
| 66 } | 66 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 buffer->Release(); | 130 buffer->Release(); |
| 131 // When libvpx fails to decode and you continue to try to decode (and fail) | 131 // When libvpx fails to decode and you continue to try to decode (and fail) |
| 132 // libvpx can for some reason try to release the same buffer multiple times. | 132 // libvpx can for some reason try to release the same buffer multiple times. |
| 133 // Setting |priv| to null protects against trying to Release multiple times. | 133 // Setting |priv| to null protects against trying to Release multiple times. |
| 134 fb->priv = nullptr; | 134 fb->priv = nullptr; |
| 135 } | 135 } |
| 136 return 0; | 136 return 0; |
| 137 } | 137 } |
| 138 | 138 |
| 139 } // namespace webrtc | 139 } // namespace webrtc |
| OLD | NEW |