[Gstreamer-openmax] [PATCH] add some utility macros to get/set core and port configs/params

Rob Clark rob at ti.com
Sat Feb 27 10:24:43 PST 2010


On Nov 25, 2009, at 11:21 AM, Felipe Contreras wrote:

> On Mon, Nov 23, 2009 at 7:25 AM, Rob Clark <rob at ti.com> wrote:
>> but an inline function could not figure out sizeof() properly.. so this
>> would have to be passed as an additional parameter.  (although a combination
>> of a macro calling an inline fxn could work)
>> 
>> sometimes macro's are a necessary evil ;-)
> 
> Right, but in my opinion if you need a macro chances are you are doing
> something wrong and the code becomes more convoluted.
> 
> I this particular case I think it makes sense to write a macro that wraps:
> OMX_AUDIO_PARAM_PCMMODETYPE param = {
>       .nSize = sizeof(param),
>       .nVersion = OMX_VERSION,
> };
> 
> But that's it. Then a separate inline function that does:
> param.nPortIndex = 1;
> OMX_GetParameter(omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
> 
> This way it would be possible to call OMX_SetParameter without
> OMX_GetParameter (in case you are setting all the fields).



btw, I'm thinking about this one again..

how about, in case of setting all params:

   OMX_AUDIO_PARAM_PCMMODETYPE param;

   G_OMX_INIT_PARAM (param);

   ...  set params ...

   G_OMX_PORT_SET_PARAM (port, OMX_IndexParamAudioPcm, &param);

or in case where you just want to set a few params:

   OMX_AUDIO_PARAM_PCMMODETYPE param;

   G_OMX_PORT_GET_PARAM (port, OMX_IndexParamAudioPcm, &param);

   ...  set params ...

   G_OMX_PORT_SET_PARAM (port, OMX_IndexParamAudioPcm, &param);


(SET_PARAM could be a fxn.. but INIT_PARAM and GET_PARAM would have to be a macro... although they could be a simple macro just passing an extra sizeof() param to a helper function rather than a pure macro)

------

the other approach would be something like:


   G_OMX_DECLARE_PARAM (OMX_AUDIO_PARAM_PCMMODETYPE, param);

   ...  set params ...

   g_omx_port_set_param (port, OMX_IndexParamAudioPcm, &param);

or in case where you just want to set a few params:

   G_OMX_DECLARE_PARAM (OMX_AUDIO_PARAM_PCMMODETYPE, param);

   g_omx_port_get_param (port, OMX_IndexParamAudioPcm, &param);

   ...  set params ...

   g_omx_port_set_param (port, OMX_IndexParamAudioPcm, &param);

in this case {get,set}_{config,param} could be functions..  but the macro to declare the param variable is a bit funny looking.

Or you could do something like:

   OMX_AUDIO_PARAM_PCMMODETYPE param = G_OMX_PARAM_INITIALIZER ();

but that forces the variable name to be only 'param', which will cause problems for me..

or:

   OMX_AUDIO_PARAM_PCMMODETYPE param = G_OMX_PARAM_INITIALIZER (param);

but again, that seems a bit funny looking to me..



Thoughts?


BR,
-R






More information about the Gstreamer-openmax mailing list