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

Jehan Pagès jehan.marmottard at gmail.com
Sat Apr 3 19:58:38 CEST 2010


Hi,

On Sun, Apr 4, 2010 at 2:42 AM, Reimar Döffinger
<Reimar.Doeffinger at gmx.de> wrote:
>> +            af_uninit ((&mpctx->mixer)->afilter);
>
> mpctx->mixer.afilter
> is the right syntax for that.

Oups right.

>> +    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"?
Is something like that better:

>> +    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;
>> +            while ((af_command = strsep (&af_commands, ",")) != NULL)
>> +                af_add ((&mpctx->mixer)->afilter, af_command);
>> +            build_afilter_chain(sh_audio, &ao_data);
>> +            free (af_args);
>> +        }

Sorry if I didn't understand otherwise.
Thanks.

Jehan



More information about the MPlayer-dev-eng mailing list