[xiph-cvs] cvs commit: ao/src/plugins/esd ao_esd.c

Stan Seibert volsung at xiph.org
Sun Jul 13 18:55:47 PDT 2003



volsung     03/07/13 21:55:47

  Modified:    .        configure.in
               src      audio_out.c
               src/plugins/alsa ao_alsa.c
               src/plugins/alsa09 ao_alsa09.c
               src/plugins/arts ao_arts.c
               src/plugins/esd ao_esd.c
  Log:
  Patch from David Walser <luigiwalser at 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.

Revision  Changes    Path
1.44      +4 -0      ao/configure.in

Index: configure.in
===================================================================
RCS file: /usr/local/cvsroot/ao/configure.in,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -r1.43 -r1.44
--- configure.in	24 Jun 2003 12:14:19 -0000	1.43
+++ configure.in	14 Jul 2003 01:55:46 -0000	1.44
@@ -248,6 +248,10 @@
   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)

<p><p>1.24      +39 -13    ao/src/audio_out.c

Index: audio_out.c
===================================================================
RCS file: /usr/local/cvsroot/ao/src/audio_out.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- audio_out.c	8 Jan 2003 03:48:54 -0000	1.23
+++ audio_out.c	14 Jul 2003 01:55:46 -0000	1.24
@@ -161,7 +161,6 @@
 {
         int def_id;
         int id;
-	int priority;
         ao_info *info;
         driver_list *driver = driver_head;
 
@@ -170,16 +169,15 @@
                 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 @@
 }
 
 
+/* 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 @@
         }
 
         
+	/* 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 @@
         }
 
         /* 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);
 }
 
 

<p><p>1.9       +1 -1      ao/src/plugins/alsa/ao_alsa.c

Index: ao_alsa.c
===================================================================
RCS file: /usr/local/cvsroot/ao/src/plugins/alsa/ao_alsa.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ao_alsa.c	18 Dec 2001 22:39:23 -0000	1.8
+++ ao_alsa.c	14 Jul 2003 01:55:47 -0000	1.9
@@ -46,7 +46,7 @@
         "Stan Seibert <volsung at asu.edu>",
         "Outputs to the Advanced Linux Sound Architecture version 0.5.x.",
         AO_FMT_NATIVE,
-	30,
+	34,
         ao_alsa_options,
         3
 };

<p><p>1.12      +1 -1      ao/src/plugins/alsa09/ao_alsa09.c

Index: ao_alsa09.c
===================================================================
RCS file: /usr/local/cvsroot/ao/src/plugins/alsa09/ao_alsa09.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- ao_alsa09.c	18 Dec 2001 22:39:24 -0000	1.11
+++ ao_alsa09.c	14 Jul 2003 01:55:47 -0000	1.12
@@ -50,7 +50,7 @@
         "Bill Currie <bill at taniwha.org>",
         "Outputs to the Advanced Linux Sound Architecture version 0.9.x.",
         AO_FMT_NATIVE,
-	30,
+	35,
         ao_alsa_options,
         3
 };

<p><p>1.5       +11 -1     ao/src/plugins/arts/ao_arts.c

Index: ao_arts.c
===================================================================
RCS file: /usr/local/cvsroot/ao/src/plugins/arts/ao_arts.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ao_arts.c	4 Aug 2001 02:56:16 -0000	1.4
+++ ao_arts.c	14 Jul 2003 01:55:47 -0000	1.5
@@ -39,7 +39,11 @@
         "Rik Hemsley (rikkus) <rik at 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 @@
 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

<p><p>1.7       +7 -4      ao/src/plugins/esd/ao_esd.c

Index: ao_esd.c
===================================================================
RCS file: /usr/local/cvsroot/ao/src/plugins/esd/ao_esd.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ao_esd.c	21 Sep 2001 14:18:58 -0000	1.6
+++ ao_esd.c	14 Jul 2003 01:55:47 -0000	1.7
@@ -43,7 +43,7 @@
         "Stan Seibert <volsung at asu.edu>",
         "Outputs to the Enlightened Sound Daemon.",
         AO_FMT_NATIVE,
-	10,
+	40,
         ao_esd_options,
         1
 };
@@ -63,12 +63,15 @@
         /* 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;
 }
 
 

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list