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

Side by Side Diff: media/video/capture/linux/video_capture_device_linux.cc

Issue 14265002: Linux video capture, invoking mmap() with both READ and WRITE. (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/video/capture/linux/video_capture_device_linux.h" 5 #include "media/video/capture/linux/video_capture_device_linux.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #if defined(OS_OPENBSD) 9 #if defined(OS_OPENBSD)
10 #include <sys/videoio.h> 10 #include <sys/videoio.h>
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 v4l2_buffer buffer; 461 v4l2_buffer buffer;
462 memset(&buffer, 0, sizeof(buffer)); 462 memset(&buffer, 0, sizeof(buffer));
463 buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 463 buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
464 buffer.memory = V4L2_MEMORY_MMAP; 464 buffer.memory = V4L2_MEMORY_MMAP;
465 buffer.index = i; 465 buffer.index = i;
466 466
467 if (ioctl(device_fd_, VIDIOC_QUERYBUF, &buffer) < 0) { 467 if (ioctl(device_fd_, VIDIOC_QUERYBUF, &buffer) < 0) {
468 return false; 468 return false;
469 } 469 }
470 470
471 buffer_pool_[i].start = mmap(NULL, buffer.length, PROT_READ, 471 // Some devices require mmap() to be called with both READ and WRITE.
472 // See crbug.com/178582.
473 buffer_pool_[i].start = mmap(NULL, buffer.length, PROT_READ | PROT_WRITE,
472 MAP_SHARED, device_fd_, buffer.m.offset); 474 MAP_SHARED, device_fd_, buffer.m.offset);
473 if (buffer_pool_[i].start == MAP_FAILED) { 475 if (buffer_pool_[i].start == MAP_FAILED) {
474 return false; 476 return false;
475 } 477 }
476 buffer_pool_[i].length = buffer.length; 478 buffer_pool_[i].length = buffer.length;
477 // Enqueue the buffer in the drivers incoming queue. 479 // Enqueue the buffer in the drivers incoming queue.
478 if (ioctl(device_fd_, VIDIOC_QBUF, &buffer) < 0) { 480 if (ioctl(device_fd_, VIDIOC_QBUF, &buffer) < 0) {
479 return false; 481 return false;
480 } 482 }
481 } 483 }
(...skipping 23 matching lines...) Expand all
505 buffer_pool_size_ = 0; 507 buffer_pool_size_ = 0;
506 } 508 }
507 509
508 void VideoCaptureDeviceLinux::SetErrorState(const std::string& reason) { 510 void VideoCaptureDeviceLinux::SetErrorState(const std::string& reason) {
509 DVLOG(1) << reason; 511 DVLOG(1) << reason;
510 state_ = kError; 512 state_ = kError;
511 observer_->OnError(); 513 observer_->OnError();
512 } 514 }
513 515
514 } // namespace media 516 } // namespace media
OLDNEW
« 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