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

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Tue Jan 26 21:31:48 PST 2010


Author: xiphmont
Date: 2010-01-26 21:31:48 -0800 (Tue, 26 Jan 2010)
New Revision: 16828

Modified:
   trunk/ao/src/ao_aixs.c
   trunk/ao/src/ao_au.c
   trunk/ao/src/ao_null.c
   trunk/ao/src/ao_raw.c
   trunk/ao/src/ao_wav.c
Log:
Add 'degenerate' surround mappings to some of the easier built-in output 
plugins.



Modified: trunk/ao/src/ao_aixs.c
===================================================================
--- trunk/ao/src/ao_aixs.c	2010-01-27 05:15:37 UTC (rev 16827)
+++ trunk/ao/src/ao_aixs.c	2010-01-27 05:31:48 UTC (rev 16828)
@@ -171,6 +171,13 @@
 
 	device->driver_byte_format = AO_FMT_NATIVE;
 
+        if(!device->output_matrix){
+          /* set up out matrix such that users are warned about > stereo playback */
+          if(format->channels<=2)
+            device->output_matrix=strdup("L,R");
+          //else no matrix, which results in a warning
+        }
+
 	return 1;
 }
 

Modified: trunk/ao/src/ao_au.c
===================================================================
--- trunk/ao/src/ao_au.c	2010-01-27 05:15:37 UTC (rev 16827)
+++ trunk/ao/src/ao_au.c	2010-01-27 05:31:48 UTC (rev 16828)
@@ -79,7 +79,7 @@
 
 typedef struct ao_au_internal
 {
-	Audio_filehdr au; 		
+	Audio_filehdr au;
 } ao_au_internal;
 
 
@@ -101,18 +101,18 @@
 
 	internal = (ao_au_internal *) malloc(sizeof(ao_au_internal));
 
-	if (internal == NULL)	
+	if (internal == NULL)
 		return 0; /* Could not initialize device memory */
-	
+
 	memset(&(internal->au), 0, sizeof(internal->au));
-	
+
 	device->internal = internal;
 
 	return 1; /* Memory alloc successful */
 }
 
 
