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

Unified Diff: content/common/gpu/media/generic_v4l2_device.cc

Issue 1093173002: Do not use libv4l if no plugin is registered. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/common/gpu/media/generic_v4l2_device.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/gpu/media/generic_v4l2_device.cc
diff --git a/content/common/gpu/media/generic_v4l2_device.cc b/content/common/gpu/media/generic_v4l2_device.cc
index 67600487cae722cb93d2d16d9dad8e976d3ed5a7..24b92ecd89b7510be02241c56a62b7a1790da27b 100644
--- a/content/common/gpu/media/generic_v4l2_device.cc
+++ b/content/common/gpu/media/generic_v4l2_device.cc
@@ -29,9 +29,6 @@ using content_common_gpu_media::StubPathMap;
static const base::FilePath::CharType kV4l2Lib[] =
FILE_PATH_LITERAL("/usr/lib/libv4l2.so");
-#else
-#define v4l2_close close
-#define v4l2_ioctl ioctl
#endif
namespace content {
@@ -45,7 +42,8 @@ const char kImageProcessorDevice[] = "/dev/gsc0";
GenericV4L2Device::GenericV4L2Device(Type type)
: type_(type),
device_fd_(-1),
- device_poll_interrupt_fd_(-1) {}
+ device_poll_interrupt_fd_(-1),
+ use_libv4l2_(false) {}
GenericV4L2Device::~GenericV4L2Device() {
if (device_poll_interrupt_fd_ != -1) {
@@ -53,13 +51,27 @@ GenericV4L2Device::~GenericV4L2Device() {
device_poll_interrupt_fd_ = -1;
}
if (device_fd_ != -1) {
- v4l2_close(device_fd_);
+ Close();
device_fd_ = -1;
}
}
+void GenericV4L2Device::Close() {
+#if defined(USE_LIBV4L2)
+ if (use_libv4l2_) {
+ v4l2_close(device_fd_);
+ return;
+ }
+#endif
+ close(device_fd_);
Pawel Osciak 2015/04/21 05:02:42 Perhaps this would be a good time to start using b
wuchengli 2015/04/21 06:12:10 Good idea. Done.
+}
+
int GenericV4L2Device::Ioctl(int request, void* arg) {
- return HANDLE_EINTR(v4l2_ioctl(device_fd_, request, arg));
+#if defined(USE_LIBV4L2)
+ if (use_libv4l2_)
+ return HANDLE_EINTR(v4l2_ioctl(device_fd_, request, arg));
+#endif
+ return HANDLE_EINTR(ioctl(device_fd_, request, arg));
}
bool GenericV4L2Device::Poll(bool poll_device, bool* event_pending) {
@@ -153,9 +165,9 @@ bool GenericV4L2Device::Initialize() {
return false;
}
#if defined(USE_LIBV4L2)
- if (HANDLE_EINTR(v4l2_fd_open(device_fd_, V4L2_DISABLE_CONVERSION)) == -1) {
- v4l2_close(device_fd_);
- return false;
+ if (HANDLE_EINTR(v4l2_fd_open(device_fd_, V4L2_DISABLE_CONVERSION)) >= 0) {
Pawel Osciak 2015/04/21 05:02:42 I'd prefer != -1.
wuchengli 2015/04/21 06:12:10 Done. I was confused when I discussed with you. !=
+ DVLOG(2) << "Found a libv4l2 plugin for " << device_path;
Pawel Osciak 2015/04/21 05:02:42 v4l2_fd_open succeeding is not exactly equivalent
wuchengli 2015/04/21 06:12:10 Done.
+ use_libv4l2_ = true;
}
#endif
« no previous file with comments | « content/common/gpu/media/generic_v4l2_device.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698