mirror of
https://github.com/openharmony/third_party_tinyalsa.git
synced 2026-07-19 15:24:22 -04:00
Merge pull request #52 from rfvirgil/get_id
mixer: Add mixer_ctl_get_id
This commit is contained in:
@@ -225,6 +225,7 @@ struct mixer_ctl *mixer_get_ctl(struct mixer *mixer, unsigned int id);
|
||||
struct mixer_ctl *mixer_get_ctl_by_name(struct mixer *mixer, const char *name);
|
||||
|
||||
/* Get info about mixer controls */
|
||||
unsigned int mixer_ctl_get_id(struct mixer_ctl *ctl);
|
||||
const char *mixer_ctl_get_name(struct mixer_ctl *ctl);
|
||||
enum mixer_ctl_type mixer_ctl_get_type(struct mixer_ctl *ctl);
|
||||
const char *mixer_ctl_get_type_string(struct mixer_ctl *ctl);
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
@@ -209,6 +210,17 @@ void mixer_ctl_update(struct mixer_ctl *ctl)
|
||||
ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_INFO, ctl->info);
|
||||
}
|
||||
|
||||
unsigned int mixer_ctl_get_id(struct mixer_ctl *ctl)
|
||||
{
|
||||
if (!ctl)
|
||||
return UINT_MAX;
|
||||
|
||||
/* numid values start at 1, return a 0-base value that
|
||||
* can be passed to mixer_get_ctl()
|
||||
*/
|
||||
return ctl->info->id.numid - 1;
|
||||
}
|
||||
|
||||
const char *mixer_ctl_get_name(struct mixer_ctl *ctl)
|
||||
{
|
||||
if (!ctl)
|
||||
|
||||
Reference in New Issue
Block a user