diff options
| author | Andrey Lihatskiy <alihatskiy@productengine.com> | 2024-06-04 19:38:30 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-04 19:38:30 +0300 |
| commit | 2bf01f80edc28ec998cab0adf3b20e9e7f7f0c4e (patch) | |
| tree | 359f25aa46d16b04ce679deeda959cc5654aeb59 /indra/media_plugins/base/media_plugin_base.cpp | |
| parent | 854bed5c171c75c97df7e58286f2350879e5c0be (diff) | |
| parent | f649f7ab2308047dc4a8ca3cbc331aed957543ff (diff) | |
Merge pull request #1265 from makidoll/pipewire-linux-volume-catcher
Add PipeWire as option for Linux volume catcher
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 3c603440df..b21f29ac32 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 |