-static int ao_au_set_option(ao_device *device, const char *key, 
+static int ao_au_set_option(ao_device *device, const char *key,
 			    const char *value)
 {
 	return 1; /* No options! */
@@ -126,7 +126,7 @@
 
 	/* The AU format is big-endian */
 	device->driver_byte_format = AO_FMT_BIG;
-		
+
 	/* Fill out the header */
 	internal->au.magic = AUDIO_FILE_MAGIC;
 	internal->au.channels = format->channels;
@@ -137,7 +137,7 @@
 	else {
 		/* Only 8 and 16 bits are supported at present. */
 		return 0;
-	}	
+	}
 	internal->au.sample_rate = format->rate;
 	internal->au.hdr_size = AU_HEADER_LEN;
 
@@ -158,11 +158,18 @@
 	WRITE_U32(buf + 20, internal->au.channels);
 	strncpy (buf + 24, internal->au.info, 4);
 
-	if (fwrite(buf, sizeof(char), AU_HEADER_LEN, device->file) 
+	if (fwrite(buf, sizeof(char), AU_HEADER_LEN, device->file)
 	    != AU_HEADER_LEN) {
 		return 0; /* Error writing header */
 	}
 
+        if(!device->output_matrix){
+          /* set up out matrix such that users are arned about > stereo playback */
+          if(format->channels<=2)
+            device->output_matrix=strdup("L,R");
+          //else no matrix, which results in a warning
+        }
+
 	return 1;
 }
 
@@ -170,10 +177,10 @@
 /*
  * play the sample to the already opened file descriptor
  */
-static int ao_au_play(ao_device *device, const char *output_samples, 
+static int ao_au_play(ao_device *device, const char *output_samples,
 		       uint_32 num_bytes)
 {
-	if (fwrite(output_samples, sizeof(char), num_bytes, 
+	if (fwrite(output_samples, sizeof(char), num_bytes,
 		   device->file) < num_bytes)
 		return 0;
 	else

Modified: trunk/ao/src/ao_null.c
===================================================================
--- trunk/ao/src/ao_null.c	2010-01-27 05:15:37 UTC (rev 16827)
+++ trunk/ao/src/ao_null.c	2010-01-27 05:31:48 UTC (rev 16828)
@@ -68,9 +68,9 @@
 
 	internal = (ao_null_internal *) malloc(sizeof(ao_null_internal));
 
-	if (internal == NULL)	
+	if (internal == NULL)
 		return 0; /* Could not initialize device memory */
-	
+
 	internal->byte_counter = 0;
 	internal->debug_output = 0;
 
@@ -80,7 +80,7 @@
 }
 
 
-static int ao_null_set_option(ao_device *device, const char *key, 
+static int ao_null_set_option(ao_device *device, const char *key,
 			      const char *value)
 {
 	ao_null_internal *internal = (ao_null_internal *) device->internal;
@@ -99,11 +99,16 @@
 	/* Use whatever format the client requested */
 	device->driver_byte_format = device->client_byte_format;
 
+        if(!device->output_matrix){
+          /* all channels 'unavailable' */
+          device->output_matrix=strdup("X");
+        }
+
 	return 1;
 }
 
 
-static int ao_null_play(ao_device *device, const char *output_samples, 
+static int ao_null_play(ao_device *device, const char *output_samples,
 			uint_32 num_bytes)
 {
 	ao_null_internal *internal = (ao_null_internal *)device->internal;

Modified: trunk/ao/src/ao_raw.c
===================================================================
--- trunk/ao/src/ao_raw.c	2010-01-27 05:15:37 UTC (rev 16827)
+++ trunk/ao/src/ao_raw.c	2010-01-27 05:31:48 UTC (rev 16828)
@@ -67,22 +67,22 @@
 
 	internal = (ao_raw_internal *) malloc(sizeof(ao_raw_internal));
 
-	if (internal == NULL)	
+	if (internal == NULL)
 		return 0; /* Could not initialize device memory */
-	
+
 	internal->byte_order = AO_FMT_NATIVE;
-	
+
 	device->internal = internal;
 
 	return 1; /* Memory alloc successful */
 }
 
-static int ao_raw_set_option(ao_device *device, const char *key, 
+static int ao_raw_set_option(ao_device *device, const char *key,
 			      const char *value)
 {
 	ao_raw_internal *internal = (ao_raw_internal *)device->internal;
-	
-	if (!strcmp(key, "byteorder")) {    
+
+	if (!strcmp(key, "byteorder")) {
 		if (!strcmp(value, "native"))
 			internal->byte_order = AO_FMT_NATIVE;
 		else if (!strcmp(value, "big"))
@@ -103,6 +103,12 @@
 
 	device->driver_byte_format = internal->byte_order;
 
+        if(!device->output_matrix){
+          /* by default, out == in */
+          if(format->matrix)
+            device->output_matrix = strdup(format->matrix);
+        }
+
 	return 1;
 }
 
@@ -110,10 +116,10 @@
 /*
  * play the sample to the already opened file descriptor
  */
-static int ao_raw_play(ao_device *device, const char *output_samples, 
+static int ao_raw_play(ao_device *device, const char *output_samples,
 		       uint_32 num_bytes)
 {
-	if (fwrite(output_samples, sizeof(char), num_bytes, 
+	if (fwrite(output_samples, sizeof(char), num_bytes,
 		   device->file) < num_bytes)
 		return 0;
 	else

Modified: trunk/ao/src/ao_wav.c
===================================================================
--- trunk/ao/src/ao_wav.c	2010-01-27 05:15:37 UTC (rev 16827)
+++ trunk/ao/src/ao_wav.c	2010-01-27 05:31:48 UTC (rev 16828)
@@ -55,13 +55,13 @@
 };
 
 
-struct chunk_struct 
+struct chunk_struct
 {
 	unsigned char id[4];
 	unsigned int len;
 };
 
-struct common_struct 
+struct common_struct
 {
 	unsigned short wFormatTag;
 	unsigned short wChannels;
@@ -71,7 +71,7 @@
 	unsigned short wBitsPerSample;  /* Only for PCM */
 };
 
-struct wave_header 
+struct wave_header
 {
 	struct riff_struct   riff;
 	struct chunk_struct  format;
@@ -117,18 +117,18 @@
 
 	internal = (ao_wav_internal *) malloc(sizeof(ao_wav_internal));
 
-	if (internal == NULL)	
+	if (internal == NULL)
 		return 0; /* Could not initialize device memory */
-	
+
 	memset(&(internal->wave), 0, sizeof(internal->wave));
-	
+
 	device->internal = internal;
 
 	return 1; /* Memory alloc successful */
 }
 
 
-static int ao_wav_set_option(ao_device *device, const char *key, 
+static int ao_wav_set_option(ao_device *device, const char *key,
 			     const char *value)
 {
 	return 1; /* No options! */
@@ -157,13 +157,13 @@
 	internal->wave.format.len = 16;
 
 	internal->wave.common.wFormatTag = WAVE_FORMAT_PCM;
-	internal->wave.common.dwAvgBytesPerSec = 
-		internal->wave.common.wChannels * 
+	internal->wave.common.dwAvgBytesPerSec =
+		internal->wave.common.wChannels *
 		internal->wave.common.dwSamplesPerSec *
 		(internal->wave.common.wBitsPerSample >> 3);
 
-	internal->wave.common.wBlockAlign = 
-		internal->wave.common.wChannels * 
+	internal->wave.common.wBlockAlign =
+		internal->wave.common.wChannels *
 		(internal->wave.common.wBitsPerSample >> 3);
 
 	strncpy(internal->wave.data.id, "data",4);
@@ -184,7 +184,7 @@
 	strncpy(buf+36, internal->wave.data.id, 4);
 	WRITE_U32(buf+40, internal->wave.data.len);
 
-	if (fwrite(buf, sizeof(char), WAV_HEADER_LEN, device->file) 
+	if (fwrite(buf, sizeof(char), WAV_HEADER_LEN, device->file)
 	    != WAV_HEADER_LEN) {
 		return 0; /* Could not write wav header */
 	}
@@ -198,15 +198,15 @@
 /*
  * play the sample to the already opened file descriptor
  */
-static int ao_wav_play(ao_device *device, const char *output_samples, 
+static int ao_wav_play(ao_device *device, const char *output_samples,
 			uint_32 num_bytes)
 {
-	if (fwrite(output_samples, sizeof(char), num_bytes, 
+	if (fwrite(output_samples, sizeof(char), num_bytes,
 		   device->file) < num_bytes)
 		return 0;
 	else
 		return 1;
-	
+
 }
 
 static int ao_wav_close(ao_device *device)
@@ -231,7 +231,7 @@
 	/* Rewind to riff len and write it */
 	if (fseek(device->file, 4, SEEK_SET) < 0)
 		return 0; /* Wav header corrupt */
-	
+
 	WRITE_U32(buf, internal->wave.riff.len);
 	if (fwrite(buf, sizeof(char), 4, device->file) < 4)
 	  return 0; /* Wav header corrupt */
@@ -240,12 +240,12 @@
 	/* Rewind to data len and write it */
 	if (fseek(device->file, 40, SEEK_SET) < 0)
 		return 0; /* Wav header corrupt */
-	
+
 	WRITE_U32(buf, internal->wave.data.len);
 	if (fwrite(buf, sizeof(char), 4, device->file) < 4)
 	  return 0; /* Wav header corrupt */
 
-       
+
 	return 1; /* Wav header correct */
 }
 
@@ -267,4 +267,3 @@
 	ao_wav_close,
 	ao_wav_device_clear
 };
-



More information about the commits mailing list