summaryrefslogtreecommitdiff
path: root/indra/media_plugins/base
diff options
context:
space:
mode:
Diffstat (limited to 'indra/media_plugins/base')
-rw-r--r--indra/media_plugins/base/CMakeLists.txt7
-rw-r--r--indra/media_plugins/base/media_plugin_base.cpp50
-rw-r--r--indra/media_plugins/base/media_plugin_base.h29
3 files changed, 78 insertions, 8 deletions
diff --git a/indra/media_plugins/base/CMakeLists.txt b/indra/media_plugins/base/CMakeLists.txt
index 64b6a4228d..5e635c6ca3 100644
--- a/indra/media_plugins/base/CMakeLists.txt
+++ b/indra/media_plugins/base/CMakeLists.txt
@@ -12,13 +12,6 @@ include(PluginAPI)
### media_plugin_base
-if(NOT ADDRESS_SIZE EQUAL 32)
- if(WINDOWS)
- ##add_definitions(/FIXED:NO)
- else(WINDOWS) # not windows therefore gcc LINUX and DARWIN
- add_definitions(-fPIC)
- endif(WINDOWS)
-endif(NOT ADDRESS_SIZE EQUAL 32)
set(media_plugin_base_SOURCE_FILES
media_plugin_base.cpp
diff --git a/indra/media_plugins/base/media_plugin_base.cpp b/indra/media_plugins/base/media_plugin_base.cpp
index 37c498664a..dbbc973f00 100644
--- a/indra/media_plugins/base/media_plugin_base.cpp
+++ b/indra/media_plugins/base/media_plugin_base.cpp
@@ -167,6 +167,56 @@ void MediaPluginBase::sendStatus()
sendMessage(message);
}
+#if LL_LINUX
+
+size_t SymbolGrabber::registerSymbol( SymbolToGrab aSymbol )
+{
+ gSymbolsToGrab.emplace_back(aSymbol);
+ return gSymbolsToGrab.size();
+}
+
+bool SymbolGrabber::grabSymbols(std::vector< std::string > const &aDSONames)
+{
+ std::cerr << "SYMBOLS: " << gSymbolsToGrab.size() << std::endl;
+
+ if (sSymsGrabbed)
+ return true;
+
+ //attempt to load the shared libraries
+ apr_pool_create(&sSymPADSOMemoryPool, nullptr);
+
+ for( std::vector< std::string >::const_iterator itr = aDSONames.begin(); itr != aDSONames.end(); ++itr )
+ {
+ apr_dso_handle_t *pDSO(NULL);
+ std::string strDSO{ *itr };
+ if( APR_SUCCESS == apr_dso_load( &pDSO, strDSO.c_str(), sSymPADSOMemoryPool ))
+ sLoadedLibraries.push_back( pDSO );
+
+ for( auto i = 0; i < gSymbolsToGrab.size(); ++i )
+ {
+ if( !*gSymbolsToGrab[i].mPPFunc )
+ apr_dso_sym( gSymbolsToGrab[i].mPPFunc, pDSO, gSymbolsToGrab[i].mName );
+ }
+ }
+
+ bool sym_error = false;
+
+ for( auto i = 0; i < gSymbolsToGrab.size(); ++i )
+ {
+ if( gSymbolsToGrab[ i ].mRequired && ! *gSymbolsToGrab[ i ].mPPFunc )
+ sym_error = true;
+ }
+
+ sSymsGrabbed = !sym_error;
+ return sSymsGrabbed;
+}
+
+void SymbolGrabber::ungrabSymbols()
+{
+
+}
+#endif
+
#if LL_WINDOWS
# define LLSYMEXPORT __declspec(dllexport)
diff --git a/indra/media_plugins/base/media_plugin_base.h b/indra/media_plugins/base/media_plugin_base.h
index 38b8226bb3..2e975a5bf2 100644
--- a/indra/media_plugins/base/media_plugin_base.h
+++ b/indra/media_plugins/base/media_plugin_base.h
@@ -32,6 +32,34 @@
#include "llpluginmessage.h"
#include "llpluginmessageclasses.h"
+#if LL_LINUX
+
+struct SymbolToGrab
+{
+ bool mRequired;
+ char const *mName;
+ apr_dso_handle_sym_t *mPPFunc;
+};
+
+class SymbolGrabber
+{
+public:
+ size_t registerSymbol( SymbolToGrab aSymbol );
+ bool grabSymbols(std::vector< std::string > const &aDSONames);
+ void ungrabSymbols();
+
+private:
+ std::vector< SymbolToGrab > gSymbolsToGrab;
+
+ bool sSymsGrabbed = false;
+ apr_pool_t *sSymPADSOMemoryPool = nullptr;
+ std::vector<apr_dso_handle_t *> sLoadedLibraries;
+};
+
+extern SymbolGrabber gSymbolGrabber;
+#define LL_GRAB_SYM(REQUIRED, SYMBOL_NAME, RETURN, ...) RETURN (*ll##SYMBOL_NAME)(__VA_ARGS__) = nullptr; size_t gRegistered##SYMBOL_NAME = gSymbolGrabber.registerSymbol( { REQUIRED, #SYMBOL_NAME , (apr_dso_handle_sym_t*)&ll##SYMBOL_NAME} );
+
+#endif
class MediaPluginBase
{
@@ -46,7 +74,6 @@ public:
static void staticReceiveMessage(const char *message_string, void **user_data);
protected:
-
/** Plugin status. */
typedef enum
{