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

Zuxy Meng zuxy.meng at gmail.com
Tue Jun 5 11:32:53 CEST 2007


Hi,

2007/6/5, Reimar Doeffinger <Reimar.Doeffinger at stud.uni-karlsruhe.de>:
> Hello,
> On Sun, Jun 03, 2007 at 10:07:57PM +0800, Zuxy Meng wrote:
> > 2007/6/3, Reimar Döffinger <Reimar.Doeffinger at stud.uni-karlsruhe.de>:
> > > On Wed, May 30, 2007 at 10:49:27PM +0800, Zuxy Meng wrote:
> > > [...]
> > > > Index: libaf/af_pan.c
> > > > ===================================================================
> > > > --- libaf/af_pan.c    ?????? 23404??
> > > > +++ 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;
> > >
> > > IMO the bug is that af->data->nch should never be zero and the bug is
> > > elsewhere.
> >
> > Why? (af_data_t*)arg->nch shouldn't but af->data->nch may not be
> > guaranteed to be nonzero. Actually all other filters initialize
> > af->data->nch upon REINIT.
>
> No, only those that do not change channels of course do it.
> E.g. af_channels does not. In both cases the number of output channels
> is specified on the command line, and should either be respected or the
> user informed that the command line is incorrect instead of just doing
> "something".

The sequence for handling command line input is
AF_CONTROL_POST_CREATE->AF_CONTROL_COMMAND_LINE->AF_CONTROL_PAN_NOUT->AF_CONTROL_REINIT.
AF_CONTROL_PAN_NOUT won't allow zero output channel so the command
line will be rejected as before. And since af->data->nch is already
nonzero upon REINIT, it won't be overwritten. After all, original
behavior remains the same.

But instead we call af_add() for pan, the sequence will be
AF_CONTROL_POST_CREATE->AF_CONTROL_REINIT->AF_CONTROL_PAN_NOUT. If we
don't assign a non-zero value to af->data->nch, AF_CONTROL_REINT of af
pan will always fail and we have no chance to add this filter at
runtime, which is needed for (soft) audio balance control.

-- 
Zuxy
Beauty is truth,
While truth is beauty.
PGP KeyID: E8555ED6



More information about the MPlayer-dev-eng mailing list