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

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

Issue 10827173: Only dlopen() OMX/VAAPI libs in the GPU process, and only lazily dlsym() their symbols. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add include_dirs for new gpu_main.cc deps. Created 8 years, 4 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
Index: content/common/gpu/media/omx_video_decode_accelerator.cc
diff --git a/content/common/gpu/media/omx_video_decode_accelerator.cc b/content/common/gpu/media/omx_video_decode_accelerator.cc
index 57fe2fddaa449c5d3bbd2365a24fdb2537a11a5e..de862197752cc2d491d7c388b15a5266ccc374a3 100644
--- a/content/common/gpu/media/omx_video_decode_accelerator.cc
+++ b/content/common/gpu/media/omx_video_decode_accelerator.cc
@@ -21,8 +21,7 @@ typedef std::pair<scoped_ptr<base::SharedMemory>, int32> SharedMemoryAndId;
enum { kNumPictureBuffers = 4 };
-// Open the libOmxCore here for now.
-void* omx_handle = dlopen("libOmxCore.so", RTLD_NOW);
+void* omx_handle = NULL;
typedef OMX_ERRORTYPE (*OMXInit)();
typedef OMX_ERRORTYPE (*OMXGetHandle)(
@@ -31,21 +30,11 @@ typedef OMX_ERRORTYPE (*OMXGetComponentsOfRole)(OMX_STRING, OMX_U32*, OMX_U8**);
typedef OMX_ERRORTYPE (*OMXFreeHandle)(OMX_HANDLETYPE);
typedef OMX_ERRORTYPE (*OMXDeinit)();
-OMXInit omx_init = reinterpret_cast<OMXInit>(dlsym(omx_handle, "OMX_Init"));
-OMXGetHandle omx_gethandle =
- reinterpret_cast<OMXGetHandle>(dlsym(omx_handle, "OMX_GetHandle"));
-OMXGetComponentsOfRole omx_get_components_of_role =
- reinterpret_cast<OMXGetComponentsOfRole>(
- dlsym(omx_handle, "OMX_GetComponentsOfRole"));
-OMXFreeHandle omx_free_handle =
- reinterpret_cast<OMXFreeHandle>(dlsym(omx_handle, "OMX_FreeHandle"));
-OMXDeinit omx_deinit =
- reinterpret_cast<OMXDeinit>(dlsym(omx_handle, "OMX_Deinit"));
-
-static bool AreOMXFunctionPointersInitialized() {
- return (omx_init && omx_gethandle && omx_get_components_of_role &&
- omx_free_handle && omx_deinit);
-}
+OMXInit omx_init = NULL;
+OMXGetHandle omx_gethandle = NULL;
+OMXGetComponentsOfRole omx_get_components_of_role = NULL;
+OMXFreeHandle omx_free_handle = NULL;
+OMXDeinit omx_deinit = NULL;
// Maps h264-related Profile enum values to OMX_VIDEO_AVCPROFILETYPE values.
static OMX_U32 MapH264ProfileToOMXAVCProfile(uint32 profile) {
@@ -97,6 +86,9 @@ static OMX_U32 MapH264ProfileToOMXAVCProfile(uint32 profile) {
log << ", OMX result: 0x" << std::hex << omx_result, \
error, ret_val)
+// static
+bool OmxVideoDecodeAccelerator::pre_sandbox_init_done_ = false;
+
OmxVideoDecodeAccelerator::OmxVideoDecodeAccelerator(
EGLDisplay egl_display, EGLContext egl_context,
media::VideoDecodeAccelerator::Client* client)
@@ -118,7 +110,8 @@ OmxVideoDecodeAccelerator::OmxVideoDecodeAccelerator(
codec_(UNKNOWN),
h264_profile_(OMX_VIDEO_AVCProfileMax),
component_name_is_nvidia_h264ext_(false) {
- RETURN_ON_FAILURE(AreOMXFunctionPointersInitialized(),
+ static bool omx_functions_initialized = PostSandboxInitialization();
+ RETURN_ON_FAILURE(omx_functions_initialized,
"Failed to load openmax library", PLATFORM_FAILURE,);
RETURN_ON_OMX_FAILURE(omx_init(), "Failed to init OpenMAX core",
PLATFORM_FAILURE,);
@@ -994,6 +987,32 @@ void OmxVideoDecodeAccelerator::EventHandlerCompleteTask(OMX_EVENTTYPE event,
}
// static
+void OmxVideoDecodeAccelerator::PreSandboxInitialization() {
+ DCHECK(!pre_sandbox_init_done_);
+ omx_handle = dlopen("libOmxCore.so", RTLD_NOW);
+ pre_sandbox_init_done_ = omx_handle != NULL;
+}
+
+// static
+bool OmxVideoDecodeAccelerator::PostSandboxInitialization() {
+ if (!pre_sandbox_init_done_)
+ return false;
+
+ omx_init = reinterpret_cast<OMXInit>(dlsym(omx_handle, "OMX_Init"));
+ omx_gethandle =
+ reinterpret_cast<OMXGetHandle>(dlsym(omx_handle, "OMX_GetHandle"));
+ omx_get_components_of_role =
+ reinterpret_cast<OMXGetComponentsOfRole>(
+ dlsym(omx_handle, "OMX_GetComponentsOfRole"));
+ omx_free_handle =
+ reinterpret_cast<OMXFreeHandle>(dlsym(omx_handle, "OMX_FreeHandle"));
+ omx_deinit =
+ reinterpret_cast<OMXDeinit>(dlsym(omx_handle, "OMX_Deinit"));
+ return (omx_init && omx_gethandle && omx_get_components_of_role &&
+ omx_free_handle && omx_deinit);
+}
+
+// static
OMX_ERRORTYPE OmxVideoDecodeAccelerator::EventHandler(OMX_HANDLETYPE component,
OMX_PTR priv_data,
OMX_EVENTTYPE event,
« no previous file with comments | « content/common/gpu/media/omx_video_decode_accelerator.h ('k') | content/common/gpu/media/vaapi_h264_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698