mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-03 09:01:52 -05:00
control: add snd_ctl_elem_id_compare() function
Compare two control element identifiers like strcmp(). Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
7a1402cddc
commit
2cfe6addae
2 changed files with 27 additions and 0 deletions
|
|
@ -424,6 +424,7 @@ int snd_ctl_elem_id_malloc(snd_ctl_elem_id_t **ptr);
|
||||||
void snd_ctl_elem_id_free(snd_ctl_elem_id_t *obj);
|
void snd_ctl_elem_id_free(snd_ctl_elem_id_t *obj);
|
||||||
void snd_ctl_elem_id_clear(snd_ctl_elem_id_t *obj);
|
void snd_ctl_elem_id_clear(snd_ctl_elem_id_t *obj);
|
||||||
void snd_ctl_elem_id_copy(snd_ctl_elem_id_t *dst, const snd_ctl_elem_id_t *src);
|
void snd_ctl_elem_id_copy(snd_ctl_elem_id_t *dst, const snd_ctl_elem_id_t *src);
|
||||||
|
int snd_ctl_elem_id_compare(snd_ctl_elem_id_t *id1, const snd_ctl_elem_id_t *id2);
|
||||||
unsigned int snd_ctl_elem_id_get_numid(const snd_ctl_elem_id_t *obj);
|
unsigned int snd_ctl_elem_id_get_numid(const snd_ctl_elem_id_t *obj);
|
||||||
snd_ctl_elem_iface_t snd_ctl_elem_id_get_interface(const snd_ctl_elem_id_t *obj);
|
snd_ctl_elem_iface_t snd_ctl_elem_id_get_interface(const snd_ctl_elem_id_t *obj);
|
||||||
unsigned int snd_ctl_elem_id_get_device(const snd_ctl_elem_id_t *obj);
|
unsigned int snd_ctl_elem_id_get_device(const snd_ctl_elem_id_t *obj);
|
||||||
|
|
|
||||||
|
|
@ -1818,6 +1818,32 @@ void snd_ctl_elem_id_copy(snd_ctl_elem_id_t *dst, const snd_ctl_elem_id_t *src)
|
||||||
*dst = *src;
|
*dst = *src;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief compare one #snd_ctl_elem_id_t to another
|
||||||
|
* \param id1 pointer to first id
|
||||||
|
* \param id2 pointer to second id
|
||||||
|
* \retval zero when values are identical, -1 first id
|
||||||
|
*/
|
||||||
|
int snd_ctl_elem_id_compare(snd_ctl_elem_id_t *id1, const snd_ctl_elem_id_t *id2)
|
||||||
|
{
|
||||||
|
int d;
|
||||||
|
|
||||||
|
assert(id1 && id2);
|
||||||
|
d = id1->iface - id2->iface;
|
||||||
|
if (d != 0)
|
||||||
|
return d;
|
||||||
|
d = id1->device - id2->device;
|
||||||
|
if (d != 0)
|
||||||
|
return d;
|
||||||
|
d = id2->subdevice - id2->subdevice;
|
||||||
|
if (d != 0)
|
||||||
|
return d;
|
||||||
|
d = strcmp((const char *)id1->name, (const char *)id2->name);
|
||||||
|
if (d != 0)
|
||||||
|
return d;
|
||||||
|
return id1->index - id2->index;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Get numeric identifier from a CTL element identifier
|
* \brief Get numeric identifier from a CTL element identifier
|
||||||
* \param obj CTL element identifier
|
* \param obj CTL element identifier
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue