alsa-lib's new API issue (snd_ctl_elem_id_compare)

Jaroslav Kysela perex at perex.cz
Mon Mar 8 15:33:46 CET 2021


Dne 08. 03. 21 v 13:58 Takashi Sakamoto napsal(a):
> Hi Jaroslav,
> 
> I have some concern about your commit 2cfe6addaef6[1] for alsa-lib,
> 
> It adds new library API, 'snd_ctl_elem_id_compare()', to compare a pair of
> IDs for control element. In the implementation, the API call returns 0 if
> they are the same, else negative or positive numeric value according to
> contents of the IDs.

I just noted that I didn't fill the function doc text correctly.

> 
> My concerns are:
> 
> 1. evaluation of numid field is not covered.
> 
> This is not preferable since ALSA control core implementation covers two
> types of comparison; numid only, and the combination iface, device,
> subdevice, name, and index fields. If the API is produced for general use
> cases, it should correctly handle the numid-only case, in my opinion.

My motivation was to allow to use this function for qsort() for example. The
numid and full-field comparisons are two very different things.

> 2. tri-state return value is semantically inconsistent

It's correct for the sorting (strcmp like).

> The ID structure includes three types of values; integer, enumeration, and
> string. In my opinion, tri-state return value from them has different meaning
> each other.
True, the signess is the key, the value should be ignored.

> The reason I post this message instead of posting any fix is that the fix
> to the API affects to alsa-utils, in which the API is used by a patch you
> applied a few days ago[2]. The patch also includes change to 'AM_PATH_ALSA'
> declaration in configure.ac with bumped-up version to '1.2.5', and it
> disables to rebuild alsa-utils on the latest toolchain. (alsa-lib 1.2.5 is
> not released yet.)

The latest alsa-lib in the git repo is already set to 1.2.5pre1, so if you
upgrade alsa-lib, everything should be fine. I was a bit lazy to write a
configure test and add a wrapper to alsactl to support the older alsa-lib.

					Jaroslav

-- 
Jaroslav Kysela <perex at perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.


More information about the Alsa-devel mailing list