diff options
author | Maki <maki@hotmilk.space> | 2024-04-19 02:32:29 -0400 |
---|---|---|
committer | Maki <maki@hotmilk.space> | 2024-04-19 02:32:29 -0400 |
commit | 477b45be1be256b7496e1d45b41754c6e40ef58a (patch) | |
tree | 24dbec258400c592af9fe04e8ba8532a63346448 /indra/media_plugins/base/media_plugin_base.cpp | |
parent | 09b0244f0e623dad43f579c9c7ba42ad0d53ed25 (diff) |
Add toggle for PipeWire volume catcher, and refactoring
Diffstat (limited to 'indra/media_plugins/base/media_plugin_base.cpp')
-rw-r--r-- | indra/media_plugins/base/media_plugin_base.cpp | 51 |
1 files changed, 49 insertions, 2 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 |