[alsa-devel] [RFC] usb-audio: Use a table of mixer controls

Takashi Iwai tiwai at suse.de
Sat May 12 09:45:00 CEST 2012


At Sat, 12 May 2012 00:21:14 +0100 (BST),
Mark Hills wrote:
> 
> On Fri, 11 May 2012, Takashi Iwai wrote:
> 
> > > +/*
> > > + * The mixer units for Ebox-44 are corrupt, and even where they
> > > + * are valid they presents mono controls as L and R channels of
> > > + * stereo. So we create provide a good mixer here.
> > > + */
> > > +struct std_mono_table ebox44_table[] = {
> > > +	{ 4, 1, 0x0, USB_MIXER_INV_BOOLEAN, "Headphone Playback Switch", NULL },
> > > +	{ 4, 2, 0x1, USB_MIXER_S16, "Headphone A Mix Playback Volume", NULL },
> > > +	{ 4, 2, 0x2, USB_MIXER_S16, "Headphone B Mix Playback Volume", NULL },
> > > +
> > > +	{ 7, 1, 0x0, USB_MIXER_INV_BOOLEAN, "Output Playback Switch", NULL },
> > > +	{ 7, 2, 0x1, USB_MIXER_S16, "Output A Playback Volume", NULL },
> > > +	{ 7, 2, 0x2, USB_MIXER_S16, "Output B Playback Volume", NULL },
> > > +
> > > +	{ 10, 1, 0x0, USB_MIXER_INV_BOOLEAN, "Input Capture Switch", NULL },
> > > +	{ 10, 2, 0x1, USB_MIXER_S16, "Input A Capture Volume", NULL },
> > > +	{ 10, 2, 0x2, USB_MIXER_S16, "Input B Capture Volume", NULL },
> > > +
> > > +	{ }
> > 
> > C99 style struct initialization is preferred.  Then NULL settings can
> > be omittted.
> 
> Do you mean like this?
> 
>   ebox44_table[] = {
>       {
>           .unitid = 4,
>           .control =  1
>           .cmask = 0x0
>           /* etc. */
>       }
> 
> Because then it becomes a lot less concise and a lot less readable?

I can't count fields more than two, so to me, C99 style is more
readable :)

> Of course, if there are more optional params in the future, then maybe.

Yep.

> IIRC, I could omit the NULL anyway, because static memory is initialised 
> to contain zeroes (hence the "{ }" works). Am I correct? It's late, I 
> might be mistaken.

Yes.  But it's not recommended much, when you think of adding a new
field.


Takashi


More information about the Alsa-devel mailing list