diff options
author | Chris Robinson <[email protected]> | 2021-08-19 06:11:30 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2021-08-19 06:11:30 -0700 |
commit | 4b030b7e95bd2c721023eabc6696e239064cb654 (patch) | |
tree | 2b2cf5541318ff9a132a0ce217382a9664a52533 /alc/backends/pipewire.cpp | |
parent | ca2e0e4b2b53dc294850180118e1d451348c349c (diff) |
Simplify pwire_load
Diffstat (limited to 'alc/backends/pipewire.cpp')
-rw-r--r-- | alc/backends/pipewire.cpp | 74 |
1 files changed, 35 insertions, 39 deletions
diff --git a/alc/backends/pipewire.cpp b/alc/backends/pipewire.cpp index 45560f9b..efba0216 100644 --- a/alc/backends/pipewire.cpp +++ b/alc/backends/pipewire.cpp @@ -136,6 +136,39 @@ void *pwire_handle; PWIRE_FUNCS(MAKE_FUNC) #undef MAKE_FUNC +bool pwire_load() +{ + if(pwire_handle) + return true; + + static constexpr char pwire_library[] = "libpipewire-0.3.so.0"; + std::string missing_funcs; + + pwire_handle = LoadLib(pwire_library); + if(!pwire_handle) + { + WARN("Failed to load %s\n", pwire_library); + return false; + } + +#define LOAD_FUNC(f) do { \ + p##f = reinterpret_cast<decltype(p##f)>(GetSymbol(pwire_handle, #f)); \ + if(p##f == nullptr) missing_funcs += "\n" #f; \ +} while(0); + PWIRE_FUNCS(LOAD_FUNC) +#undef LOAD_FUNC + + if(!missing_funcs.empty()) + { + WARN("Missing expected functions:%s\n", missing_funcs.c_str()); + CloseLib(pwire_handle); + pwire_handle = nullptr; + return false; + } + + return true; +} + #ifndef IN_IDE_PARSER #define pw_context_connect ppw_context_connect #define pw_context_destroy ppw_context_destroy @@ -167,49 +200,12 @@ PWIRE_FUNCS(MAKE_FUNC) #define pw_thread_loop_unlock ppw_thread_loop_unlock #define pw_thread_loop_wait ppw_thread_loop_wait #endif -#endif +#else -bool pwire_load() -{ - bool error{false}; - -#ifdef HAVE_DYNLOAD - if(!pwire_handle) - { - static constexpr char pwire_library[] = "libpipewire-0.3.so.0"; - std::string missing_funcs; - - pwire_handle = LoadLib(pwire_library); - if(!pwire_handle) - { - WARN("Failed to load %s\n", pwire_library); - return false; - } - - error = false; -#define LOAD_FUNC(f) do { \ - p##f = reinterpret_cast<decltype(p##f)>(GetSymbol(pwire_handle, #f)); \ - if(p##f == nullptr) { \ - error = true; \ - missing_funcs += "\n" #f; \ - } \ -} while(0); - PWIRE_FUNCS(LOAD_FUNC) -#undef LOAD_FUNC - - if(error) - { - WARN("Missing expected functions:%s\n", missing_funcs.c_str()); - CloseLib(pwire_handle); - pwire_handle = nullptr; - } - } +constexpr bool pwire_load() { return true; } #endif - return !error; -} - class ThreadMainloop { pw_thread_loop *mLoop{}; |