Re: dB gain

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

 



At Mon, 29 May 2006 18:34:06 +0100,
James Courtier-Dutton wrote:
> 
> Takashi Iwai wrote:
> > 
> > I agree to use numid.
> > My argument is that numid can belong to the common header block.
> > 
> > The code you find in control.c is anyway a kind of object oriented.
> > It's a message to a control element.
> > But in this protocol, you get numid at very last, even depending on
> > the type.  Thus the code looks like
> > 
> > 	type = get_type();
> > 	len = get_length();
> > 	switch (type) {
> > 	case DB_SCALE:
> > 		numid = get_value();
> > 		kctl = get_kcontrol(numid);
> > 		kctl->info2(kctl, ptr);
> > 		...
> > 	}
> > 
> > When you add more different types,
> > 
> > 	type = get_type();
> > 	len = get_length();
> > 	switch (type) {
> > 	case DB_SCALE:
> > 		numid = get_value();
> > 		kctl = get_kcontrol(numid);
> > 		kctl->info2(kctl, ptr);
> > 		...
> > 	case ANOTHER_DB_SCALE:
> > 		numid = get_value();
> > 		kctl = get_kcontrol(numid);
> > 		kctl->info2(kctl, ptr);
> > 		...
> > 	case YET_ANOTHER_DATA:
> > 		numid = get_value();
> > 		kctl = get_kcontrol(numid);
> > 		kctl->info2(kctl, ptr);
> > 		...
> > 
> > 	}
> > 
> > If the numid is in the common block, we can simply extract numid
> > first, then evaluate the type and value later, eventually call the
> > callback at the single place.
> > 
> > 
> > Takashi
> 
> My point is that there will only be one DB_SCALE case in the request
> handler in control.c in the kernel. It simply calls info2(). The driver
> then returns a TLV. The returned TLV will have all the variations on
> db_scales. control.c won't care what the actual TLV value means. It will
> simply return it to user space, and let alsa-lib work out what it is.
> Another call the snd_ctl_misc might not even need a numid. It might
> instead be requesting some other information, like card name or some
> other future bit of info needed. My point is this is extensible, without
> breaking kernel/alsa-lib binary compatibility.

Sure, it's extensible.  But my point is that the complexity of this
encapsulation.

For example, in order to get a numid, you have to extract three
levels down.  The version + length, the type + length, again type +
length, then finally you reach to numid value.  Each extraction
requires a function call to convert from a byte-stream to an integer
and a check of the length.  I feel it's a bit too much abstraction.

We've learned that too much abstraction is rather more evil -- see the
implementation of alsa-lib and alsa-kernel API...


Takashi


_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/alsa-devel

[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux