[xiph-commits] r12979 - trunk/ao/src

ben at svn.xiph.org ben at svn.xiph.org
Thu May 24 03:00:49 PDT 2007


Author: ben
Date: 2007-05-24 03:00:48 -0700 (Thu, 24 May 2007)
New Revision: 12979

Modified:
   trunk/ao/src/audio_out.c
Log:
Add conditionnal to remove dlopen() and friends calls on system that does not support it. 


Modified: trunk/ao/src/audio_out.c
===================================================================
--- trunk/ao/src/audio_out.c	2007-05-24 09:43:48 UTC (rev 12978)
+++ trunk/ao/src/audio_out.c	2007-05-24 10:00:48 UTC (rev 12979)
@@ -28,7 +28,16 @@
 #include <stdio.h>
 #include <string.h>
 #include <limits.h>
-#include <dlfcn.h>
+#if defined HAVE_DLFCN_H && defined HAVE_DLOPEN
+# include <dlfcn.h>
+#else
+static void *dlopen(const char *filename, int flag) {return 0;}
+static char *dlerror(void) { return "dlopen: unsupported"; }
+static void *dlsym(void *handle, const char *symbol) { return 0; }
+static int dlclose(void *handle) { return 0; }
+#undef DLOPEN_FLAG
+#define DLOPEN_FLAG 0
+#endif
 #include <sys/types.h>
 #include <sys/stat.h>
 #ifndef _MSC_VER
@@ -66,7 +75,9 @@
 #ifdef HAVE_SYS_AUDIO_H
 extern ao_functions ao_aixs;
 #endif
-
+#ifdef HAVE_WMM
+extern ao_functions ao_wmm;
+#endif
 static ao_functions *static_drivers[] = {
 	&ao_null, /* Must have at least one static driver! */
 	&ao_wav,
@@ -75,6 +86,10 @@
 #ifdef HAVE_SYS_AUDIO_H
 	&ao_aixs,
 #endif
+#ifdef HAVE_WMM
+	&ao_wmm,
+#endif
+
 	NULL /* End of list */
 };
 
@@ -99,7 +114,6 @@
 
 /* Load a plugin from disk and put the function table into a driver_list
    struct. */
-
 static driver_list *_get_plugin(char *plugin_file)
 {
 	driver_list *dt;
@@ -235,6 +249,7 @@
    driver list.  end points the driver_list node to append to. */
 static void _append_dynamic_drivers(driver_list *end)
 {
+#ifdef HAVE_DLOPEN
 	struct dirent *plugin_dirent;
 	char *ext;
 	struct stat statbuf;
@@ -265,6 +280,7 @@
 		
 		closedir(plugindir);
 	}
+#endif
 }
 
 
@@ -514,6 +530,14 @@
 	/* Only create swap buffer for 16 bit samples if needed */
 	if (format->bits == 16 &&
 	    device->client_byte_format != device->driver_byte_format) {
+
+	  fprintf(stderr,
+		  "n\n\n\n-------------------------\n"
+		  "big : %d\n"
+		  "device->client_byte_format:%d\n"
+		  "device->driver_byte_format:%d\n"
+		  "--------------------------\n",
+		  ao_is_big_endian(),device->client_byte_format,device->driver_byte_format);
 		
 		result = _realloc_swap_buffer(device, DEF_SWAP_BUF_SIZE);
 		
@@ -563,6 +587,7 @@
 	/* unload and free all the drivers */
 	while (driver) {
 		if (driver->handle) {
+
 		  dlclose(driver->handle);
 		  free(driver->functions); /* DON'T FREE STATIC FUNC TABLES */
 		}
@@ -673,6 +698,7 @@
 	if (device == NULL)
 	  return 0;
 
+#if 1
 	if (device->swap_buffer != NULL) {
 		if (_realloc_swap_buffer(device, num_bytes)) {
 			_swap_samples(device->swap_buffer, 
@@ -681,6 +707,7 @@
 		} else
 			return 0; /* Could not expand swap buffer */
 	} else
+#endif
 		playback_buffer = output_samples;
 
 	return device->funcs->play(device, playback_buffer, num_bytes);
@@ -763,9 +790,6 @@
 /* Stolen from Vorbis' lib/vorbisfile.c */
 int ao_is_big_endian(void) 
 {
-	uint_16 pattern = 0xbabe;
-	unsigned char *bytewise = (unsigned char *)&pattern;
-
-	if (bytewise[0] == 0xba) return 1;
-	return 0;
+	static uint_16 pattern = 0xbabe;
+	return 0[(volatile unsigned char *)&pattern] == 0xba;
 }



More information about the commits mailing list