diff --git a/alsapid/lib.c b/alsapid/lib.c index 4552f684..802f13fe 100644 --- a/alsapid/lib.c +++ b/alsapid/lib.c @@ -2,7 +2,7 @@ /* * LADI Session Handler (ladish) * - * Copyright (C) 2010 Nedko Arnaudov + * Copyright (C) 2010, 2011 Nedko Arnaudov * ************************************************************************** * This file contains implementation of the libasound LD_PRELOAD-ed alsapid library @@ -76,23 +76,15 @@ static int (* real_snd_seq_close)(snd_seq_t * handle); //static int (* real_snd_seq_create_port)(snd_seq_t * handle, snd_seq_port_info_t * info); //static int (* real_snd_seq_create_simple_port)(snd_seq_t * seq, const char * name, unsigned int caps, unsigned int type); -static void __attribute__ ((constructor)) init(void); - -/* Library constructor */ -void init(void) -{ -// real_snd_seq_open = dlvsym(RTLD_NEXT, "snd_seq_open", API_VERSION); - real_snd_seq_set_client_name = dlvsym(RTLD_NEXT, "snd_seq_set_client_name", API_VERSION); - real_snd_seq_close = dlvsym(RTLD_NEXT, "snd_seq_close", API_VERSION); -// real_snd_seq_create_port = dlvsym(RTLD_NEXT, "snd_seq_create_port", API_VERSION); -// real_snd_seq_create_simple_port = dlvsym(RTLD_NEXT, "snd_seq_create_simple_port", API_VERSION); -} - #define CHECK_FUNC(func) \ if (real_ ## func == NULL) \ { \ - fprintf(stderr, "dlvsym(\"" #func "\", \""API_VERSION"\") failed.\n"); \ - return -1; \ + real_ ## func = dlvsym(RTLD_NEXT, #func, API_VERSION); \ + if (real_ ## func == NULL) \ + { \ + fprintf(stderr, "dlvsym(\""#func"\", \""API_VERSION"\") failed. %s\n", dlerror()); \ + return -1; \ + } \ } #if 0 diff --git a/daemon/loader.c b/daemon/loader.c index c869d991..f7e11831 100644 --- a/daemon/loader.c +++ b/daemon/loader.c @@ -484,6 +484,8 @@ loader_run(void) loader_childs_bury(); } +#define LD_PRELOAD_ADD "libalsapid.so libasound.so" + static void set_ldpreload(void) { const char * old; @@ -492,7 +494,7 @@ static void set_ldpreload(void) old = getenv("LD_PRELOAD"); if (old != NULL) { - new = catdup3("libalsapid.so", " ", old); + new = catdup3(LD_PRELOAD_ADD, " ", old); if (new == NULL) { fprintf(stderr, "Memory allocation failure. Cannot hook libalsapid.so through LD_PRELOAD.\n"); @@ -501,7 +503,7 @@ static void set_ldpreload(void) } else { - new = "libalsapid.so"; + new = LD_PRELOAD_ADD; } printf("LD_PRELOAD set to \"%s\"\n", new);