[MPlayer-dev-eng] [PATCH] Audio balance feature

Zuxy Meng zuxy.meng at gmail.com
Tue Jun 5 03:13:28 CEST 2007


Hi,

2007/5/31, Zuxy Meng <zuxy.meng at gmail.com>:
> Hi,
>
> 2007/5/31, Alban Bedel <albeu at free.fr>:
> > On Thu, 31 May 2007 20:13:53 +0800
> > "Zuxy Meng" <zuxy.meng at gmail.com> wrote:
> >
> > > +    case M_PROPERTY_STEP_UP:
> > > +     step = .1f;
> > > +     // falling thru
> > > +    case M_PROPERTY_STEP_DOWN:
> > > +     step = -.1f;
> > > +     // falling thru
> >
> > Both cases will get step = -.1
>
> Ooops....
>
> >
> > > +    case M_PROPERTY_SET:
> > > +     if (action == M_PROPERTY_SET) {
> > > +         if (!arg)
> > > +             return M_PROPERTY_ERROR;
> > > +         bal = *(float*)arg;
> >
> > SET should return the value set if possible.
> >
> > > +     } else {
> > > +         if (arg)
> > > +             step = *(float*)arg;
> > > +         mixer_getbalance(&mpctx->mixer, &bal);
> > > +         bal += step;
> > > +     }
> > > +     M_PROPERTY_CLAMP(prop, bal);
> > > +     mixer_setbalance(&mpctx->mixer, bal);
> > > +     return M_PROPERTY_OK;
> > > +    }
> >
> > Better simply do something like:
> >
> >    case M_PROPERTY_SET:
> >        if (!arg) return M_PROPERTY_ERROR;
> >        M_PROPERTY_CLAMP(prop, *(float*)arg);
> >        mixer_setbalance(&mpctx->mixer, *(float*)arg);
> >        return M_PROPERTY_OK;
> >
> >    case M_PROPERTY_STEP_UP:
> >    case M_PROPERTY_STEP_DOWN:
> >        mixer_getbalance(&mpctx->mixer, &bal);
> >        bal += (arg ? *(float*)arg : 0.1) *
> >            (action == M_PROPERTY_STEP_UP ? 1.0 : -1.0);
> >        M_PROPERTY_CLAMP(prop, bal);
> >        mixer_setbalance(&mpctx->mixer, bal);
> >        return M_PROPERTY_OK;
> >
> > and you'll get correct behaviour everywhere.
>
> Thanks! See if this one's better.

Will apply this weekend of no one objects.
-- 
Zuxy
Beauty is truth,
While truth is beauty.
PGP KeyID: E8555ED6



More information about the MPlayer-dev-eng mailing list