From cd7b25d4c1b3a2405c76e3c398990dcefe9af725 Mon Sep 17 00:00:00 2001
From: Jack Moffitt <jack@xiph.org>
Date: Sun, 6 May 2001 00:13:59 +0000
Subject: [PATCH] Stan Seibert's ao_raw device.

git-svn-id: http://svn.xiph.org/trunk/ao@1440 0101bb08-14d6-0310-b084-bc0e0c8e3800
---
 doc/DRIVERS     | 12 ++++++++++++
 include/ao/ao.h |  1 +
 src/Makefile.am |  2 +-
 src/audio_out.c | 12 +++++++++---
 4 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/doc/DRIVERS b/doc/DRIVERS
index a4f8db1..e12b612 100644
--- a/doc/DRIVERS
+++ b/doc/DRIVERS
@@ -59,6 +59,18 @@ data you output.
         "file" - Sets the output file.  By default, this is
                  "output.wav".
 
+raw
+---
+Raw sample output.  Writes the sound data to disk in uncompressed,
+headerless form using the byte order specified.
+	Option keys:
+		"file" - Sets the output file.  Use "-" if you want to write
+		to stdout.  By default this is "output.raw".
+		
+		"byteorder" - Sets the byte order used in the output.  Use
+		"native" for native machine byte order, "big" for 
+		big-endian order, and "little" for little-endian order. By
+		default this is "native".
 
 ADDING NEW DRIVERS
 
diff --git a/include/ao/ao.h b/include/ao/ao.h
index 4311b0f..b4de0fe 100644
--- a/include/ao/ao.h
+++ b/include/ao/ao.h
@@ -75,6 +75,7 @@ typedef struct ao_device_s {
 
 #define AO_NULL     0
 #define AO_WAV      1
+#define AO_RAW	    2
 
 /* --- Functions --- */
 
diff --git a/src/Makefile.am b/src/Makefile.am
index e12d5a0..034c454 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -7,7 +7,7 @@ INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/include
 
 lib_LTLIBRARIES = libao.la
 
-libao_la_SOURCES = audio_out.c ao_wav.c ao_null.c
+libao_la_SOURCES = audio_out.c ao_raw.c ao_wav.c ao_null.c
 libao_la_LDFLAGS = -version-info @LIB_CURRENT@:@LIB_REVISION@:@LIB_AGE@
 
 
diff --git a/src/audio_out.c b/src/audio_out.c
index 6559749..2bda2d5 100644
--- a/src/audio_out.c
+++ b/src/audio_out.c
@@ -55,6 +55,7 @@ typedef struct driver_tree_s {
 
 extern ao_functions_t ao_null;
 extern ao_functions_t ao_wav;
+extern ao_functions_t ao_raw;
 
 driver_tree_t *driver_head = NULL;
 
@@ -97,6 +98,7 @@ void ao_initialize(void)
 {
 	driver_tree_t *dnull;
 	driver_tree_t *dwav;
+	driver_tree_t *draw;
 	driver_tree_t *plugin;
 	driver_tree_t *driver;
 	DIR *plugindir;
@@ -114,12 +116,16 @@ void ao_initialize(void)
 		dwav = (driver_tree_t *)malloc(sizeof(driver_tree_t));
 		dwav->functions = &ao_wav;
 		dwav->handle = NULL;
+		draw = (driver_tree_t *)malloc(sizeof(driver_tree_t));
+		draw->functions = &ao_raw;
+		draw->handle = NULL;
 		
 		dnull->next = dwav;
-		dwav->next = NULL;
+		dwav->next = draw;
+		draw->next = NULL;
 
 		driver_head = dnull;		
-		driver = dwav;
+		driver = draw;
 
 		/* now insert any plugins we find */
 		plugindir = opendir(AO_PLUGIN_PATH);
@@ -151,7 +157,7 @@ void ao_shutdown(void)
 	if (!driver_head) return;
 
 	/* unload and free all the plugins */
-	driver = driver->next->next;
+	driver = driver->next->next->next;  /* Skip null, wav, and raw driver */
 	while (driver) {
 		if (driver->functions) free(driver->functions);
 		if (driver->handle) dlclose(driver->handle);
-- 
GitLab