[linux-dvb] What do you think of mpsys library ? (for ca_zap)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Apr 02, 2005 at 12:28:20AM +0200, Kenneth Aafl?y wrote:
> On Saturday 02 April 2005 00:13, Johannes Stezenbach wrote:
> > Kenneth Aafl?y wrote:
> > > } vid_dev_info_t;
> > 
> > Please don't use typedefs unless you are explicitly defining
> > opaque data types. It makes it more difficult to see what's going on.
> 
> I'm wondering if you recentment is against the typedef in general or the
> implementation of a clean api.

I'm neither agains typedefs, where they make sense, nor against clean APIs.

> The api will be well documented, and so
> will the new typedefed types? I was merily following the alsa api here,
> so I'm not in any way married to it yet! Any suggestions is very much
> welcome, please prove why your suggestion will produce a cleaner api.

Typedefs have a purpose: Creating an abstraction, i.e. hiding
information about the type from the user. IMHO it is totally useless to
stick a typedef on every struct or enum definition. All you get is
obfuscation. And the _t suffixes are ugly, too.
Please ask yourself if and why you want to hide from the users
of your API why e.g. vid_dev_hierarchy_t is an enum.


> /**
>  * Set/Get DVB/ATSC parameters of the channel.
>  * XXX - combined struct ??
>  */
> 
> typedef enum _vid_channel_param {
>         VID_CHANNEL_PARAM_INVERSION,
>         VID_CHANNEL_PARAM_FEC_RATE,
>         VID_CHANNEL_PARAM_LOW_FEC_RATE,
>         VID_CHANNEL_PARAM_MODULATION,
>         VID_CHANNEL_PARAM_BANDWIDTH,
>         VID_CHANNEL_PARAM_TRANSMISSION_MODE,
>         VID_CHANNEL_PARAM_GUARD_INTERVAL,
>         VID_CHANNEL_PARAM_HIERARCHY,
> 
>         VID_CHANNEL_PARAM_LAST
> } vid_channel_param_t;
> 
> int vid_channel_set_param(vid_channel_param_t, int value);
> int vid_channel_get_param(vid_channel_param_t);

I would prefer to use a struct, or rather a union of structs for
each transmission system. You'd get nuts when you need a dozen
function calls to tune or update the channel list.

Johannes



[Index of Archives]     [Linux Media]     [Video 4 Linux]     [Asterisk]     [Samba]     [Xorg]     [Xfree86]     [Linux USB]

  Powered by Linux