Changeset 60aaa492db336e5685ff19f3a2600bbbaf074cef
- 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:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r0cfdeec
|
r60aaa49
|
|
| 3 | 3 | * LADI Session Handler (ladish) |
| 4 | 4 | * |
| 5 | | * Copyright (C) 2010 Nedko Arnaudov <nedko@arnaudov.name> |
| | 5 | * Copyright (C) 2010, 2011 Nedko Arnaudov <nedko@arnaudov.name> |
| 6 | 6 | * |
| 7 | 7 | ************************************************************************** |
| … |
… |
|
| 77 | 77 | //static int (* real_snd_seq_create_simple_port)(snd_seq_t * seq, const char * name, unsigned int caps, unsigned int type); |
| 78 | 78 | |
| 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 | | |
| 91 | 79 | #define CHECK_FUNC(func) \ |
| 92 | 80 | if (real_ ## func == NULL) \ |
| 93 | 81 | { \ |
| 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 | } \ |
| 96 | 88 | } |
| 97 | 89 | |
-
|
r0ba807b
|
r60aaa49
|
|
| 485 | 485 | } |
| 486 | 486 | |
| | 487 | #define LD_PRELOAD_ADD "libalsapid.so libasound.so" |
| | 488 | |
| 487 | 489 | static void set_ldpreload(void) |
| 488 | 490 | { |
| … |
… |
|
| 493 | 495 | if (old != NULL) |
| 494 | 496 | { |
| 495 | | new = catdup3("libalsapid.so", " ", old); |
| | 497 | new = catdup3(LD_PRELOAD_ADD, " ", old); |
| 496 | 498 | if (new == NULL) |
| 497 | 499 | { |
| … |
… |
|
| 502 | 504 | else |
| 503 | 505 | { |
| 504 | | new = "libalsapid.so"; |
| | 506 | new = LD_PRELOAD_ADD; |
| 505 | 507 | } |
| 506 | 508 | |