diff --git a/configure.in b/configure.in index 2a310bff25d9611af814485a9e29c12d213d37f5..f9dd8496e558be862555db1799e486e0f8cb6dca 100644 --- a/configure.in +++ b/configure.in @@ -248,6 +248,10 @@ if test "$BUILD_ARTS" = "yes"; then then ARTS_CFLAGS=`$ac_cv_path_ARTSC_CONFIG --cflags` ARTS_LIBS=`$ac_cv_path_ARTSC_CONFIG --libs` + SAVELIBS=$LIBS + LIBS="$LIBS $ARTS_LIBS" + AC_CHECK_FUNCS(arts_suspended) + LIBS=$SAVELIBS fi fi AM_CONDITIONAL(HAVE_ARTS,test "x$ac_cv_path_ARTSC_CONFIG" != x) diff --git a/src/audio_out.c b/src/audio_out.c index ff9cac012ba82d32e402b4c84e1c56a20f3b863d..b3102bb0324d6f6b07c220734a6e0e946d8b1039 100644 --- a/src/audio_out.c +++ b/src/audio_out.c @@ -161,7 +161,6 @@ static int _find_default_driver_id (const char *name) { int def_id; int id; - int priority; ao_info *info; driver_list *driver = driver_head; @@ -170,16 +169,15 @@ static int _find_default_driver_id (const char *name) def_id = -1; id = 0; - priority = 0; /* This forces the null driver to be skipped */ while (driver != NULL) { info = driver->functions->driver_info(); if ( info->type == AO_TYPE_LIVE && - info->priority > priority && + info->priority > 0 && /* Skip static drivers */ driver->functions->test() ) { - priority = info->priority; def_id = id; /* Found a usable driver */ + break; } driver = driver->next; @@ -264,15 +262,29 @@ static void _append_dynamic_drivers(driver_list *end) } +/* Compare two drivers based on priority + Used as compar function for qsort() in _make_info_table() */ +static int _compar_driver_priority (const driver_list **a, + const driver_list **b) +{ + return memcmp(&((*b)->functions->driver_info()->priority), + &((*a)->functions->driver_info()->priority), + sizeof(int)); +} + + /* Make a table of driver info structures for ao_driver_info_list(). */ -static ao_info ** _make_info_table (driver_list *head, int *driver_count) +static ao_info ** _make_info_table (driver_list **head, int *driver_count) { driver_list *list; int i; ao_info **table; + driver_list **drivers_table; + + *driver_count = 0; /* Count drivers */ - list = head; + list = *head; i = 0; while (list != NULL) { i++; @@ -280,15 +292,29 @@ static ao_info ** _make_info_table (driver_list *head, int *driver_count) } + /* Sort driver_list */ + drivers_table = (driver_list **) calloc(i, sizeof(driver_list *)); + if (drivers_table == NULL) + return (ao_info **) NULL; + list = *head; + *driver_count = i; + for (i = 0; i < *driver_count; i++, list = list->next) + drivers_table[i] = list; + qsort(drivers_table, i, sizeof(driver_list *), _compar_driver_priority); + *head = drivers_table[0]; + for (i = 1; i < *driver_count; i++) + drivers_table[i-1]->next = drivers_table[i]; + drivers_table[i-1]->next = NULL; + + /* Alloc table */ table = (ao_info **) calloc(i, sizeof(ao_info *)); if (table != NULL) { - *driver_count = i; - list = head; - for (i = 0; i < *driver_count; i++, list = list->next) - table[i] = list->functions->driver_info(); - } else - *driver_count = 0; + for (i = 0; i < *driver_count; i++) + table[i] = drivers_table[i]->functions->driver_info(); + } + + free(drivers_table); return table; } @@ -515,7 +541,7 @@ void ao_initialize(void) } /* Create the table of driver info structs */ - info_table = _make_info_table(driver_head, &driver_count); + info_table = _make_info_table(&driver_head, &driver_count); } diff --git a/src/plugins/alsa/ao_alsa.c b/src/plugins/alsa/ao_alsa.c index ec47ab3d32829d3c35e429ef816e4d8cdb4960ae..a21d785f167a084635c22f55bd6fc770544798b8 100644 --- a/src/plugins/alsa/ao_alsa.c +++ b/src/plugins/alsa/ao_alsa.c @@ -46,7 +46,7 @@ static ao_info ao_alsa_info = "Stan Seibert <volsung@asu.edu>", "Outputs to the Advanced Linux Sound Architecture version 0.5.x.", AO_FMT_NATIVE, - 30, + 34, ao_alsa_options, 3 }; diff --git a/src/plugins/alsa09/ao_alsa09.c b/src/plugins/alsa09/ao_alsa09.c index 70d38fa043d471e92ee87f01187bf4ef9a2ed869..bf6e01c67bc3b073ba77b16ae638e6d41286deb3 100644 --- a/src/plugins/alsa09/ao_alsa09.c +++ b/src/plugins/alsa09/ao_alsa09.c @@ -50,7 +50,7 @@ static ao_info ao_alsa_info = "Bill Currie <bill@taniwha.org>", "Outputs to the Advanced Linux Sound Architecture version 0.9.x.", AO_FMT_NATIVE, - 30, + 35, ao_alsa_options, 3 }; diff --git a/src/plugins/arts/ao_arts.c b/src/plugins/arts/ao_arts.c index d97e88121c87f1f2e66c744304a7b01d48f3cc20..e3d0ccf6294fb37ab52166db9f947adf6318708c 100644 --- a/src/plugins/arts/ao_arts.c +++ b/src/plugins/arts/ao_arts.c @@ -39,7 +39,11 @@ static ao_info ao_arts_info = "Rik Hemsley (rikkus) <rik@kde.org>", "Outputs to the aRts soundserver.", AO_FMT_NATIVE, - 10, +#ifdef HAVE_ARTS_SUSPENDED + 45, +#else + 15, +#endif NULL, 0 }; @@ -54,6 +58,12 @@ typedef struct ao_arts_internal int ao_plugin_test() { if (arts_init() == 0) { +#ifdef HAVE_ARTS_SUSPENDED + if (arts_suspended() == 1) { + arts_free(); + return 0; + } +#endif arts_free(); return 1; } else diff --git a/src/plugins/esd/ao_esd.c b/src/plugins/esd/ao_esd.c index fd0797e33f3851137fa44bb2b45c733cf3737bc4..c73a9eb54ff4a9e3358cf9f3ed2901dff76b7436 100644 --- a/src/plugins/esd/ao_esd.c +++ b/src/plugins/esd/ao_esd.c @@ -43,7 +43,7 @@ static ao_info ao_esd_info = "Stan Seibert <volsung@asu.edu>", "Outputs to the Enlightened Sound Daemon.", AO_FMT_NATIVE, - 10, + 40, ao_esd_options, 1 }; @@ -63,12 +63,15 @@ int ao_plugin_test() /* don't wake up the beast while detecting */ setenv("ESD_NO_SPAWN", "1", 1); sock = esd_open_sound(NULL); - if (sock < 0) + if (sock < 0) return 0; - else { + if (esd_get_standby_mode(sock) != ESM_RUNNING) { esd_close(sock); - return 1; + return 0; } + + esd_close(sock); + return 1; }