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

Unified Diff: media/gpu/tegra_v4l2_device.cc

Issue 2668813002: Remove LazyInstance usage from media/ (Closed)
Patch Set: Fix presubmit comments. Created 3 years, 10 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 | « media/gpu/avda_codec_allocator.cc ('k') | media/gpu/vaapi_wrapper.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..72234560dc6a85e62e2cf9015975ef9a6d358672 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,44 +51,6 @@ 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;
-#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; \
- } \
- } 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);
-#undef TEGRAV4L2_DLSYM
- initialized_ = true;
- }
-
- bool initialized() { return initialized_; }
-
- private:
- bool initialized_;
-};
-
-base::LazyInstance<TegraFunctionSymbolFinder> g_tegra_function_symbol_finder_ =
- LAZY_INSTANCE_INITIALIZER;
-
TegraV4L2Device::TegraV4L2Device() {}
TegraV4L2Device::~TegraV4L2Device() {
@@ -138,7 +99,35 @@ bool TegraV4L2Device::ClearDevicePollInterrupt() {
}
bool TegraV4L2Device::Initialize() {
- return g_tegra_function_symbol_finder_.Get().initialized();
+ static bool initialized = []() {
+ 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 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);
+#undef TEGRAV4L2_DLSYM_OR_RETURN_ON_ERROR
+ return true;
+ }();
+
+ return initialized;
}
bool TegraV4L2Device::Open(Type type, uint32_t /* v4l2_pixfmt */) {
« no previous file with comments | « media/gpu/avda_codec_allocator.cc ('k') | media/gpu/vaapi_wrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698