[MPlayer-dev-eng] [PATCH] af_pan.c: Avoid zero output channels when reinit af pan

Reimar Doeffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Sun Jun 10 19:27:47 CEST 2007


Hello,
On Sun, Jun 10, 2007 at 07:16:23PM +0200, Reimar Doeffinger wrote:
> On Sun, Jun 10, 2007 at 07:04:57PM +0800, Zuxy Meng wrote:
> [...]
> > I got tired about this issue.  All I want is an audio filter used for
> > balancing that can be 'af_add()'ed at runtime and doesn't alter the #
> > of channels before and after it. If one day you come up with an ideal
> > solution, pls kindly ping me.
> 
> You'd only have to add nch to af_pan_t, set that in the comamndline
> control and on reinit read it end set af->data->nch to it if it's
> non-zero or to the current number of channels otherwise.

As in attached patch. As my development machines are all dead currently
I can't test beyond compilation.
If it is somehow possible to use this feature from the command line it
should be documented, too.

Greetings,
Reimar Doeffinger
-------------- next part --------------
Index: libaf/af_pan.c
===================================================================
--- libaf/af_pan.c	(revision 23461)
+++ libaf/af_pan.c	(working copy)
@@ -22,6 +22,7 @@
 // Data for specific instances of this filter
 typedef struct af_pan_s
 {
+  int nch;
   float level[AF_NCH][AF_NCH];	// Gain level for each channel
 }af_pan_t;
 
@@ -38,6 +39,7 @@
     af->data->rate   = ((af_data_t*)arg)->rate;
     af->data->format = AF_FORMAT_FLOAT_NE;
     af->data->bps    = 4;
+    af->data->nch    = s->nch ? s->nch : ((af_data_t*)arg)->nch;
     af->mul.n        = af->data->nch;
     af->mul.d	     = ((af_data_t*)arg)->nch;
     af_frac_cancel(&af->mul);
@@ -99,12 +101,12 @@
     // Reinit must be called after this function has been called
 
     // Sanity check
-    if(((int*)arg)[0] <= 0 || ((int*)arg)[0] > AF_NCH){
+    if(((int*)arg)[0] < 0 || ((int*)arg)[0] > AF_NCH){
       af_msg(AF_MSG_ERROR,"[pan] The number of output channels must be" 
-	     " between 1 and %i. Current value is %i\n",AF_NCH,((int*)arg)[0]);
+	     " between 0 and %i. Current value is %i\n",AF_NCH,((int*)arg)[0]);
       return AF_ERROR;
     }
-    af->data->nch=((int*)arg)[0];
+    s->nch=((int*)arg)[0];
     return AF_OK;
   case AF_CONTROL_PAN_NOUT | AF_CONTROL_GET:
     *(int*)arg = af->data->nch;


More information about the MPlayer-dev-eng mailing list