[MPlayer-dev-eng] [PATCH] don't use unsupported audio plugins, use all plugins (bugfix)

Christian Ohm chr.ohm at gmx.net
Thu Jun 6 23:37:01 CEST 2002


On Wednesday,  5 June 2002 at 23:09, Felix Buenemann wrote:
> On Wednesday 05 June 2002 03:47, Felix Buenemann wrote:
> > can you give a simple test-case commandline so I can check your changes
> > before applying to cvs?

mplayer -aop list=volnorm filethatdoesnthave16bitsignedlittleendiansound

without the patch, mplayer quits, with it it just doesn't use the plugin.

or
mplayer -aop list=volnorm,volume,extrastereo filewith8bitsound

runs and uses just the volume plugin. (where the file can of course be a wav
file that has been run through sox to have the required format.)

> And I just noted a problem in your patch:
>    if(ao_plugin_cfg.plugin_list){
> -    if(!add_plugin(i,ao_plugin_cfg.plugin_list))
> +    config = malloc(strlen(ao_plugin_cfg.plugin_list));
> +    if (!strcpy(config, ao_plugin_cfg.plugin_list))
>        return 0;
> +    if(!add_plugin(i,config))
> +      return 0;
> +    free(config);
>    }
> 
> see, in case of an early return 0, config doesn't get freed, so you should 
> make sure it is freed before returning.

well, right now mplayer quits on a 'return 0'. but i've made a new patch
that frees config (and catches a failed malloc, too).

bye
christian ohm

-- 
Sorry.  Nice try.
-------------- next part --------------
Index: libao2/ao_plugin.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_plugin.c,v
retrieving revision 1.18
diff -u -r1.18 ao_plugin.c
--- libao2/ao_plugin.c	30 May 2002 11:53:51 -0000	1.18
+++ libao2/ao_plugin.c	6 Jun 2002 21:48:38 -0000
@@ -116,13 +116,21 @@
 // open & setup audio device and plugins
 // return: 1=success 0=fail
 static int init(int rate,int channels,int format,int flags){
+  int use_plugin[NPL];
+  int x,npl,unused=0;
   int ok=1;
+  char *config;
 
   // Create list of plugins from cfg option
   int i=0; 
   if(ao_plugin_cfg.plugin_list){
-    if(!add_plugin(i,ao_plugin_cfg.plugin_list))
+    config = malloc(strlen(ao_plugin_cfg.plugin_list));
+    if(!config) return 0;
+    if(!strcpy(config, ao_plugin_cfg.plugin_list) || !add_plugin(i,config)){
+      free(config);
       return 0;
+    }
+    free(config);
   }
 
   /* Set input parameters and itterate through plugins each plugin
@@ -139,11 +147,21 @@
   ao_plugin_data.sz_fix=0;
   ao_plugin_data.delay_mult=1;
   ao_plugin_data.delay_fix=0;
-  i=0;
-  while(plugin(i)&&ok)
-    ok=plugin(i++)->init();
-  
-  if(!ok) return 0;
+
+  for(i=0;i<NPL,plugin(i);i++){
+    use_plugin[i]=plugin(i)->init();
+    if(!use_plugin[i]) plugin(i)->uninit();
+  }
+  npl=i;
+  for(i=0;i<npl,plugin(i);i++)
+    if(!use_plugin[i+unused]){
+      unused++;
+      for(x=i;x<npl,plugin(x+1);x++) plugin(x)=plugin(x+1);
+      plugin(x)=NULL;
+      npl--;
+      i--;
+    }
+  i=npl;
 
   // Calculate bps
   ao_plugin_local_data.bps=(float)(ao_plugin_data.rate * 


More information about the MPlayer-dev-eng mailing list