13
0

add explicit construction (for MSVC) and some debug messages

This commit is contained in:
Robin Gareus 2014-10-24 17:15:03 +02:00
parent 25a6aa57a3
commit 5e7f935a27
2 changed files with 18 additions and 5 deletions

View File

@ -84,15 +84,15 @@ static struct WeakJack {
static int _status = -1;
int have_libjack (void) {
return _status;
}
__attribute__((constructor))
//__attribute__((constructor))
static void init_weak_jack(void)
{
void* lib;
int err = 0;
#ifndef NDEBUG
fprintf(stderr, "*** WEAK-JACK: initializing\n");
#endif
memset(&_j, 0, sizeof(_j));
@ -111,6 +111,9 @@ static void init_weak_jack(void)
lib = lib_open("libjack.so.0");
#endif
if (!lib) {
#ifndef NDEBUG
fprintf(stderr, "*** WEAK-JACK: libjack was not found\n");
#endif
_status = -2;
return;
}
@ -135,6 +138,16 @@ static void init_weak_jack(void)
_j._client_open = NULL;
}
_status = err;
#ifndef NDEBUG
fprintf(stderr, "*** WEAK-JACK: %s. (%d)\n", err ? "jack is not available" : "OK", _status);
#endif
}
int have_libjack (void) {
if (_status == -1) {
init_weak_jack();
}
return _status;
}
/*******************************************************************************

View File

@ -9,7 +9,7 @@
* see https://en.wikibooks.org/wiki/C_Programming/Preprocessor#X-Macros
*/
#ifndef USE_WEAK_JACK
#ifdef USE_WEAK_JACK
/* <jack/jack.h> */
JCFUN(1, int, client_close, 0)