Chromium Code Reviews| Index: webrtc/common_video/include/i420_buffer_pool.h |
| diff --git a/webrtc/common_video/include/i420_buffer_pool.h b/webrtc/common_video/include/i420_buffer_pool.h |
| index 6359c21c8fc0a6f8ce8445d29c29977c0f59204f..53950945c2b1850dceeb3b85f528cd72cbb8db79 100644 |
| --- a/webrtc/common_video/include/i420_buffer_pool.h |
| +++ b/webrtc/common_video/include/i420_buffer_pool.h |
| @@ -12,6 +12,7 @@ |
| #define WEBRTC_COMMON_VIDEO_INCLUDE_I420_BUFFER_POOL_H_ |
| #include <list> |
| +#include <limits> |
| #include "webrtc/base/race_checker.h" |
| #include "webrtc/common_video/include/video_frame_buffer.h" |
| @@ -27,18 +28,21 @@ namespace webrtc { |
| // are created. This is to prevent memory leaks where frames are not returned. |
| class I420BufferPool { |
| public: |
| - I420BufferPool() : I420BufferPool(false) {} |
| - explicit I420BufferPool(bool zero_initialize); |
| + I420BufferPool() |
| + : I420BufferPool(false, std::numeric_limits<size_t>::max()) {} |
|
magjed_webrtc
2016/11/04 08:21:36
nit: this is enough: I420BufferPool(false) {}
|
| + explicit I420BufferPool(bool zero_initialize) |
| + : I420BufferPool(zero_initialize, std::numeric_limits<size_t>::max()) {} |
| + I420BufferPool(bool zero_initialze, size_t max_number_of_buffers); |
| - // Returns a buffer from the pool, or creates a new buffer if no suitable |
| - // buffer exists in the pool. |
| + // Returns a buffer from the pool. If no suitable buffer exist in the pool |
| + // and there are less than |max_number_of_buffers| pending, a buffer is |
| + // created. Returns null otherwise. |
| rtc::scoped_refptr<I420Buffer> CreateBuffer(int width, int height); |
| // Clears buffers_ and detaches the thread checker so that it can be reused |
| // later from another thread. |
| void Release(); |
| private: |
| - static const size_t kMaxNumberOfFramesBeforeCrash; |
| // Explicitly use a RefCountedObject to get access to HasOneRef, |
| // needed by the pool to check exclusive access. |
| using PooledI420Buffer = rtc::RefCountedObject<I420Buffer>; |
| @@ -51,6 +55,8 @@ class I420BufferPool { |
| // initial allocation (as shown by FFmpeg's own buffer allocation code). It |
| // has to do with "Use-of-uninitialized-value" on "Linux_msan_chrome". |
| bool zero_initialize_; |
| + // Max number of buffers this pool can have pending. |
| + size_t max_number_of_buffers_; |
|
magjed_webrtc
2016/11/04 08:21:36
It would be nice to have this (and zero_initialize
|
| }; |
| } // namespace webrtc |