Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(767)

Unified Diff: webrtc/common_video/include/i420_buffer_pool.h

Issue 2474783005: Replace Check for too many pending frames in I420_buffer_pool with returning nullptr. Added histogr… (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
« no previous file with comments | « webrtc/common_video/i420_buffer_pool_unittest.cc ('k') | webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698