[alsa-devel] snd_ctl_add_enumerated_elem_set and TLV
Hi,
I'm using snd_ctl_add_enumerated_elem_set to create user controls, I do not understand why it set "TLV readable" option at true by default. I have a simple enumeration without TLV. I use snd_ctl_elem_write but do not call snd_ctl_elem_tlv_write. I do no understand how to prevent snd_ctl_elem_info_is_tlv_readable to return true for this control, obviously even if TLV is set as readable, it is empty and reading fail.
Example
fulup@fulup-desktop:~/Workspace/AlsaPulse> amixer -D hw:USB cget numid=237 numid=237,iface=MIXER,name='Hal-VolRamp-Mode' ; type=ENUMERATED,access=rw---RW-,values=1,items=4 ; Item #0 'None' ; Item #1 'Normal' ; Item #2 'Smooth' ; Item #3 'Emergency' : values=1 amixer: Control hw:USB element TLV read error: No such device or address
Question: is there something special to set when a control does not have a TLV ?
Fulup
PS: if I write a fake TLV everything goes fine, but this is not what I expect for ENUM.
Fulup Ar Foll wrote:
I'm using snd_ctl_add_enumerated_elem_set to create user controls, I do not understand why it set "TLV readable" option at true by default.
As far as I can see, the library API has no mechanism to set or clear this access right, so it's set by default to allow TLVs for controls where it makes sense.
(In theory, the code could be changed to clear the readable flag when there is no TLV.)
I have a simple enumeration without TLV. I use snd_ctl_elem_write but do not call snd_ctl_elem_tlv_write. I do no understand how to prevent snd_ctl_elem_info_is_tlv_readable to return true for this control,
This is not possible at the moment.
obviously even if TLV is set as readable, it is empty and reading fail.
You'll have to write a fake TLV (an empty container).
Regards, Clemens
Thank you. I will write an empty container. Hopefully most clients will be happy with it.
I understand that it not a critical BUG, but as you said the flag should not be set to readable, when they is no TLV.
On 30/07/17 16:49, Clemens Ladisch wrote:
Fulup Ar Foll wrote:
I'm using snd_ctl_add_enumerated_elem_set to create user controls, I do not understand why it set "TLV readable" option at true by default.
As far as I can see, the library API has no mechanism to set or clear this access right, so it's set by default to allow TLVs for controls where it makes sense.
(In theory, the code could be changed to clear the readable flag when there is no TLV.)
I have a simple enumeration without TLV. I use snd_ctl_elem_write but do not call snd_ctl_elem_tlv_write. I do no understand how to prevent snd_ctl_elem_info_is_tlv_readable to return true for this control,
This is not possible at the moment.
obviously even if TLV is set as readable, it is empty and reading fail.
You'll have to write a fake TLV (an empty container).
Regards, Clemens
participants (2)
-
Clemens Ladisch
-
Fulup Ar Foll