[alsa-devel] [PATCH] test: fix comment about first two fields of TLV data payload

Takashi Iwai tiwai at suse.de
Tue Aug 30 09:04:50 CEST 2016


On Tue, 30 Aug 2016 08:33:24 +0200,
Takashi Sakamoto wrote:
> 
> On Aug 30 2016 14:32, Takashi Iwai wrote:
> > On Tue, 30 Aug 2016 02:21:45 +0200,
> > Takashi Sakamoto wrote:
> >>
> >> I misunderstand TLV packet structure (struct snd_ctl_tlv) nests in its
> >> payload. But actually, the payload stores different type of data.
> >>
> >> This commit corrects a comment in a test program of user control element
> >> set including my misunderstanding.
> >>
> >> Signed-off-by: Takashi Sakamoto <o-takashi at sakamocchi.jp>
> >> ---
> >>  test/user-ctl-element-set.c | 8 ++++----
> >>  1 file changed, 4 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/test/user-ctl-element-set.c b/test/user-ctl-element-set.c
> >> index 9b9dc59..f6f050a 100644
> >> --- a/test/user-ctl-element-set.c
> >> +++ b/test/user-ctl-element-set.c
> >> @@ -418,11 +418,11 @@ static int check_tlv(struct elem_set_trial *trial)
> >>  	int err;
> >>
> >>  	/*
> >> -	 * See a layout of 'struct snd_ctl_tlv'. I don't know the reason to
> >> -	 * construct this buffer with the same layout. It should be abstracted
> >> -	 * inner userspace library...
> >> +	 * When transferring threshold level information via TLV feature of
> >> +	 * ALSA control interface, the first two fields of packet payload
> >> +	 * consist of data type and data length.
> >>  	 */
> >> -	orig[0] = snd_ctl_elem_id_get_numid(trial->id);
> >> +	orig[0] = SNDRV_CTL_TLVT_CONTAINER;
> >>  	orig[1] = 6 * sizeof(orig[0]);
> >>  	orig[2] = 'a';
> >>  	orig[3] = 'b';
> >
> > The container TLV type expects other TLVs as its content.  So the
> > above looks buggy to me...
> 
> This is a test program just to serve to myself. So I hope this degree
> of roughness is allowed...

But it's a clearly wrong choice.  Even a random number would be
better, as the chance to choose a wrong one is lower than 100% :)

> Or could you please construct valid TLV array here? I don't exactly
> know the way to do it, because I've never touched better documentation
> about whole design of TLV payload data.

Just pick anything else than CONTAINER type.

As said, CONTAINER type follows other TLVs in its value data, e.g. in
the example below, the container contains two TLV data A and B.

TLV_CONTAINER
length (A+B)
TLV_XXX_A
length_a
value_a...
TLV_XXX_B
length_b
value_b...


Takashi


More information about the Alsa-devel mailing list