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

Side by Side Diff: content/common/gpu/media/tegra_v4l2_video_device.cc

Issue 649533003: C++11 declares a type safe null pointer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed Presubmit errors Created 6 years, 2 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <dlfcn.h> 5 #include <dlfcn.h>
6 #include <fcntl.h> 6 #include <fcntl.h>
7 #include <linux/videodev2.h> 7 #include <linux/videodev2.h>
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 18 matching lines...) Expand all
29 size_t length, 29 size_t length,
30 int prot, 30 int prot,
31 int flags, 31 int flags,
32 int fd, 32 int fd,
33 unsigned int offset); 33 unsigned int offset);
34 typedef int32 (*TegraV4L2Munmap)(void* addr, size_t length); 34 typedef int32 (*TegraV4L2Munmap)(void* addr, size_t length);
35 typedef int32 (*TegraV4L2UseEglImage)(int fd, 35 typedef int32 (*TegraV4L2UseEglImage)(int fd,
36 unsigned int buffer_index, 36 unsigned int buffer_index,
37 void* egl_image); 37 void* egl_image);
38 38
39 #define TEGRAV4L2_SYM(name) TegraV4L2##name TegraV4L2_##name = NULL 39 #define TEGRAV4L2_SYM(name) TegraV4L2##name TegraV4L2_##name = nullptr
40 40
41 TEGRAV4L2_SYM(Open); 41 TEGRAV4L2_SYM(Open);
42 TEGRAV4L2_SYM(Close); 42 TEGRAV4L2_SYM(Close);
43 TEGRAV4L2_SYM(Ioctl); 43 TEGRAV4L2_SYM(Ioctl);
44 TEGRAV4L2_SYM(Poll); 44 TEGRAV4L2_SYM(Poll);
45 TEGRAV4L2_SYM(SetDevicePollInterrupt); 45 TEGRAV4L2_SYM(SetDevicePollInterrupt);
46 TEGRAV4L2_SYM(ClearDevicePollInterrupt); 46 TEGRAV4L2_SYM(ClearDevicePollInterrupt);
47 TEGRAV4L2_SYM(Mmap); 47 TEGRAV4L2_SYM(Mmap);
48 TEGRAV4L2_SYM(Munmap); 48 TEGRAV4L2_SYM(Munmap);
49 TEGRAV4L2_SYM(UseEglImage); 49 TEGRAV4L2_SYM(UseEglImage);
50 50
51 #undef TEGRAV4L2_SYM 51 #undef TEGRAV4L2_SYM
52 52
53 class TegraFunctionSymbolFinder { 53 class TegraFunctionSymbolFinder {
54 public: 54 public:
55 TegraFunctionSymbolFinder() : initialized_(false) { 55 TegraFunctionSymbolFinder() : initialized_(false) {
56 if (!dlopen("/usr/lib/libtegrav4l2.so", 56 if (!dlopen("/usr/lib/libtegrav4l2.so",
57 RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE)) { 57 RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE)) {
58 DLOG(ERROR) << "Failed to load libtegrav4l2.so"; 58 DLOG(ERROR) << "Failed to load libtegrav4l2.so";
59 return; 59 return;
60 } 60 }
61 #define TEGRAV4L2_DLSYM_OR_RETURN_ON_ERROR(name) \ 61 #define TEGRAV4L2_DLSYM_OR_RETURN_ON_ERROR(name) \
62 do { \ 62 do { \
63 TegraV4L2_##name = reinterpret_cast<TegraV4L2##name>( \ 63 TegraV4L2_##name = reinterpret_cast<TegraV4L2##name>( \
64 dlsym(RTLD_DEFAULT, "TegraV4L2_" #name)); \ 64 dlsym(RTLD_DEFAULT, "TegraV4L2_" #name)); \
65 if (TegraV4L2_##name == NULL) { \ 65 if (TegraV4L2_##name == nullptr) { \
66 LOG(ERROR) << "Failed to dlsym TegraV4L2_" #name; \ 66 LOG(ERROR) << "Failed to dlsym TegraV4L2_" #name; \
67 return; \ 67 return; \
68 } \ 68 } \
69 } while (0) 69 } while (0)
70 70
71 TEGRAV4L2_DLSYM_OR_RETURN_ON_ERROR(Open); 71 TEGRAV4L2_DLSYM_OR_RETURN_ON_ERROR(Open);
72 TEGRAV4L2_DLSYM_OR_RETURN_ON_ERROR(Close); 72 TEGRAV4L2_DLSYM_OR_RETURN_ON_ERROR(Close);
73 TEGRAV4L2_DLSYM_OR_RETURN_ON_ERROR(Ioctl); 73 TEGRAV4L2_DLSYM_OR_RETURN_ON_ERROR(Ioctl);
74 TEGRAV4L2_DLSYM_OR_RETURN_ON_ERROR(Poll); 74 TEGRAV4L2_DLSYM_OR_RETURN_ON_ERROR(Poll);
75 TEGRAV4L2_DLSYM_OR_RETURN_ON_ERROR(SetDevicePollInterrupt); 75 TEGRAV4L2_DLSYM_OR_RETURN_ON_ERROR(SetDevicePollInterrupt);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 137
138 bool TegraV4L2Device::ClearDevicePollInterrupt() { 138 bool TegraV4L2Device::ClearDevicePollInterrupt() {
139 if (HANDLE_EINTR(TegraV4L2_ClearDevicePollInterrupt(device_fd_)) == -1) { 139 if (HANDLE_EINTR(TegraV4L2_ClearDevicePollInterrupt(device_fd_)) == -1) {
140 LOG(ERROR) << "Error in calling TegraV4L2ClearDevicePollInterrupt"; 140 LOG(ERROR) << "Error in calling TegraV4L2ClearDevicePollInterrupt";
141 return false; 141 return false;
142 } 142 }
143 return true; 143 return true;
144 } 144 }
145 145
146 bool TegraV4L2Device::Initialize() { 146 bool TegraV4L2Device::Initialize() {
147 const char* device_path = NULL; 147 const char* device_path = nullptr;
148 switch (type_) { 148 switch (type_) {
149 case kDecoder: 149 case kDecoder:
150 device_path = kDecoderDevice; 150 device_path = kDecoderDevice;
151 break; 151 break;
152 case kEncoder: 152 case kEncoder:
153 device_path = kEncoderDevice; 153 device_path = kEncoderDevice;
154 break; 154 break;
155 case kImageProcessor: 155 case kImageProcessor:
156 DVLOG(1) << "Device type " << type_ << " not supported on this platform"; 156 DVLOG(1) << "Device type " << type_ << " not supported on this platform";
157 return false; 157 return false;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 } 211 }
212 212
213 uint32 TegraV4L2Device::PreferredOutputFormat() { 213 uint32 TegraV4L2Device::PreferredOutputFormat() {
214 // TODO(posciak): We should support "dontcare" returns here once we 214 // TODO(posciak): We should support "dontcare" returns here once we
215 // implement proper handling (fallback, negotiation) for this in users. 215 // implement proper handling (fallback, negotiation) for this in users.
216 CHECK_EQ(type_, kDecoder); 216 CHECK_EQ(type_, kDecoder);
217 return V4L2_PIX_FMT_NV12M; 217 return V4L2_PIX_FMT_NV12M;
218 } 218 }
219 219
220 } // namespace content 220 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/media/rendering_helper.cc ('k') | content/common/gpu/media/v4l2_image_processor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698