summaryrefslogtreecommitdiff
path: root/indra/media_plugins/base
diff options
context:
space:
mode:
authorMaki <maki@hotmilk.space>2024-04-19 02:32:29 -0400
committerMaki <maki@hotmilk.space>2024-04-19 02:32:29 -0400
commit477b45be1be256b7496e1d45b41754c6e40ef58a (patch)
tree24dbec258400c592af9fe04e8ba8532a63346448 /indra/media_plugins/base
parent09b0244f0e623dad43f579c9c7ba42ad0d53ed25 (diff)
Add toggle for PipeWire volume catcher, and refactoring
Diffstat (limited to 'indra/media_plugins/base')
-rw-r--r--indra/media_plugins/base/media_plugin_base.cpp51
-rw-r--r--indra/media_plugins/base/media_plugin_base.h18
2 files changed, 64 insertions, 5 deletions
diff --git a/indra/media_plugins/base/media_plugin_base.cpp b/indra/media_plugins/base/media_plugin_base.cpp
index dbbc973f00..3514ff428f 100644
--- a/indra/media_plugins/base/media_plugin_base.cpp
+++ b/indra/media_plugins/base/media_plugin_base.cpp
@@ -183,13 +183,13 @@ bool SymbolGrabber::grabSymbols(std::vector< std::string > const &aDSONames)
return true;
//attempt to load the shared libraries
- apr_pool_create(&sSymPADSOMemoryPool, nullptr);
+ apr_pool_create(&sSymDSOMemoryPool, 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 ))
+ if( APR_SUCCESS == apr_dso_load( &pDSO, strDSO.c_str(), sSymDSOMemoryPool ))
sLoadedLibraries.push_back( pDSO );
for( auto i = 0; i < gSymbolsToGrab.size(); ++i )
@@ -254,3 +254,50 @@ int WINAPI DllEntryPoint( HINSTANCE hInstance, unsigned long reason, void* param
return 1;
}
#endif
+
+#if LL_LINUX
+pid_t getParentPid( pid_t aPid )
+{
+ std::stringstream strm;
+ strm << "/proc/" << aPid << "/status";
+ std::ifstream in{ strm.str() };
+
+ if( !in.is_open() )
+ return 0;
+
+ pid_t res {0};
+ while( !in.eof() && res == 0 )
+ {
+ std::string line;
+ line.resize( 1024, 0 );
+ in.getline( &line[0], line.length() );
+
+ auto i = line.find( "PPid:" );
+
+ if( i == std::string::npos )
+ continue;
+
+ char const *pIn = line.c_str() + 5; // Skip over pid;
+ while( *pIn != 0 && isspace( *pIn ) )
+ ++pIn;
+
+ if( *pIn )
+ res = atoll( pIn );
+ }
+ return res;
+}
+
+bool isPluginPid( pid_t aPid )
+{
+ auto myPid = getpid();
+
+ do
+ {
+ if( aPid == myPid )
+ return true;
+ aPid = getParentPid( aPid );
+ } while( aPid > 1 );
+
+ return false;
+}
+#endif \ No newline at end of file
diff --git a/indra/media_plugins/base/media_plugin_base.h b/indra/media_plugins/base/media_plugin_base.h
index 2e975a5bf2..571dd3bd1b 100644
--- a/indra/media_plugins/base/media_plugin_base.h
+++ b/indra/media_plugins/base/media_plugin_base.h
@@ -52,12 +52,21 @@ private:
std::vector< SymbolToGrab > gSymbolsToGrab;
bool sSymsGrabbed = false;
- apr_pool_t *sSymPADSOMemoryPool = nullptr;
+ apr_pool_t *sSymDSOMemoryPool = 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} );
+
+// extern SymbolGrabber gSymbolGrabber;
+
+#define LL_SYMBOL_GRABBER gSymbolGrabber
+
+#define LL_GRAB_SYM(REQUIRED, SYMBOL_NAME, RETURN, ...) \
+ RETURN (*ll##SYMBOL_NAME)(__VA_ARGS__) = nullptr; \
+ size_t gRegistered##SYMBOL_NAME = LL_SYMBOL_GRABBER.registerSymbol( \
+ { REQUIRED, #SYMBOL_NAME , (apr_dso_handle_sym_t*)&ll##SYMBOL_NAME} \
+ );
#endif
@@ -153,4 +162,7 @@ int init_media_plugin(
LLPluginInstance::sendMessageFunction *plugin_send_func,
void **plugin_user_data);
-
+#if LL_LINUX
+pid_t getParentPid(pid_t aPid);
+bool isPluginPid(pid_t aPid);
+#endif \ No newline at end of file