changeset 29708:38a054e832c7

fix calculation of ao_data.bps for sample formats with more than 16 bits
author cladisch
date Mon, 05 Oct 2009 07:42:02 +0000
parents 4a6ec8b958c4
children 750ebb6ee49a
files libao2/ao_oss.c
diffstat 1 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libao2/ao_oss.c	Sun Oct 04 21:10:13 2009 +0000
+++ b/libao2/ao_oss.c	Mon Oct 05 07:42:02 2009 +0000
@@ -396,8 +396,19 @@
   }
 
   ao_data.bps=ao_data.channels;
-  if(ao_data.format != AF_FORMAT_U8 && ao_data.format != AF_FORMAT_S8)
+  switch (ao_data.format & AF_FORMAT_BITS_MASK) {
+  case AF_FORMAT_8BIT:
+    break;
+  case AF_FORMAT_16BIT:
     ao_data.bps*=2;
+    break;
+  case AF_FORMAT_24BIT:
+    ao_data.bps*=3;
+    break;
+  case AF_FORMAT_32BIT:
+    ao_data.bps*=4;
+    break;
+  }
 
   ao_data.outburst-=ao_data.outburst % ao_data.bps; // round down
   ao_data.bps*=ao_data.samplerate;