[vlc-devel] [PATCH] omxil: Add a prefix to the iomx function symbols

Martin Storsjö martin at martin.st
Tue Jan 24 08:27:36 CET 2012


On some devices (apparently froyo and earlier), some OMX core
(with sw-only codecs) already is loaded into the process, and
dlsym(RTLD_DEFAULT) can just as well return functions from that
one instead of the ones from the iomx wrapper that we've loaded.

This makes sure we really get the functions we want.
---
 modules/codec/omxil/iomx.cpp |   16 ++++++++++------
 modules/codec/omxil/omxil.c  |    2 +-
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/modules/codec/omxil/iomx.cpp b/modules/codec/omxil/iomx.cpp
index ccc4abb..1316c0b 100644
--- a/modules/codec/omxil/iomx.cpp
+++ b/modules/codec/omxil/iomx.cpp
@@ -29,6 +29,8 @@
 #include <binder/MemoryDealer.h>
 #include <OMX_Component.h>
 
+#define PREFIX(x) I ## x
+
 using namespace android;
 
 class IOMXContext {
@@ -270,7 +272,8 @@ static OMX_ERRORTYPE iomx_set_config(OMX_HANDLETYPE component, OMX_INDEXTYPE ind
     return get_error(ctx->iomx->setConfig(node->node, index, param, sizeof(OMX_BOOL)));
 }
 
-OMX_ERRORTYPE OMX_GetHandle(OMX_HANDLETYPE *handle_ptr, OMX_STRING component_name, OMX_PTR app_data, OMX_CALLBACKTYPE *callbacks)
+extern "C" {
+OMX_ERRORTYPE PREFIX(OMX_GetHandle)(OMX_HANDLETYPE *handle_ptr, OMX_STRING component_name, OMX_PTR app_data, OMX_CALLBACKTYPE *callbacks)
 {
     OMXNode* node = new OMXNode();
     node->app_data = app_data;
@@ -308,7 +311,7 @@ OMX_ERRORTYPE OMX_GetHandle(OMX_HANDLETYPE *handle_ptr, OMX_STRING component_nam
     return OMX_ErrorNone;
 }
 
-OMX_ERRORTYPE OMX_FreeHandle(OMX_HANDLETYPE handle)
+OMX_ERRORTYPE PREFIX(OMX_FreeHandle)(OMX_HANDLETYPE handle)
 {
     OMXNode* node = (OMXNode*) ((OMX_COMPONENTTYPE*)handle)->pComponentPrivate;
     ctx->iomx->freeNode( node->node );
@@ -318,7 +321,7 @@ OMX_ERRORTYPE OMX_FreeHandle(OMX_HANDLETYPE handle)
     return OMX_ErrorNone;
 }
 
-OMX_ERRORTYPE OMX_Init(void)
+OMX_ERRORTYPE PREFIX(OMX_Init)(void)
 {
     OMXClient client;
     if (client.connect() != OK)
@@ -331,7 +334,7 @@ OMX_ERRORTYPE OMX_Init(void)
     return OMX_ErrorNone;
 }
 
-OMX_ERRORTYPE OMX_Deinit(void)
+OMX_ERRORTYPE PREFIX(OMX_Deinit)(void)
 {
     ctx->iomx = NULL;
     delete ctx;
@@ -339,7 +342,7 @@ OMX_ERRORTYPE OMX_Deinit(void)
     return OMX_ErrorNone;
 }
 
-OMX_ERRORTYPE OMX_ComponentNameEnum(OMX_STRING component_name, OMX_U32 name_length, OMX_U32 index)
+OMX_ERRORTYPE PREFIX(OMX_ComponentNameEnum)(OMX_STRING component_name, OMX_U32 name_length, OMX_U32 index)
 {
     if (index >= ctx->components.size())
         return OMX_ErrorNoMore;
@@ -351,7 +354,7 @@ OMX_ERRORTYPE OMX_ComponentNameEnum(OMX_STRING component_name, OMX_U32 name_leng
     return OMX_ErrorNone;
 }
 
-OMX_ERRORTYPE OMX_GetRolesOfComponent(OMX_STRING component_name, OMX_U32 *num_roles, OMX_U8 **roles)
+OMX_ERRORTYPE PREFIX(OMX_GetRolesOfComponent)(OMX_STRING component_name, OMX_U32 *num_roles, OMX_U8 **roles)
 {
     for( List<IOMX::ComponentInfo>::iterator it = ctx->components.begin(); it != ctx->components.end(); it++ ) {
         if (!strcmp(component_name, it->mName.string())) {
@@ -372,4 +375,5 @@ OMX_ERRORTYPE OMX_GetRolesOfComponent(OMX_STRING component_name, OMX_U32 *num_ro
     }
     return OMX_ErrorInvalidComponentName;
 }
+}
 
diff --git a/modules/codec/omxil/omxil.c b/modules/codec/omxil/omxil.c
index ef8982b..3c13a73 100644
--- a/modules/codec/omxil/omxil.c
+++ b/modules/codec/omxil/omxil.c
@@ -33,7 +33,7 @@
 /* On dll_open, just check that the OMX_Init symbol already is loaded */
 # define dll_open(name) dlsym(RTLD_DEFAULT, "OMX_Init")
 # define dll_close(handle) do { } while (0)
-# define dlsym(handle, name) dlsym(RTLD_DEFAULT, name)
+# define dlsym(handle, name) dlsym(RTLD_DEFAULT, "I" name)
 #else
 # define dll_open(name) dlopen( name, RTLD_NOW )
 # define dll_close(handle) dlclose(handle)
-- 
1.7.2.5




More information about the vlc-devel mailing list