changeset 6026:16e33d66b813

added audio_out_format_bits to calc len alignment
author iive
date Thu, 09 May 2002 07:39:33 +0000
parents 4dc96c97ac07
children 7c26ef54ff14
files libao2/afmt.c libao2/audio_out.h
diffstat 2 files changed, 38 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libao2/afmt.c	Thu May 09 00:45:36 2002 +0000
+++ b/libao2/afmt.c	Thu May 09 07:39:33 2002 +0000
@@ -45,3 +45,40 @@
     }
     return("Unknown");
 }
+
+// return number of bits for 1 sample in one channel, or 8 bits for compressed
+int audio_out_format_bits(int format){
+    switch (format)
+    {
+/*
+  the following two formats are not available with old linux kernel
+  headers (e.g. in 2.2.16)
+*/
+#ifdef AFMT_S32_LE
+	case AFMT_S32_LE:
+	return 32;
+#endif
+#ifdef AFMT_S32_BE
+	case AFMT_S32_BE:
+	return 32;
+#endif
+
+	case AFMT_U16_LE:
+	case AFMT_U16_BE: 
+	case AFMT_S16_LE:
+	case AFMT_S16_BE:
+	return 16;//16 bits
+	
+	case AFMT_MU_LAW:
+	case AFMT_A_LAW:
+	case AFMT_IMA_ADPCM:
+	case AFMT_S8:
+	case AFMT_U8:
+	case AFMT_MPEG:
+	case AFMT_AC3:
+	default:
+	    return 8;//default 1 byte
+	
+    }
+    return 8;
+}
\ No newline at end of file
--- a/libao2/audio_out.h	Thu May 09 00:45:36 2002 +0000
+++ b/libao2/audio_out.h	Thu May 09 07:39:33 2002 +0000
@@ -42,6 +42,7 @@
 
 // prototypes
 extern char *audio_out_format_name(int format);
+extern int   audio_out_format_bits(int format);
 
 // NULL terminated array of all drivers
 extern ao_functions_t* audio_out_drivers[];