Support loading as float or ADPCM in alplay
[openal-soft.git] / core / dbus_wrap.cpp
blob7f2217066ff8b57770efc4c457433333e9b6d1e2
2 #include "config.h"
4 #include "dbus_wrap.h"
6 #ifdef HAVE_DYNLOAD
8 #include <mutex>
9 #include <type_traits>
11 #include "logging.h"
14 void *dbus_handle{nullptr};
15 #define DECL_FUNC(x) decltype(p##x) p##x{};
16 DBUS_FUNCTIONS(DECL_FUNC)
17 #undef DECL_FUNC
19 void PrepareDBus()
21 static constexpr char libname[] = "libdbus-1.so.3";
23 auto load_func = [](auto &f, const char *name) -> void
24 { f = reinterpret_cast<std::remove_reference_t<decltype(f)>>(GetSymbol(dbus_handle, name)); };
25 #define LOAD_FUNC(x) do { \
26 load_func(p##x, #x); \
27 if(!p##x) \
28 { \
29 WARN("Failed to load function %s\n", #x); \
30 CloseLib(dbus_handle); \
31 dbus_handle = nullptr; \
32 return; \
33 } \
34 } while(0);
36 dbus_handle = LoadLib(libname);
37 if(!dbus_handle)
39 WARN("Failed to load %s\n", libname);
40 return;
43 DBUS_FUNCTIONS(LOAD_FUNC)
44 #undef LOAD_FUNC
46 #endif