[vorbis-dev] libao patch: Minor clean up / Byte-order proposal

volsung at asu.edu volsung at asu.edu
Sat Aug 12 20:53:38 PDT 2000



Here is a patch to fix the compiler warnings I mentioned earlier.  I've
removed the byte-order changes that don't make sense.  (Thanks Michael for
pointing out the error!)

As for the byte-order changes, since some output modules don't have the option
to set the sample byte-order, I would like to standardize libao and ogg123 on
native byte-order.  Will this break the ao_wav.c patches you just submitted,
Michael?  

If there aren't any objections, I'll send the patch to fix the byte-order
problem on Monday. 


---
Stan Seibert





Index: vorbis-tools/libao/ao_alsa.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/vorbis-tools/libao/ao_alsa.c,v
retrieving revision 1.1
diff -u -r1.1 ao_alsa.c
--- vorbis-tools/libao/ao_alsa.c	2000/07/22 01:57:05	1.1
+++ vorbis-tools/libao/ao_alsa.c	2000/08/13 00:30:01
@@ -38,7 +38,7 @@
 typedef struct ao_alsa_internal_s
 {
 	snd_pcm_t *pcm_handle;
-	void *buf;
+	char *buf;
 	int buf_size;
 	int buf_end;
 	int card;
@@ -191,9 +191,9 @@
 ao_alsa_play (ao_internal_t *state, void* output_samples, uint_32 num_bytes)
 {
 	ao_alsa_internal_t *s = (ao_alsa_internal_t *) state;
-	snd_pcm_t *pcm_handle = s->pcm_handle;
 	int packed = 0;
 	int copy_len;
+	char *samples = (char *) output_samples;
 
 	while (packed < num_bytes)
 	{
@@ -203,9 +203,7 @@
 		else
 			copy_len = s->buf_size-s->buf_end;
 
-		memcpy(s->buf + s->buf_end, 
-		       output_samples + packed,
-		       copy_len); 
+		memcpy(s->buf + s->buf_end, samples + packed, copy_len); 
 		packed += copy_len;
 		s->buf_end += copy_len;
 
Index: vorbis-tools/libao/ao_null.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/vorbis-tools/libao/ao_null.c,v
retrieving revision 1.1
diff -u -r1.1 ao_null.c
--- vorbis-tools/libao/ao_null.c	2000/07/22 01:57:05	1.1
+++ vorbis-tools/libao/ao_null.c	2000/08/13 00:30:01
@@ -59,7 +59,7 @@
 static void
 ao_null_close (ao_internal_t *state)
 {
-	fprintf(stderr, "ao_null: %d bytes sent to null device.\n",
+	fprintf(stderr, "ao_null: %ld bytes sent to null device.\n",
 		((ao_null_internal_t *) state)->byte_counter);
 }
 
Index: vorbis-tools/libao/audio_out.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/vorbis-tools/libao/audio_out.c,v
retrieving revision 1.1
diff -u -r1.1 audio_out.c
--- vorbis-tools/libao/audio_out.c	2000/07/22 01:57:05	1.1
+++ vorbis-tools/libao/audio_out.c	2000/08/13 00:30:01
@@ -109,10 +109,6 @@
 
 
 
-/* --- Device Table --- */
-
-
-
 /* --- Driver Functions --- */
 
 /* This should have been set by the Makefile */
@@ -169,7 +165,6 @@
 	ao_functions_t *funcs;
 	ao_internal_t *state;
 	ao_device_t *device;
-	int dev_id;
 
 	if (ao_check_driver_id(driver_id))
 	{
@@ -209,37 +204,28 @@
 	char *copy;
 	char *value_ptr;
 	char *colon;
-	ao_option_t *op;
-	int fail = 0;
-
-	copy = strdup(op_str);
-
-	colon = strchr(copy, ':');
-	if (colon == NULL)
-		fail = 1;
-	else
-	{
-		value_ptr = colon + 1;
-		*colon = 0x00; // Null terminate the key part
-		
-		// Allocate the option structure
-		op = malloc(sizeof(ao_option_t));
-		if (op == NULL)
-			fail = 1;
-		else
-		{
-			op->key = strdup(copy);
-			op->value = strdup(value_ptr);
-			op->next = NULL;
-		}
-	}
-
-	free(copy);
-
-	if (fail)
-		return NULL;
-	else
-		return op;
+        ao_option_t *op = NULL;
+	
+        copy = strdup(op_str);
+	
+        colon = strchr(copy, ':');
+        if (colon != NULL) 
+        {
+                value_ptr = colon + 1;
+                *colon = 0x00; // Null terminate the key part
+                
+                // Allocate the option structure
+                op = malloc(sizeof(ao_option_t));
+                if (op != NULL)
+                {
+                        op->key = strdup(copy);
+                        op->value = strdup(value_ptr);
+                        op->next = NULL;
+                }
+        }
+	
+        free(copy);
+        return op;
 }
 
 

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/



More information about the Vorbis-dev mailing list