Changeset 60aaa492db336e5685ff19f3a2600bbbaf074cef

Show
Ignore:
Timestamp:
06/03/11 00:44:00 (2 years ago)
Author:
Nedko Arnaudov <nedko@…>
Children:
78f07f7ad1a4778a5aa49083c4341cbbb4af1556
Parents:
cd3c2e4af45af43b3d3330f84180c6a7a74941a3
git-committer:
Nedko Arnaudov <nedko@arnaudov.name> / 2011-06-03T00:44:00Z+0300
Message:

Make alsapid work when libasound is loaded with dlopen(). Fix for #180

when alsapid is preloaded libasound is not loaded yet
for some unknown reason, late call to dlvsym() fails as well,
at least for mididings (python loads _mididings.so that
implicitly loads libasound.so)

this changeset implements the late symbol lookup,
because it makes the code smaller

the actual fix is to LD_PRELOAD libasound.so as well

Files:
2 modified

Legend:

Unmodified
Added
Removed
  • alsapid/lib.c

    r0cfdeec r60aaa49  
    33 * LADI Session Handler (ladish) 
    44 * 
    5  * Copyright (C) 2010 Nedko Arnaudov <nedko@arnaudov.name> 
     5 * Copyright (C) 2010, 2011 Nedko Arnaudov <nedko@arnaudov.name> 
    66 * 
    77 ************************************************************************** 
     
    7777//static int (* real_snd_seq_create_simple_port)(snd_seq_t * seq, const char * name, unsigned int caps, unsigned int type); 
    7878 
    79 static void __attribute__ ((constructor)) init(void); 
    80  
    81 /* Library constructor */ 
    82 void init(void) 
    83 { 
    84 //  real_snd_seq_open               = dlvsym(RTLD_NEXT, "snd_seq_open",               API_VERSION); 
    85   real_snd_seq_set_client_name    = dlvsym(RTLD_NEXT, "snd_seq_set_client_name",    API_VERSION); 
    86   real_snd_seq_close              = dlvsym(RTLD_NEXT, "snd_seq_close",              API_VERSION); 
    87 //  real_snd_seq_create_port        = dlvsym(RTLD_NEXT, "snd_seq_create_port",        API_VERSION); 
    88 //  real_snd_seq_create_simple_port = dlvsym(RTLD_NEXT, "snd_seq_create_simple_port", API_VERSION); 
    89 } 
    90  
    9179#define CHECK_FUNC(func)                                                \ 
    9280  if (real_ ## func == NULL)                                            \ 
    9381  {                                                                     \ 
    94     fprintf(stderr, "dlvsym(\"" #func "\", \""API_VERSION"\") failed.\n"); \ 
    95     return -1;                                                          \ 
     82    real_ ## func = dlvsym(RTLD_NEXT, #func, API_VERSION);              \ 
     83    if (real_ ## func == NULL)                                          \ 
     84    {                                                                   \ 
     85      fprintf(stderr, "dlvsym(\""#func"\", \""API_VERSION"\") failed. %s\n", dlerror()); \ 
     86      return -1;                                                        \ 
     87    }                                                                   \ 
    9688  } 
    9789 
  • daemon/loader.c

    r0ba807b r60aaa49  
    485485} 
    486486 
     487#define LD_PRELOAD_ADD "libalsapid.so libasound.so" 
     488 
    487489static void set_ldpreload(void) 
    488490{ 
     
    493495  if (old != NULL) 
    494496  { 
    495     new = catdup3("libalsapid.so", " ", old); 
     497    new = catdup3(LD_PRELOAD_ADD, " ", old); 
    496498    if (new == NULL) 
    497499    { 
     
    502504  else 
    503505  { 
    504     new = "libalsapid.so"; 
     506    new = LD_PRELOAD_ADD; 
    505507  } 
    506508