Skip to content
Snippets Groups Projects
Commit 8e39a136 authored by Stan Seibert's avatar Stan Seibert
Browse files

Patch from David Walser <luigiwalser@yahoo.com> to do plugin detection in

a better way.  Sort the plugin priorities and do them in descending order.
Also makes use of arts/esd functions to test if they are holding the
device or not.  If present, we check the those plugins first and only
use them if they are currently holding the device.


git-svn-id: http://svn.xiph.org/trunk/ao@5136 0101bb08-14d6-0310-b084-bc0e0c8e3800
parent c5a9831e
No related branches found
No related tags found
No related merge requests found
...@@ -248,6 +248,10 @@ if test "$BUILD_ARTS" = "yes"; then ...@@ -248,6 +248,10 @@ if test "$BUILD_ARTS" = "yes"; then
then then
ARTS_CFLAGS=`$ac_cv_path_ARTSC_CONFIG --cflags` ARTS_CFLAGS=`$ac_cv_path_ARTSC_CONFIG --cflags`
ARTS_LIBS=`$ac_cv_path_ARTSC_CONFIG --libs` ARTS_LIBS=`$ac_cv_path_ARTSC_CONFIG --libs`
SAVELIBS=$LIBS
LIBS="$LIBS $ARTS_LIBS"
AC_CHECK_FUNCS(arts_suspended)
LIBS=$SAVELIBS
fi fi
fi fi
AM_CONDITIONAL(HAVE_ARTS,test "x$ac_cv_path_ARTSC_CONFIG" != x) AM_CONDITIONAL(HAVE_ARTS,test "x$ac_cv_path_ARTSC_CONFIG" != x)
......
...@@ -161,7 +161,6 @@ static int _find_default_driver_id (const char *name) ...@@ -161,7 +161,6 @@ static int _find_default_driver_id (const char *name)
{ {
int def_id; int def_id;
int id; int id;
int priority;
ao_info *info; ao_info *info;
driver_list *driver = driver_head; driver_list *driver = driver_head;
...@@ -170,16 +169,15 @@ static int _find_default_driver_id (const char *name) ...@@ -170,16 +169,15 @@ static int _find_default_driver_id (const char *name)
def_id = -1; def_id = -1;
id = 0; id = 0;
priority = 0; /* This forces the null driver to be skipped */
while (driver != NULL) { while (driver != NULL) {
info = driver->functions->driver_info(); info = driver->functions->driver_info();
if ( info->type == AO_TYPE_LIVE && if ( info->type == AO_TYPE_LIVE &&
info->priority > priority && info->priority > 0 && /* Skip static drivers */
driver->functions->test() ) { driver->functions->test() ) {
priority = info->priority;
def_id = id; /* Found a usable driver */ def_id = id; /* Found a usable driver */
break;
} }
driver = driver->next; driver = driver->next;
...@@ -264,15 +262,29 @@ static void _append_dynamic_drivers(driver_list *end) ...@@ -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(). */ /* 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; driver_list *list;
int i; int i;
ao_info **table; ao_info **table;
driver_list **drivers_table;
*driver_count = 0;
/* Count drivers */ /* Count drivers */
list = head; list = *head;
i = 0; i = 0;
while (list != NULL) { while (list != NULL) {
i++; i++;
...@@ -280,15 +292,29 @@ static ao_info ** _make_info_table (driver_list *head, int *driver_count) ...@@ -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 */ /* Alloc table */
table = (ao_info **) calloc(i, sizeof(ao_info *)); table = (ao_info **) calloc(i, sizeof(ao_info *));
if (table != NULL) { if (table != NULL) {
*driver_count = i; for (i = 0; i < *driver_count; i++)
list = head; table[i] = drivers_table[i]->functions->driver_info();
for (i = 0; i < *driver_count; i++, list = list->next) }
table[i] = list->functions->driver_info();
} else free(drivers_table);
*driver_count = 0;
return table; return table;
} }
...@@ -515,7 +541,7 @@ void ao_initialize(void) ...@@ -515,7 +541,7 @@ void ao_initialize(void)
} }
/* Create the table of driver info structs */ /* 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);
} }
......
...@@ -46,7 +46,7 @@ static ao_info ao_alsa_info = ...@@ -46,7 +46,7 @@ static ao_info ao_alsa_info =
"Stan Seibert <volsung@asu.edu>", "Stan Seibert <volsung@asu.edu>",
"Outputs to the Advanced Linux Sound Architecture version 0.5.x.", "Outputs to the Advanced Linux Sound Architecture version 0.5.x.",
AO_FMT_NATIVE, AO_FMT_NATIVE,
30, 34,
ao_alsa_options, ao_alsa_options,
3 3
}; };
......
...@@ -50,7 +50,7 @@ static ao_info ao_alsa_info = ...@@ -50,7 +50,7 @@ static ao_info ao_alsa_info =
"Bill Currie <bill@taniwha.org>", "Bill Currie <bill@taniwha.org>",
"Outputs to the Advanced Linux Sound Architecture version 0.9.x.", "Outputs to the Advanced Linux Sound Architecture version 0.9.x.",
AO_FMT_NATIVE, AO_FMT_NATIVE,
30, 35,
ao_alsa_options, ao_alsa_options,
3 3
}; };
......
...@@ -39,7 +39,11 @@ static ao_info ao_arts_info = ...@@ -39,7 +39,11 @@ static ao_info ao_arts_info =
"Rik Hemsley (rikkus) <rik@kde.org>", "Rik Hemsley (rikkus) <rik@kde.org>",
"Outputs to the aRts soundserver.", "Outputs to the aRts soundserver.",
AO_FMT_NATIVE, AO_FMT_NATIVE,
10, #ifdef HAVE_ARTS_SUSPENDED
45,
#else
15,
#endif
NULL, NULL,
0 0
}; };
...@@ -54,6 +58,12 @@ typedef struct ao_arts_internal ...@@ -54,6 +58,12 @@ typedef struct ao_arts_internal
int ao_plugin_test() int ao_plugin_test()
{ {
if (arts_init() == 0) { if (arts_init() == 0) {
#ifdef HAVE_ARTS_SUSPENDED
if (arts_suspended() == 1) {
arts_free();
return 0;
}
#endif
arts_free(); arts_free();
return 1; return 1;
} else } else
......
...@@ -43,7 +43,7 @@ static ao_info ao_esd_info = ...@@ -43,7 +43,7 @@ static ao_info ao_esd_info =
"Stan Seibert <volsung@asu.edu>", "Stan Seibert <volsung@asu.edu>",
"Outputs to the Enlightened Sound Daemon.", "Outputs to the Enlightened Sound Daemon.",
AO_FMT_NATIVE, AO_FMT_NATIVE,
10, 40,
ao_esd_options, ao_esd_options,
1 1
}; };
...@@ -63,12 +63,15 @@ int ao_plugin_test() ...@@ -63,12 +63,15 @@ int ao_plugin_test()
/* don't wake up the beast while detecting */ /* don't wake up the beast while detecting */
setenv("ESD_NO_SPAWN", "1", 1); setenv("ESD_NO_SPAWN", "1", 1);
sock = esd_open_sound(NULL); sock = esd_open_sound(NULL);
if (sock < 0) if (sock < 0)
return 0; return 0;
else { if (esd_get_standby_mode(sock) != ESM_RUNNING) {
esd_close(sock); esd_close(sock);
return 1; return 0;
} }
esd_close(sock);
return 1;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment