[Mplayer-cvslog] CVS: main/libao2 ao_plugin.c,1.16,1.17

Ivan Kalvachev iive at mplayerhq.hu
Thu May 9 09:41:28 CEST 2002


Update of /cvsroot/mplayer/main/libao2
In directory mail:/var/tmp.root/cvs-serv11624

Modified Files:
	ao_plugin.c 
Log Message:
fixed sdl+resample bug coused by float point to int rounding error

Index: ao_plugin.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_plugin.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- ao_plugin.c	21 Apr 2002 16:56:19 -0000	1.16
+++ ao_plugin.c	9 May 2002 07:41:25 -0000	1.17
@@ -27,13 +27,16 @@
 {
   void* buf;					 // Output data buffer
   int len;					 // Amount of data in buffer
+  int channels;
+  int format;
+  int bpm;   //bit of format
   float bps;					 // Bytes per second out
   ao_functions_t* driver;      			 // Output driver
   ao_plugin_functions_t** plugins;               // List of used plugins
   ao_plugin_functions_t* available_plugins[NPL]; // List of available plugins
 } ao_plugin_local_data_t;
 
-static ao_plugin_local_data_t ao_plugin_local_data={NULL,0,0.0,NULL,NULL,AO_PLUGINS};
+static ao_plugin_local_data_t ao_plugin_local_data={NULL,0,0,0,0,0.0,NULL,NULL,AO_PLUGINS};
 
 // global data 
 volatile ao_plugin_data_t ao_plugin_data;             // Data used by the plugins
@@ -123,6 +126,11 @@
 
   /* Set input parameters and itterate through plugins each plugin
      changes the parameters according to its output */
+
+  ao_plugin_local_data.format=format;
+  ao_plugin_local_data.channels=channels;
+  ao_plugin_local_data.bpm=audio_out_format_bits(format);
+
   ao_plugin_data.rate=rate;
   ao_plugin_data.channels=channels;
   ao_plugin_data.format=format;
@@ -139,16 +147,7 @@
   // Calculate bps
   ao_plugin_local_data.bps=(float)(ao_plugin_data.rate * 
 				   ao_plugin_data.channels);
-
-  if(ao_plugin_data.format == AFMT_S16_LE ||
-     ao_plugin_data.format == AFMT_S16_BE ||
-     ao_plugin_data.format == AFMT_U16_LE ||
-     ao_plugin_data.format == AFMT_U16_BE)
-    ao_plugin_local_data.bps *= 2;
-
-  if(ao_plugin_data.format == AFMT_S32_LE ||
-     ao_plugin_data.format == AFMT_S32_BE)
-    ao_plugin_local_data.bps *= 4;
+  ao_plugin_local_data.bps*=audio_out_format_bits(ao_plugin_data.format)/8;
 
   // This should never happen but check anyway 
   if(NULL==ao_plugin_local_data.driver)
@@ -213,12 +212,16 @@
 
 // return: how many bytes can be played without blocking
 static int get_space(){
-  double sz=(double)(driver()->get_space());
+double sz;
+int isz;
+  sz=(double)(driver()->get_space());
   if(sz+(double)ao_plugin_local_data.len > (double)MAX_OUTBURST)
     sz=(double)MAX_OUTBURST-(double)ao_plugin_local_data.len;
   sz*=ao_plugin_data.sz_mult;
   sz+=ao_plugin_data.sz_fix;
-  return (int)(sz);
+  isz=(int)(sz);
+  isz-=isz%(ao_plugin_local_data.channels*ao_plugin_local_data.bpm/8);
+  return isz;
 }
 
 // plays 'len' bytes of 'data'
@@ -232,6 +235,11 @@
     // Filter data
     ao_plugin_data.len=ret_len;
     ao_plugin_data.data=data;
+
+// update plugins and uncoment that
+//    ao_plugin_data.channels=ao_plugin_local_data.channels;
+//    ao_plugin_data.format=ao_plugin_local_data.format;
+    
     while(plugin(i))
       plugin(i++)->play();
     // Copy data to output buffer




More information about the MPlayer-cvslog mailing list