-
-#define UNLOAD_POLL_TIME 2
-
-/* lt_dlsym() violates ISO C, so confide the breakage into this function to
- * avoid warnings. */
-typedef void (*fnptr)(void);
-static inline fnptr lt_dlsym_fn(lt_dlhandle handle, const char *symbol) {
- return (fnptr) (long) lt_dlsym(handle, symbol);
-}
-
-static void timeout_callback(pa_mainloop_api *m, pa_time_event*e, PA_GCC_UNUSED const struct timeval *tv, void *userdata) {
- pa_core *c = userdata;
- struct timeval ntv;
- assert(c && c->mainloop == m && c->module_auto_unload_event == e);
-
- pa_module_unload_unused(c);
-
- pa_gettimeofday(&ntv);
- ntv.tv_sec += UNLOAD_POLL_TIME;
- m->time_restart(e, &ntv);
-}
-
-static inline fnptr load_sym(lt_dlhandle handle, const char *module, const char *symbol) {
- char *buffer, *ch;
- size_t buflen;
- fnptr res;
-
- res = lt_dlsym_fn(handle, symbol);
- if (res)
- return res;
-
- /* As the .la files might have been cleansed from the system, we should
- * try with the ltdl prefix as well. */
-
- buflen = strlen(symbol) + strlen(module) + strlen("_LTX_") + 1;
- buffer = pa_xmalloc(buflen);
- assert(buffer);
-
- strcpy(buffer, module);
-
- for (ch = buffer;*ch != '\0';ch++) {
- if (!isalnum(*ch))
- *ch = '_';
- }
-
- strcat(buffer, "_LTX_");
- strcat(buffer, symbol);
-
- res = lt_dlsym_fn(handle, buffer);
-
- pa_xfree(buffer);
-
- return res;
-}