alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Jaroslav Kysela <perex@perex.cz>
To: alsa-devel@alsa-project.org
Subject: Re: alsa-lib's new API issue (snd_ctl_elem_id_compare)
Date: Tue, 9 Mar 2021 13:37:26 +0100	[thread overview]
Message-ID: <cfadffa0-b89f-13d2-5b52-67842cc4b372@perex.cz> (raw)
In-Reply-To: <20210309003803.GA215306@workstation>

Dne 09. 03. 21 v 1:38 Takashi Sakamoto napsal(a):
> On Mon, Mar 08, 2021 at 03:33:46PM +0100, Jaroslav Kysela wrote:
>> Dne 08. 03. 21 v 13:58 Takashi Sakamoto napsal(a):
>>> 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.
>  
> Yep. I easily associated sort implementation in hcontrol API or simple
> mixer API from your implementation
> 
> However, the new API is a part of control API and it just achieves things without
> any supplemental information given from userspace implementation.

It's not required, if documented. Nobody forces to use this function in the
app code.

> For the above comparison API, as I described, it's not appropriate. ID
> structure for control element is not comparable, thus it should be dropped
> or replaced with equality function such as 'snd_ctl_elem_id_equal()'.

I don't require the numid match at this point. The numid is not known or may
change for the id entered by the user. So I need to forcefully ignore it.

If we need a function which follow numid + full id comparison, then we can
introduce it. I agree that it should return only a boolean return value in
this case.

> When you need any sorting algorithms, it should be implemented in
> application side or alsa-lib API in the other layer such as hcontrol and
> simple mixer since control API should follow to specification of ALSA
> control written in kernel land.

I don't follow your arguments here. The numid and full field comparisons are
two different things. The caller must know things behind the scene.
The snd_ctl_elem_id_compare() function may be used as a quick backend for the
full field comparisons with the optimized execution (reduce app -> library calls).

The enums conversion to integers: I think that we're safe here. The interface
enum numbers cannot change and we know the range (and the order), so it's safe.

Lastly, the qsort() with snd_ctl_id_compare() as an argument will produce a
consistent, understandable result, right?

					Jaroslav

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

  reply	other threads:[~2021-03-09 12:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-08 12:58 alsa-lib's new API issue (snd_ctl_elem_id_compare) Takashi Sakamoto
2021-03-08 14:33 ` Jaroslav Kysela
2021-03-09  0:38   ` Takashi Sakamoto
2021-03-09 12:37     ` Jaroslav Kysela [this message]
2021-03-11 12:46       ` Takashi Sakamoto
2021-03-11 13:22         ` Jaroslav Kysela
2021-03-12  1:35           ` Takashi Sakamoto
2021-03-12 10:09             ` Jaroslav Kysela
2021-03-14  1:41               ` Takashi Sakamoto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cfadffa0-b89f-13d2-5b52-67842cc4b372@perex.cz \
    --to=perex@perex.cz \
    --cc=alsa-devel@alsa-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).