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

Alban Bedel albeu at free.fr
Thu May 31 15:02:50 CEST 2007


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

> +    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.

	Albeu




More information about the MPlayer-dev-eng mailing list