OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |