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

Zuxy Meng zuxy.meng at gmail.com
Sun Jun 3 09:24:31 CEST 2007


Hi,

2007/6/3, Compn <tempn at twmi.rr.com>:
> On Sun, 03 Jun 2007 00:07:09 +0800, Zuxy Meng scribed:
>
> >Hi,
> >
> >2007/5/30, Zuxy Meng <zuxy.meng at gmail.com>:
> >> Hi,
> >>
> >> af pan doesn't allow zero output channel at initialization, which
> >> makes it impossible to af_add it. This patch initialize the number of
> >> output channels as the same as that of input channels.
> >>
> >> It might fix Bug 818 too but I'm unsure about that.
> >
> >No comments?
>
> it fixes bug 818. switch_audio with af pan continues without exiting...
> but now the audio is silent after switching. (weirdly enough, changing
> the balance a little bit will make the audio come back).
>
> http://samples.mplayerhq.hu/avi/2-audio-streams.avi

The problem is that previous setting for pan will be lost after you've
switched the audio stream, and the default setting is all zero, i.e.
mute. It can be fixed by change the default setting to 'pass-thru', as
in the attached patch.

It's a bit interesting that although the proper comment had been
there, the 'pass-thru' wasn't implemented. Maybe the author had
intended to do so but eventually forgot it?
-- 
Zuxy
Beauty is truth,
While truth is beauty.
PGP KeyID: E8555ED6
-------------- next part --------------
Index: libaf/af_pan.c
===================================================================
--- libaf/af_pan.c	?????? 23450??
+++ libaf/af_pan.c	????????????
@@ -35,6 +35,8 @@
     // Sanity check
     if(!arg) return AF_ERROR;
 
+    if (af->data->nch == 0)
+      af->data->nch = ((af_data_t*)arg)->nch;
     af->data->rate   = ((af_data_t*)arg)->rate;
     af->data->format = AF_FORMAT_FLOAT_NE;
     af->data->bps    = 4;
@@ -164,6 +166,7 @@
 
 // Allocate memory and set function pointers
 static int af_open(af_instance_t* af){
+  int i;
   af->control=control;
   af->uninit=uninit;
   af->play=play;
@@ -174,6 +177,8 @@
   if(af->data == NULL || af->setup == NULL)
     return AF_ERROR;
   // Set initial pan to pass-through.
+  for (i = 0; i < AF_NCH; i++)
+    ((af_pan_t*)af->setup)->level[i][i] = 1.f;
   return AF_OK;
 }
 


More information about the MPlayer-dev-eng mailing list