[xiph-commits] r16849 - trunk/ao/src/plugins/sun

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Fri Jan 29 03:13:12 PST 2010


Author: xiphmont
Date: 2010-01-29 03:13:12 -0800 (Fri, 29 Jan 2010)
New Revision: 16849

Modified:
   trunk/ao/src/plugins/sun/ao_sun.c
Log:
Update sun audio driver to look for environment variables specifying 
device
Fixes #611


Modified: trunk/ao/src/plugins/sun/ao_sun.c
===================================================================
--- trunk/ao/src/plugins/sun/ao_sun.c	2010-01-29 10:58:31 UTC (rev 16848)
+++ trunk/ao/src/plugins/sun/ao_sun.c	2010-01-29 11:13:12 UTC (rev 16849)
@@ -44,6 +44,17 @@
 #define AUDIO_ENCODING_SLINEAR AUDIO_ENCODING_LINEAR	/* Solaris */
 #endif
 
+#ifndef AO_SUN_ENV_DEV1
+/* SunRay device environment variable, look here first */
+#define AO_SUN_ENV_DEV1 "UTAUDIODEV"
+#endif
+
+#ifndef AO_SUN_ENV_DEV2
+/* Ordinary Sun audio device environment variable, look here second */
+#define AO_SUN_ENV_DEV2 "AUDIODEV"
+#endif
+
+/* No environment variable, try the default local device */
 #ifndef AO_SUN_DEFAULT_DEV
 #define AO_SUN_DEFAULT_DEV "/dev/audio"
 #endif
@@ -72,8 +83,13 @@
 int ao_plugin_test()
 {
 	int fd;
+        char *dev = NULL;
 
-	if ( (fd = open(AO_SUN_DEFAULT_DEV, O_WRONLY | O_NONBLOCK)) < 0 )
+        dev = getenv(AO_SUN_ENV_DEV1);
+        if (!dev) dev = getenv(AO_SUN_ENV_DEV2);
+        if (!dev) dev = AO_SUN_DEFAULT_DEV;
+
+	if ( (fd = open(dev, O_WRONLY | O_NONBLOCK)) < 0 )
 		return 0; /* Cannot use this plugin with default parameters */
 	else {
 		close(fd);
@@ -91,13 +107,17 @@
 int ao_plugin_device_init(ao_device *device)
 {
 	ao_sun_internal *internal;
+        char *dev = NULL;
 
 	internal = (ao_sun_internal *) malloc(sizeof(ao_sun_internal));
 
 	if (internal == NULL)
 		return 0; /* Could not initialize device memory */
 
-	internal->dev = strdup(AO_SUN_DEFAULT_DEV);
+        dev = getenv(AO_SUN_ENV_DEV1);
+        if (!dev) dev = getenv(AO_SUN_ENV_DEV2);
+        if (!dev) dev = AO_SUN_DEFAULT_DEV;
+	internal->dev = strdup(dev);
 
 	if (internal->dev == NULL) {
 		free(internal);



More information about the commits mailing list