[MPlayer-dev-eng] [PATCH] New commands for loading/unloading audio filters at runtime

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sun Apr 4 08:40:09 CEST 2010


On Sun, Apr 04, 2010 at 02:58:38AM +0900, Jehan Pagès wrote:
> >> +    case MP_CMD_AF_ADD:
> >> +        if (!sh_audio)
> >> +            break;
> >> +        {
> >> +            char* af_args = strdup(cmd->args[0].v.s);
> >> +            char* af_commands = af_args;
> >> +            char* af_command = strsep (&af_commands, ",");
> >> +            while (af_command != NULL)
> >> +            {
> >> +                af_add ((&mpctx->mixer)->afilter, af_command);
> >> +                af_command = strsep (&af_commands, ",");
> >> +            }
> >> +            build_afilter_chain(sh_audio, &ao_data);
> >> +            free (af_args);
> >> +        }
> >
> > Hm, this boiler-plate code is always the same and it's not performance-critical.
> > Maybe you could do a switch inside the while and this avoid duplicating
> > any code?
> 
> The duplicated code that annoys you here is the strsep line before the
> loop and then inside it? What do you mean "do a switch inside the
> while"?

No I meant
> >> +        if (!sh_audio)
> >> +            break;
> >> +        {
> >> +            char* af_args = strdup(cmd->args[0].v.s);
> >> +            char* af_commands = af_args;
> >> +            char* af_command = strsep (&af_commands, ",");
> >> +            while (af_command != NULL)
> >> +            {
switch (command)
{
case MP_CMD_AF_ADD:
> >> +                af_add ((&mpctx->mixer)->afilter, af_command);
break;
case MP_CMD_AF_DEL:
af_del(...);
break;
> >> +                af_command = strsep (&af_commands, ",");
> >> +            }
> >> +            build_afilter_chain(sh_audio, &ao_data);
> >> +            free (af_args);
> >> +        }



More information about the MPlayer-dev-eng mailing list