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

Unified Diff: media/video/capture/linux/video_capture_device_linux.cc

Issue 1008343006: Increase VIDIOC_REQBUFS count from 2 to 4 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: format comments Created 5 years, 9 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/video/capture/linux/video_capture_device_linux.cc
diff --git a/media/video/capture/linux/video_capture_device_linux.cc b/media/video/capture/linux/video_capture_device_linux.cc
index 60d8f77d55cfe0497fe3835cdfe76f6016ff037a..b9fb195f8ae4b0e670b7c482bd3a5245460f35c8 100644
--- a/media/video/capture/linux/video_capture_device_linux.cc
+++ b/media/video/capture/linux/video_capture_device_linux.cc
@@ -28,8 +28,11 @@ namespace media {
#define GET_V4L2_FOURCC_CHAR(a, index) ((char)( ((a) >> (8 * index)) & 0xff))
-// Max number of video buffers VideoCaptureDeviceLinux can allocate.
-const uint32 kMaxVideoBuffers = 2;
+// Desired number of video buffers to allocate. The actual number of allocated
+// buffers by v4l2 driver can be higher or lower than this number.
+// kNumVideoBuffers should not be too small, or Chrome may not return enough
+// buffers back to driver in time.
+const uint32 kNumVideoBuffers = 4;
// Timeout in milliseconds v4l2_thread_ blocks waiting for a frame from the hw.
enum { kCaptureTimeoutMs = 200 };
// The number of continuous timeouts tolerated before treated as error.
@@ -463,13 +466,11 @@ bool VideoCaptureDeviceLinux::V4L2CaptureDelegate::AllocateVideoBuffers() {
v4l2_requestbuffers r_buffer = {};
r_buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
r_buffer.memory = V4L2_MEMORY_MMAP;
- r_buffer.count = kMaxVideoBuffers;
+ r_buffer.count = kNumVideoBuffers;
if (HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_REQBUFS, &r_buffer)) < 0) {
DLOG(ERROR) << "Error requesting MMAP buffers from V4L2";
return false;
}
- DCHECK_EQ(r_buffer.count, kMaxVideoBuffers);
- r_buffer.count = std::min(r_buffer.count, kMaxVideoBuffers);
buffer_pool_size_ = r_buffer.count;
buffer_pool_ = new Buffer[buffer_pool_size_];
for (unsigned int i = 0; i < r_buffer.count; ++i) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698