[MPlayer-dev-eng] [PATCH] New command support select sub by source and ID
Ulion
ulion2002 at gmail.com
Thu Nov 22 06:55:58 CET 2007
2007/11/18, Ulion <ulion2002 at gmail.com>:
> 2007/11/16, Ulion <ulion2002 at gmail.com>:
> > 2007/11/16, Alban Bedel <albeu at free.fr>:
> > > On Thu, 15 Nov 2007 18:11:46 +0800
> > > Ulion <ulion2002 at gmail.com> wrote:
> > >
> > >
> > > > > > + case M_PROPERTY_SET:
> > > > > > + if (!arg || *(int *) arg < -1 || *(int *) arg >=
> > > > > > SUB_SOURCES)
> > > > > > + return M_PROPERTY_ERROR;
> > > > >
> > > > > It should just clamp the parameter into the valid range instead of
> > > > > returning an error.
> > > >
> > > > I already did that, at:
> > > > { "sub_source", mp_property_sub_source, CONF_TYPE_INT,
> > > > M_OPT_RANGE, -1, SUB_SOURCES - 1, NULL },
> > >
> > > No, this just fill in the info, you still have to use it. With the
> > > M_PROPERTY_CLAMP() macro for ex.
> >
> > OK, now I known.
> >
> > >
> > > > >
> > > > > > + if (*(int *) arg < 0)
> > > > > > + mpctx->global_sub_pos = -1;
> > > > > > + else if (*(int *) arg != sub_source(mpctx)) {
> > > > > > + if (*(int *) arg != sub_source_by_pos(mpctx,
> > > > > > mpctx->global_sub_indices[*(int *) arg]))
> > > > > > + return M_PROPERTY_UNAVAILABLE;
> > > > > > + mpctx->global_sub_pos = mpctx->global_sub_indices[*
> > > > > > (int *) arg];
> > > > > > + }
> > > > > > + break;
> > > > >
> > > > > And it should return the value effectively set (like GET do).
> > > >
> > > > Indeed the code did return the value effectively set, when arg < 0, it
> > > > must be -1, we set -1, and the effectively set value also -1, no need
> > > > to change the value. when arg >= 0, I have a check call
> > > > sub_source_by_pos to see whether the effectively set value is same
> > > > with the input arg, when they not match, set fail, else set it, the
> > > > input arg is just the effectively set value we make it sure here.
> > >
> > > It might not if the input was out of range and needed to be clamped to
> > > the valid range.
> >
> > OK, clamped version here.
>
> Then, I think it's ready to commit, I will wait a week to apply if no
> objects or suggestions.
>
If no objects, I will apply in 3 days.
--
Ulion
More information about the MPlayer-dev-eng
mailing list