Chromium Code Reviews| Index: media/gpu/tegra_v4l2_device.cc |
| diff --git a/media/gpu/tegra_v4l2_device.cc b/media/gpu/tegra_v4l2_device.cc |
| index b66534a2a42d43582581703e1e1a865c19e3cd31..49bc904d62aa7e68a16d414ecda219a1a0e2be8c 100644 |
| --- a/media/gpu/tegra_v4l2_device.cc |
| +++ b/media/gpu/tegra_v4l2_device.cc |
| @@ -6,7 +6,6 @@ |
| #include <fcntl.h> |
| #include <linux/videodev2.h> |
| -#include "base/lazy_instance.h" |
| #include "base/posix/eintr_wrapper.h" |
| #include "base/trace_event/trace_event.h" |
| #include "media/gpu/tegra_v4l2_device.h" |
| @@ -52,43 +51,33 @@ TEGRAV4L2_SYM(UseEglImage); |
| #undef TEGRAV4L2_SYM |
| -class TegraFunctionSymbolFinder { |
| - public: |
| - TegraFunctionSymbolFinder() : initialized_(false) { |
| - if (!dlopen("/usr/lib/libtegrav4l2.so", |
| - RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE)) |
| - return; |
| +bool InitializeTegraFunctionSymbolFinder() { |
|
Mark Mentovai
2017/01/31 21:33:56
This should be marked “static”, in an unnamed name
DaleCurtis
2017/01/31 22:04:33
Inlined.
|
| + if (!dlopen("/usr/lib/libtegrav4l2.so", |
| + RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE)) { |
| + return false; |
| + } |
| #define TEGRAV4L2_DLSYM_OR_RETURN_ON_ERROR(name) \ |
| do { \ |
| TegraV4L2_##name = reinterpret_cast<TegraV4L2##name>( \ |
| dlsym(RTLD_DEFAULT, "TegraV4L2_" #name)); \ |
| if (TegraV4L2_##name == NULL) { \ |
| LOG(ERROR) << "Failed to dlsym TegraV4L2_" #name; \ |
| - return; \ |
| + return false; \ |
| } \ |
| } while (0) |
| - TEGRAV4L2_DLSYM_OR_RETURN_ON_ERROR(Open); |
| - TEGRAV4L2_DLSYM_OR_RETURN_ON_ERROR(Close); |
| - TEGRAV4L2_DLSYM_OR_RETURN_ON_ERROR(Ioctl); |
| - TEGRAV4L2_DLSYM_OR_RETURN_ON_ERROR(Poll); |
| - TEGRAV4L2_DLSYM_OR_RETURN_ON_ERROR(SetDevicePollInterrupt); |
| - TEGRAV4L2_DLSYM_OR_RETURN_ON_ERROR(ClearDevicePollInterrupt); |
| - TEGRAV4L2_DLSYM_OR_RETURN_ON_ERROR(Mmap); |
| - TEGRAV4L2_DLSYM_OR_RETURN_ON_ERROR(Munmap); |
| - TEGRAV4L2_DLSYM_OR_RETURN_ON_ERROR(UseEglImage); |
| + TEGRAV4L2_DLSYM_OR_RETURN_ON_ERROR(Open); |
| + TEGRAV4L2_DLSYM_OR_RETURN_ON_ERROR(Close); |
| + TEGRAV4L2_DLSYM_OR_RETURN_ON_ERROR(Ioctl); |
| + TEGRAV4L2_DLSYM_OR_RETURN_ON_ERROR(Poll); |
| + TEGRAV4L2_DLSYM_OR_RETURN_ON_ERROR(SetDevicePollInterrupt); |
| + TEGRAV4L2_DLSYM_OR_RETURN_ON_ERROR(ClearDevicePollInterrupt); |
| + TEGRAV4L2_DLSYM_OR_RETURN_ON_ERROR(Mmap); |
| + TEGRAV4L2_DLSYM_OR_RETURN_ON_ERROR(Munmap); |
| + TEGRAV4L2_DLSYM_OR_RETURN_ON_ERROR(UseEglImage); |
| #undef TEGRAV4L2_DLSYM |
|
Mark Mentovai
2017/01/31 21:33:56
This was never #defined, I think it means TEGRAV4L
DaleCurtis
2017/01/31 22:04:33
Good catch, fixed.
|
| - initialized_ = true; |
| - } |
| - |
| - bool initialized() { return initialized_; } |
| - |
| - private: |
| - bool initialized_; |
| -}; |
| - |
| -base::LazyInstance<TegraFunctionSymbolFinder> g_tegra_function_symbol_finder_ = |
| - LAZY_INSTANCE_INITIALIZER; |
| + return true; |
| +} |
| TegraV4L2Device::TegraV4L2Device() {} |
| @@ -138,7 +127,8 @@ bool TegraV4L2Device::ClearDevicePollInterrupt() { |
| } |
| bool TegraV4L2Device::Initialize() { |
| - return g_tegra_function_symbol_finder_.Get().initialized(); |
| + static bool initialized = InitializeTegraFunctionSymbolFinder(); |
|
Mark Mentovai
2017/01/31 21:33:56
…written in-line here in a lambda.
DaleCurtis
2017/01/31 22:04:33
:)
|
| + return initialized; |
| } |
| bool TegraV4L2Device::Open(Type type, uint32_t /* v4l2_pixfmt */) { |