mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-05 13:30:00 -05:00
Better names for control API
This commit is contained in:
parent
66f13f6115
commit
45c416ed82
22 changed files with 666 additions and 668 deletions
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Control Interface - highlevel API - hcontrol bag operations
|
||||
* Control Interface - highlevel API - helem bag operations
|
||||
* Copyright (c) 2000 by Jaroslav Kysela <perex@suse.cz>
|
||||
*
|
||||
*
|
||||
|
|
@ -36,43 +36,43 @@ int snd_ctl_hbag_create(void **bag)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void snd_ctl_hbag_free_private(snd_hcontrol_t *hcontrol ATTRIBUTE_UNUSED)
|
||||
static void snd_ctl_hbag_free_private(snd_hctl_element_t *helem ATTRIBUTE_UNUSED)
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
int snd_ctl_hbag_destroy(void **bag, void (*hcontrol_free)(snd_hcontrol_t *hcontrol))
|
||||
int snd_ctl_hbag_destroy(void **bag, void (*hctl_element_free)(snd_hctl_element_t *helem))
|
||||
{
|
||||
assert(bag != NULL);
|
||||
if (hcontrol_free == NULL)
|
||||
hcontrol_free = snd_ctl_hbag_free_private;
|
||||
tdestroy(*bag, (__free_fn_t)hcontrol_free);
|
||||
if (hctl_element_free == NULL)
|
||||
hctl_element_free = snd_ctl_hbag_free_private;
|
||||
tdestroy(*bag, (__free_fn_t)hctl_element_free);
|
||||
*bag = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int snd_ctl_hbag_add(void **bag, snd_hcontrol_t *hcontrol)
|
||||
int snd_ctl_hbag_add(void **bag, snd_hctl_element_t *helem)
|
||||
{
|
||||
void *res;
|
||||
|
||||
assert(bag != NULL && hcontrol != NULL);
|
||||
res = tsearch(hcontrol, bag, (__compar_fn_t)snd_ctl_hsort);
|
||||
assert(bag != NULL && helem != NULL);
|
||||
res = tsearch(helem, bag, (__compar_fn_t)snd_ctl_hsort);
|
||||
if (res == NULL)
|
||||
return -ENOMEM;
|
||||
if ((snd_hcontrol_t *)res == hcontrol)
|
||||
if ((snd_hctl_element_t *)res == helem)
|
||||
return -EALREADY;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int snd_ctl_hbag_del(void **bag, snd_hcontrol_t *hcontrol)
|
||||
int snd_ctl_hbag_del(void **bag, snd_hctl_element_t *helem)
|
||||
{
|
||||
assert(bag != NULL && hcontrol != NULL);
|
||||
if (tdelete(hcontrol, bag, (__compar_fn_t)snd_ctl_hsort) == NULL)
|
||||
assert(bag != NULL && helem != NULL);
|
||||
if (tdelete(helem, bag, (__compar_fn_t)snd_ctl_hsort) == NULL)
|
||||
return -ENOENT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
snd_hcontrol_t *snd_ctl_hbag_find(void **bag, snd_control_id_t *id)
|
||||
snd_hctl_element_t *snd_ctl_hbag_find(void **bag, snd_ctl_element_id_t *id)
|
||||
{
|
||||
void *res;
|
||||
|
||||
|
|
@ -80,5 +80,5 @@ snd_hcontrol_t *snd_ctl_hbag_find(void **bag, snd_control_id_t *id)
|
|||
if (*bag == NULL)
|
||||
return NULL;
|
||||
res = tfind(id, bag, (__compar_fn_t)snd_ctl_hsort);
|
||||
return res == NULL ? NULL : *(snd_hcontrol_t **)res;
|
||||
return res == NULL ? NULL : *(snd_hctl_element_t **)res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ int snd_card_get_index(const char *string)
|
|||
{
|
||||
int card;
|
||||
snd_ctl_t *handle;
|
||||
snd_ctl_info_t info;
|
||||
snd_ctl_card_info_t info;
|
||||
|
||||
if (!string || *string == '\0')
|
||||
return -EINVAL;
|
||||
|
|
@ -90,7 +90,7 @@ int snd_card_get_index(const char *string)
|
|||
continue;
|
||||
if (snd_ctl_hw_open(&handle, NULL, card) < 0)
|
||||
continue;
|
||||
if (snd_ctl_info(handle, &info) < 0) {
|
||||
if (snd_ctl_card_info(handle, &info) < 0) {
|
||||
snd_ctl_close(handle);
|
||||
continue;
|
||||
}
|
||||
|
|
@ -104,14 +104,14 @@ int snd_card_get_index(const char *string)
|
|||
int snd_card_get_name(int card, char **name)
|
||||
{
|
||||
snd_ctl_t *handle;
|
||||
snd_ctl_info_t info;
|
||||
snd_ctl_card_info_t info;
|
||||
int err;
|
||||
|
||||
if (name == NULL)
|
||||
return -EINVAL;
|
||||
if ((err = snd_ctl_hw_open(&handle, NULL, card)) < 0)
|
||||
return err;
|
||||
if ((err = snd_ctl_info(handle, &info)) < 0) {
|
||||
if ((err = snd_ctl_card_info(handle, &info)) < 0) {
|
||||
snd_ctl_close(handle);
|
||||
return err;
|
||||
}
|
||||
|
|
@ -125,14 +125,14 @@ int snd_card_get_name(int card, char **name)
|
|||
int snd_card_get_longname(int card, char **name)
|
||||
{
|
||||
snd_ctl_t *handle;
|
||||
snd_ctl_info_t info;
|
||||
snd_ctl_card_info_t info;
|
||||
int err;
|
||||
|
||||
if (name == NULL)
|
||||
return -EINVAL;
|
||||
if ((err = snd_ctl_hw_open(&handle, NULL, card)) < 0)
|
||||
return err;
|
||||
if ((err = snd_ctl_info(handle, &info)) < 0) {
|
||||
if ((err = snd_ctl_card_info(handle, &info)) < 0) {
|
||||
snd_ctl_close(handle);
|
||||
return err;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,31 +48,31 @@ int snd_ctl_poll_descriptor(snd_ctl_t *ctl)
|
|||
return ctl->ops->poll_descriptor(ctl);
|
||||
}
|
||||
|
||||
int snd_ctl_info(snd_ctl_t *ctl, snd_ctl_info_t *info)
|
||||
int snd_ctl_card_info(snd_ctl_t *ctl, snd_ctl_card_info_t *info)
|
||||
{
|
||||
assert(ctl && info);
|
||||
return ctl->ops->hw_info(ctl, info);
|
||||
}
|
||||
|
||||
int snd_ctl_clist(snd_ctl_t *ctl, snd_control_list_t *list)
|
||||
int snd_ctl_clist(snd_ctl_t *ctl, snd_ctl_element_list_t *list)
|
||||
{
|
||||
assert(ctl && list);
|
||||
return ctl->ops->clist(ctl, list);
|
||||
}
|
||||
|
||||
int snd_ctl_cinfo(snd_ctl_t *ctl, snd_control_info_t *info)
|
||||
int snd_ctl_element_info(snd_ctl_t *ctl, snd_ctl_element_info_t *info)
|
||||
{
|
||||
assert(ctl && info && (info->id.name[0] || info->id.numid));
|
||||
return ctl->ops->cinfo(ctl, info);
|
||||
}
|
||||
|
||||
int snd_ctl_cread(snd_ctl_t *ctl, snd_control_t *control)
|
||||
int snd_ctl_element_read(snd_ctl_t *ctl, snd_ctl_element_t *control)
|
||||
{
|
||||
assert(ctl && control && (control->id.name[0] || control->id.numid));
|
||||
return ctl->ops->cread(ctl, control);
|
||||
}
|
||||
|
||||
int snd_ctl_cwrite(snd_ctl_t *ctl, snd_control_t *control)
|
||||
int snd_ctl_element_write(snd_ctl_t *ctl, snd_ctl_element_t *control)
|
||||
{
|
||||
assert(ctl && control && (control->id.name[0] || control->id.numid));
|
||||
return ctl->ops->cwrite(ctl, control);
|
||||
|
|
@ -239,18 +239,18 @@ int snd_ctl_open(snd_ctl_t **ctlp, char *name)
|
|||
return open_func(ctlp, name, ctl_conf);
|
||||
}
|
||||
|
||||
void snd_control_set_bytes(snd_control_t *obj, void *data, size_t size)
|
||||
void snd_ctl_element_set_bytes(snd_ctl_element_t *obj, void *data, size_t size)
|
||||
{
|
||||
assert(obj);
|
||||
assert(size <= sizeof(obj->value.bytes.data));
|
||||
memcpy(obj->value.bytes.data, data, size);
|
||||
}
|
||||
|
||||
#define TYPE(v) [SND_CONTROL_TYPE_##v] = #v
|
||||
#define IFACE(v) [SND_CONTROL_IFACE_##v] = #v
|
||||
#define TYPE(v) [SND_CTL_ELEMENT_TYPE_##v] = #v
|
||||
#define IFACE(v) [SND_CTL_ELEMENT_IFACE_##v] = #v
|
||||
#define EVENT(v) [SND_CTL_EVENT_##v] = #v
|
||||
|
||||
const char *snd_control_type_names[] = {
|
||||
const char *snd_ctl_element_type_names[] = {
|
||||
TYPE(NONE),
|
||||
TYPE(BOOLEAN),
|
||||
TYPE(INTEGER),
|
||||
|
|
@ -259,7 +259,7 @@ const char *snd_control_type_names[] = {
|
|||
TYPE(IEC958),
|
||||
};
|
||||
|
||||
const char *snd_control_iface_names[] = {
|
||||
const char *snd_ctl_element_iface_names[] = {
|
||||
IFACE(CARD),
|
||||
IFACE(HWDEP),
|
||||
IFACE(MIXER),
|
||||
|
|
@ -277,16 +277,16 @@ const char *snd_ctl_event_type_names[] = {
|
|||
EVENT(REMOVE),
|
||||
};
|
||||
|
||||
const char *snd_control_type_name(snd_control_type_t type)
|
||||
const char *snd_ctl_element_type_name(snd_ctl_element_type_t type)
|
||||
{
|
||||
assert(type <= SND_CONTROL_TYPE_LAST);
|
||||
return snd_control_type_names[snd_enum_to_int(type)];
|
||||
assert(type <= SND_CTL_ELEMENT_TYPE_LAST);
|
||||
return snd_ctl_element_type_names[snd_enum_to_int(type)];
|
||||
}
|
||||
|
||||
const char *snd_control_iface_name(snd_control_iface_t iface)
|
||||
const char *snd_ctl_element_iface_name(snd_ctl_element_iface_t iface)
|
||||
{
|
||||
assert(iface <= SND_CONTROL_IFACE_LAST);
|
||||
return snd_control_iface_names[snd_enum_to_int(iface)];
|
||||
assert(iface <= SND_CTL_ELEMENT_IFACE_LAST);
|
||||
return snd_ctl_element_iface_names[snd_enum_to_int(iface)];
|
||||
}
|
||||
|
||||
const char *snd_ctl_event_type_name(snd_ctl_event_type_t type)
|
||||
|
|
@ -295,7 +295,7 @@ const char *snd_ctl_event_type_name(snd_ctl_event_type_t type)
|
|||
return snd_ctl_event_type_names[snd_enum_to_int(type)];
|
||||
}
|
||||
|
||||
int snd_control_list_alloc_space(snd_control_list_t *obj, unsigned int entries)
|
||||
int snd_ctl_element_list_alloc_space(snd_ctl_element_list_t *obj, unsigned int entries)
|
||||
{
|
||||
obj->pids = calloc(entries, sizeof(*obj->pids));
|
||||
if (!obj->pids) {
|
||||
|
|
@ -306,7 +306,7 @@ int snd_control_list_alloc_space(snd_control_list_t *obj, unsigned int entries)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void snd_control_list_free_space(snd_control_list_t *obj)
|
||||
void snd_ctl_element_list_free_space(snd_ctl_element_list_t *obj)
|
||||
{
|
||||
free(obj->pids);
|
||||
obj->pids = NULL;
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ static int snd_ctl_hw_poll_descriptor(snd_ctl_t *handle)
|
|||
return hw->fd;
|
||||
}
|
||||
|
||||
static int snd_ctl_hw_hw_info(snd_ctl_t *handle, snd_ctl_info_t *info)
|
||||
static int snd_ctl_hw_hw_info(snd_ctl_t *handle, snd_ctl_card_info_t *info)
|
||||
{
|
||||
snd_ctl_hw_t *hw = handle->private;
|
||||
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_INFO, info) < 0)
|
||||
|
|
@ -59,34 +59,34 @@ static int snd_ctl_hw_hw_info(snd_ctl_t *handle, snd_ctl_info_t *info)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int snd_ctl_hw_clist(snd_ctl_t *handle, snd_control_list_t *list)
|
||||
static int snd_ctl_hw_clist(snd_ctl_t *handle, snd_ctl_element_list_t *list)
|
||||
{
|
||||
snd_ctl_hw_t *hw = handle->private;
|
||||
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_CONTROL_LIST, list) < 0)
|
||||
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_ELEMENT_LIST, list) < 0)
|
||||
return -errno;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int snd_ctl_hw_cinfo(snd_ctl_t *handle, snd_control_info_t *info)
|
||||
static int snd_ctl_hw_cinfo(snd_ctl_t *handle, snd_ctl_element_info_t *info)
|
||||
{
|
||||
snd_ctl_hw_t *hw = handle->private;
|
||||
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_CONTROL_INFO, info) < 0)
|
||||
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_ELEMENT_INFO, info) < 0)
|
||||
return -errno;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int snd_ctl_hw_cread(snd_ctl_t *handle, snd_control_t *control)
|
||||
static int snd_ctl_hw_cread(snd_ctl_t *handle, snd_ctl_element_t *control)
|
||||
{
|
||||
snd_ctl_hw_t *hw = handle->private;
|
||||
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_CONTROL_READ, control) < 0)
|
||||
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_ELEMENT_READ, control) < 0)
|
||||
return -errno;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int snd_ctl_hw_cwrite(snd_ctl_t *handle, snd_control_t *control)
|
||||
static int snd_ctl_hw_cwrite(snd_ctl_t *handle, snd_ctl_element_t *control)
|
||||
{
|
||||
snd_ctl_hw_t *hw = handle->private;
|
||||
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_CONTROL_WRITE, control) < 0)
|
||||
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_ELEMENT_WRITE, control) < 0)
|
||||
return -errno;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,11 +25,11 @@
|
|||
typedef struct _snd_ctl_ops {
|
||||
int (*close)(snd_ctl_t *handle);
|
||||
int (*poll_descriptor)(snd_ctl_t *handle);
|
||||
int (*hw_info)(snd_ctl_t *handle, snd_ctl_info_t *info);
|
||||
int (*clist)(snd_ctl_t *handle, snd_control_list_t *list);
|
||||
int (*cinfo)(snd_ctl_t *handle, snd_control_info_t *info);
|
||||
int (*cread)(snd_ctl_t *handle, snd_control_t *control);
|
||||
int (*cwrite)(snd_ctl_t *handle, snd_control_t *control);
|
||||
int (*hw_info)(snd_ctl_t *handle, snd_ctl_card_info_t *info);
|
||||
int (*clist)(snd_ctl_t *handle, snd_ctl_element_list_t *list);
|
||||
int (*cinfo)(snd_ctl_t *handle, snd_ctl_element_info_t *info);
|
||||
int (*cread)(snd_ctl_t *handle, snd_ctl_element_t *control);
|
||||
int (*cwrite)(snd_ctl_t *handle, snd_ctl_element_t *control);
|
||||
int (*hwdep_next_device)(snd_ctl_t *handle, int *device);
|
||||
int (*hwdep_info)(snd_ctl_t *handle, snd_hwdep_info_t * info);
|
||||
int (*pcm_next_device)(snd_ctl_t *handle, int *device);
|
||||
|
|
@ -62,33 +62,33 @@ struct _snd_ctl {
|
|||
struct _snd_ctl_callbacks {
|
||||
void *private_data; /* may be used by an application */
|
||||
void (*rebuild) (snd_ctl_t *handle, void *private_data);
|
||||
void (*value) (snd_ctl_t *handle, void *private_data, snd_control_id_t * id);
|
||||
void (*change) (snd_ctl_t *handle, void *private_data, snd_control_id_t * id);
|
||||
void (*add) (snd_ctl_t *handle, void *private_data, snd_control_id_t * id);
|
||||
void (*remove) (snd_ctl_t *handle, void *private_data, snd_control_id_t * id);
|
||||
void (*value) (snd_ctl_t *handle, void *private_data, snd_ctl_element_id_t * id);
|
||||
void (*change) (snd_ctl_t *handle, void *private_data, snd_ctl_element_id_t * id);
|
||||
void (*add) (snd_ctl_t *handle, void *private_data, snd_ctl_element_id_t * id);
|
||||
void (*remove) (snd_ctl_t *handle, void *private_data, snd_ctl_element_id_t * id);
|
||||
void *reserved[58]; /* reserved for the future use - must be NULL!!! */
|
||||
};
|
||||
|
||||
struct _snd_hcontrol_list {
|
||||
struct _snd_hctl_element_list {
|
||||
unsigned int offset; /* W: first control ID to get */
|
||||
unsigned int space; /* W: count of control IDs to get */
|
||||
unsigned int used; /* R: count of available (set) controls */
|
||||
unsigned int count; /* R: count of all available controls */
|
||||
snd_control_id_t *pids; /* W: IDs */
|
||||
snd_ctl_element_id_t *pids; /* W: IDs */
|
||||
};
|
||||
|
||||
struct _snd_hcontrol {
|
||||
snd_control_id_t id; /* must be always on top */
|
||||
struct list_head list; /* links for list of all hcontrols */
|
||||
struct _snd_hctl_element {
|
||||
snd_ctl_element_id_t id; /* must be always on top */
|
||||
struct list_head list; /* links for list of all helems */
|
||||
int change: 1, /* structure change */
|
||||
value: 1; /* value change */
|
||||
/* event callbacks */
|
||||
snd_hcontrol_callback_t callback_change;
|
||||
snd_hcontrol_callback_t callback_value;
|
||||
snd_hcontrol_callback_t callback_remove;
|
||||
snd_hctl_element_callback_t callback_change;
|
||||
snd_hctl_element_callback_t callback_value;
|
||||
snd_hctl_element_callback_t callback_remove;
|
||||
/* private data */
|
||||
void *private_data;
|
||||
snd_hcontrol_private_free_t private_free;
|
||||
snd_hctl_element_private_free_t private_free;
|
||||
/* links */
|
||||
snd_ctl_t *handle; /* associated handle */
|
||||
};
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -106,7 +106,7 @@ static int snd_ctl_shm_poll_descriptor(snd_ctl_t *ctl)
|
|||
return fd;
|
||||
}
|
||||
|
||||
static int snd_ctl_shm_hw_info(snd_ctl_t *ctl, snd_ctl_info_t *info)
|
||||
static int snd_ctl_shm_hw_info(snd_ctl_t *ctl, snd_ctl_card_info_t *info)
|
||||
{
|
||||
snd_ctl_shm_t *shm = ctl->private;
|
||||
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
|
||||
|
|
@ -120,18 +120,18 @@ static int snd_ctl_shm_hw_info(snd_ctl_t *ctl, snd_ctl_info_t *info)
|
|||
return err;
|
||||
}
|
||||
|
||||
static int snd_ctl_shm_clist(snd_ctl_t *ctl, snd_control_list_t *list)
|
||||
static int snd_ctl_shm_clist(snd_ctl_t *ctl, snd_ctl_element_list_t *list)
|
||||
{
|
||||
snd_ctl_shm_t *shm = ctl->private;
|
||||
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
|
||||
size_t maxsize = CTL_SHM_DATA_MAXLEN;
|
||||
size_t bytes = list->space * sizeof(*list->pids);
|
||||
int err;
|
||||
snd_control_id_t *pids = list->pids;
|
||||
snd_ctl_element_id_t *pids = list->pids;
|
||||
if (bytes > maxsize)
|
||||
return -EINVAL;
|
||||
ctrl->u.clist = *list;
|
||||
ctrl->cmd = SNDRV_CTL_IOCTL_CONTROL_LIST;
|
||||
ctrl->cmd = SNDRV_CTL_IOCTL_ELEMENT_LIST;
|
||||
err = snd_ctl_shm_action(ctl);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
|
@ -142,13 +142,13 @@ static int snd_ctl_shm_clist(snd_ctl_t *ctl, snd_control_list_t *list)
|
|||
return err;
|
||||
}
|
||||
|
||||
static int snd_ctl_shm_cinfo(snd_ctl_t *ctl, snd_control_info_t *info)
|
||||
static int snd_ctl_shm_cinfo(snd_ctl_t *ctl, snd_ctl_element_info_t *info)
|
||||
{
|
||||
snd_ctl_shm_t *shm = ctl->private;
|
||||
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
|
||||
int err;
|
||||
ctrl->u.cinfo = *info;
|
||||
ctrl->cmd = SNDRV_CTL_IOCTL_CONTROL_INFO;
|
||||
ctrl->cmd = SNDRV_CTL_IOCTL_ELEMENT_INFO;
|
||||
err = snd_ctl_shm_action(ctl);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
|
@ -156,13 +156,13 @@ static int snd_ctl_shm_cinfo(snd_ctl_t *ctl, snd_control_info_t *info)
|
|||
return err;
|
||||
}
|
||||
|
||||
static int snd_ctl_shm_cread(snd_ctl_t *ctl, snd_control_t *control)
|
||||
static int snd_ctl_shm_cread(snd_ctl_t *ctl, snd_ctl_element_t *control)
|
||||
{
|
||||
snd_ctl_shm_t *shm = ctl->private;
|
||||
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
|
||||
int err;
|
||||
ctrl->u.cread = *control;
|
||||
ctrl->cmd = SNDRV_CTL_IOCTL_CONTROL_READ;
|
||||
ctrl->cmd = SNDRV_CTL_IOCTL_ELEMENT_READ;
|
||||
err = snd_ctl_shm_action(ctl);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
|
@ -170,13 +170,13 @@ static int snd_ctl_shm_cread(snd_ctl_t *ctl, snd_control_t *control)
|
|||
return err;
|
||||
}
|
||||
|
||||
static int snd_ctl_shm_cwrite(snd_ctl_t *ctl, snd_control_t *control)
|
||||
static int snd_ctl_shm_cwrite(snd_ctl_t *ctl, snd_ctl_element_t *control)
|
||||
{
|
||||
snd_ctl_shm_t *shm = ctl->private;
|
||||
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
|
||||
int err;
|
||||
ctrl->u.cwrite = *control;
|
||||
ctrl->cmd = SNDRV_CTL_IOCTL_CONTROL_WRITE;
|
||||
ctrl->cmd = SNDRV_CTL_IOCTL_ELEMENT_WRITE;
|
||||
err = snd_ctl_shm_action(ctl);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
|
|
|||
|
|
@ -29,12 +29,12 @@
|
|||
#include <search.h>
|
||||
#include "control_local.h"
|
||||
|
||||
static void snd_ctl_hfree1(snd_hcontrol_t *hcontrol);
|
||||
static void snd_ctl_hfree1(snd_hctl_element_t *helem);
|
||||
|
||||
int snd_ctl_hbuild(snd_ctl_t *handle, snd_ctl_hsort_t hsort)
|
||||
{
|
||||
snd_control_list_t list;
|
||||
snd_hcontrol_t *hcontrol, *prev;
|
||||
snd_ctl_element_list_t list;
|
||||
snd_hctl_element_t *helem, *prev;
|
||||
int err;
|
||||
unsigned int idx;
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ int snd_ctl_hbuild(snd_ctl_t *handle, snd_ctl_hsort_t hsort)
|
|||
return err;
|
||||
if (list.count == 0)
|
||||
break;
|
||||
list.pids = (snd_control_id_t *)calloc(list.count, sizeof(snd_control_id_t));
|
||||
list.pids = (snd_ctl_element_id_t *)calloc(list.count, sizeof(snd_ctl_element_id_t));
|
||||
if (list.pids == NULL)
|
||||
return -ENOMEM;
|
||||
list.space = list.count;
|
||||
|
|
@ -61,24 +61,24 @@ int snd_ctl_hbuild(snd_ctl_t *handle, snd_ctl_hsort_t hsort)
|
|||
return err;
|
||||
} while (list.count != list.used);
|
||||
for (idx = 0, prev = NULL; idx < list.count; idx++) {
|
||||
hcontrol = (snd_hcontrol_t *)calloc(1, sizeof(snd_hcontrol_t));
|
||||
if (hcontrol == NULL)
|
||||
helem = (snd_hctl_element_t *)calloc(1, sizeof(snd_hctl_element_t));
|
||||
if (helem == NULL)
|
||||
goto __nomem;
|
||||
hcontrol->id = list.pids[idx];
|
||||
hcontrol->handle = handle;
|
||||
if (tsearch(hcontrol, &handle->hroot, (__compar_fn_t)hsort) == NULL) {
|
||||
helem->id = list.pids[idx];
|
||||
helem->handle = handle;
|
||||
if (tsearch(helem, &handle->hroot, (__compar_fn_t)hsort) == NULL) {
|
||||
__nomem:
|
||||
if (handle->hroot != NULL) {
|
||||
tdestroy(handle->hroot, (__free_fn_t)snd_ctl_hfree1);
|
||||
handle->hroot = NULL;
|
||||
}
|
||||
handle->hroot = NULL;
|
||||
if (hcontrol != NULL)
|
||||
free(hcontrol);
|
||||
if (helem != NULL)
|
||||
free(helem);
|
||||
free(list.pids);
|
||||
return -ENOMEM;
|
||||
}
|
||||
list_add_tail(&hcontrol->list, &handle->hlist);
|
||||
list_add_tail(&helem->list, &handle->hlist);
|
||||
handle->hcount++;
|
||||
}
|
||||
if (list.pids != NULL)
|
||||
|
|
@ -90,20 +90,20 @@ int snd_ctl_hbuild(snd_ctl_t *handle, snd_ctl_hsort_t hsort)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void snd_ctl_hfree1(snd_hcontrol_t *hcontrol)
|
||||
static void snd_ctl_hfree1(snd_hctl_element_t *helem)
|
||||
{
|
||||
snd_ctl_t *handle;
|
||||
|
||||
assert(hcontrol != NULL);
|
||||
handle = hcontrol->handle;
|
||||
assert(helem != NULL);
|
||||
handle = helem->handle;
|
||||
assert(handle != NULL);
|
||||
assert(handle->hcount > 0);
|
||||
if (hcontrol->callback_remove)
|
||||
hcontrol->callback_remove(handle, hcontrol);
|
||||
if (hcontrol->private_free)
|
||||
hcontrol->private_free(hcontrol);
|
||||
list_del(&hcontrol->list);
|
||||
free(hcontrol);
|
||||
if (helem->callback_remove)
|
||||
helem->callback_remove(handle, helem);
|
||||
if (helem->private_free)
|
||||
helem->private_free(helem);
|
||||
list_del(&helem->list);
|
||||
free(helem);
|
||||
handle->hcount--;
|
||||
}
|
||||
|
||||
|
|
@ -202,7 +202,7 @@ static int snd_ctl_hsort_mixer_priority(const char *name)
|
|||
return res + res1;
|
||||
}
|
||||
|
||||
int snd_ctl_hsort(const snd_hcontrol_t *c1, const snd_hcontrol_t *c2)
|
||||
int snd_ctl_hsort(const snd_hctl_element_t *c1, const snd_hctl_element_t *c2)
|
||||
{
|
||||
int res, p1, p2;
|
||||
|
||||
|
|
@ -211,7 +211,7 @@ int snd_ctl_hsort(const snd_hcontrol_t *c1, const snd_hcontrol_t *c2)
|
|||
if (c1->id.iface > c2->id.iface)
|
||||
return 1;
|
||||
if ((res = strcmp(c1->id.name, c2->id.name)) != 0) {
|
||||
if (c1->id.iface != SNDRV_CONTROL_IFACE_MIXER)
|
||||
if (c1->id.iface != SNDRV_CTL_ELEMENT_IFACE_MIXER)
|
||||
return res;
|
||||
p1 = snd_ctl_hsort_mixer_priority(c1->id.name);
|
||||
p2 = snd_ctl_hsort_mixer_priority(c2->id.name);
|
||||
|
|
@ -228,7 +228,7 @@ int snd_ctl_hsort(const snd_hcontrol_t *c1, const snd_hcontrol_t *c2)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void snd_ctl_hresort_free(snd_hcontrol_t *hcontrol ATTRIBUTE_UNUSED)
|
||||
static void snd_ctl_hresort_free(snd_hctl_element_t *helem ATTRIBUTE_UNUSED)
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
|
|
@ -236,8 +236,8 @@ static void snd_ctl_hresort_free(snd_hcontrol_t *hcontrol ATTRIBUTE_UNUSED)
|
|||
int snd_ctl_hresort(snd_ctl_t *handle, snd_ctl_hsort_t hsort)
|
||||
{
|
||||
struct list_head *list;
|
||||
snd_hcontrol_t *hcontrol;
|
||||
snd_control_id_t *ids, *pids;
|
||||
snd_hctl_element_t *helem;
|
||||
snd_ctl_element_id_t *ids, *pids;
|
||||
int idx;
|
||||
|
||||
assert(handle != NULL && hsort != NULL);
|
||||
|
|
@ -246,14 +246,14 @@ int snd_ctl_hresort(snd_ctl_t *handle, snd_ctl_hsort_t hsort)
|
|||
if (handle->herr < 0)
|
||||
return handle->herr;
|
||||
assert(handle->hroot_new == NULL);
|
||||
ids = pids = (snd_control_id_t *)malloc(sizeof(snd_control_id_t) * handle->hcount);
|
||||
ids = pids = (snd_ctl_element_id_t *)malloc(sizeof(snd_ctl_element_id_t) * handle->hcount);
|
||||
if (ids == NULL)
|
||||
return -ENOMEM;
|
||||
/* first step - update search engine */
|
||||
list_for_each(list, &handle->hlist) {
|
||||
hcontrol = list_entry(list, snd_hcontrol_t, list);
|
||||
*pids++ = hcontrol->id;
|
||||
if (tsearch(hcontrol, &handle->hroot_new, (__compar_fn_t)hsort) == NULL) {
|
||||
helem = list_entry(list, snd_hctl_element_t, list);
|
||||
*pids++ = helem->id;
|
||||
if (tsearch(helem, &handle->hroot_new, (__compar_fn_t)hsort) == NULL) {
|
||||
if (handle->hroot_new != NULL)
|
||||
tdestroy(handle->hroot_new, (__free_fn_t)snd_ctl_hresort_free);
|
||||
handle->hroot_new = NULL;
|
||||
|
|
@ -267,46 +267,46 @@ int snd_ctl_hresort(snd_ctl_t *handle, snd_ctl_hsort_t hsort)
|
|||
handle->hroot = handle->hroot_new;
|
||||
handle->hroot_new = NULL;
|
||||
/* second step - perform qsort and save results */
|
||||
qsort(ids, handle->hcount, sizeof(snd_control_id_t), (int (*)(const void *, const void *))hsort);
|
||||
qsort(ids, handle->hcount, sizeof(snd_ctl_element_id_t), (int (*)(const void *, const void *))hsort);
|
||||
INIT_LIST_HEAD(&handle->hlist);
|
||||
for (idx = 0; idx < handle->hcount; idx++) {
|
||||
hcontrol = snd_ctl_hfind(handle, ids + idx);
|
||||
list_add_tail(&hcontrol->list, &handle->hlist);
|
||||
helem = snd_ctl_hfind(handle, ids + idx);
|
||||
list_add_tail(&helem->list, &handle->hlist);
|
||||
}
|
||||
free(ids);
|
||||
return 0;
|
||||
}
|
||||
|
||||
snd_hcontrol_t *snd_ctl_hfirst(snd_ctl_t *handle)
|
||||
snd_hctl_element_t *snd_ctl_hfirst(snd_ctl_t *handle)
|
||||
{
|
||||
assert(handle != NULL);
|
||||
if (list_empty(&handle->hlist))
|
||||
return NULL;
|
||||
return (snd_hcontrol_t *)list_entry(handle->hlist.next, snd_hcontrol_t, list);
|
||||
return (snd_hctl_element_t *)list_entry(handle->hlist.next, snd_hctl_element_t, list);
|
||||
}
|
||||
|
||||
snd_hcontrol_t *snd_ctl_hlast(snd_ctl_t *handle)
|
||||
snd_hctl_element_t *snd_ctl_hlast(snd_ctl_t *handle)
|
||||
{
|
||||
assert(handle != NULL);
|
||||
if (list_empty(&handle->hlist))
|
||||
return NULL;
|
||||
return (snd_hcontrol_t *)list_entry(handle->hlist.prev, snd_hcontrol_t, list);
|
||||
return (snd_hctl_element_t *)list_entry(handle->hlist.prev, snd_hctl_element_t, list);
|
||||
}
|
||||
|
||||
snd_hcontrol_t *snd_ctl_hnext(snd_ctl_t *handle, snd_hcontrol_t *hcontrol)
|
||||
snd_hctl_element_t *snd_ctl_hnext(snd_ctl_t *handle, snd_hctl_element_t *helem)
|
||||
{
|
||||
assert(handle != NULL && hcontrol != NULL);
|
||||
if (hcontrol->list.next == &handle->hlist)
|
||||
assert(handle != NULL && helem != NULL);
|
||||
if (helem->list.next == &handle->hlist)
|
||||
return NULL;
|
||||
return (snd_hcontrol_t *)list_entry(hcontrol->list.next, snd_hcontrol_t, list);
|
||||
return (snd_hctl_element_t *)list_entry(helem->list.next, snd_hctl_element_t, list);
|
||||
}
|
||||
|
||||
snd_hcontrol_t *snd_ctl_hprev(snd_ctl_t *handle, snd_hcontrol_t *hcontrol)
|
||||
snd_hctl_element_t *snd_ctl_hprev(snd_ctl_t *handle, snd_hctl_element_t *helem)
|
||||
{
|
||||
assert(handle != NULL && hcontrol != NULL);
|
||||
if (hcontrol->list.prev == &handle->hlist)
|
||||
assert(handle != NULL && helem != NULL);
|
||||
if (helem->list.prev == &handle->hlist)
|
||||
return NULL;
|
||||
return (snd_hcontrol_t *)list_entry(hcontrol->list.prev, snd_hcontrol_t, list);
|
||||
return (snd_hctl_element_t *)list_entry(helem->list.prev, snd_hctl_element_t, list);
|
||||
}
|
||||
|
||||
int snd_ctl_hcount(snd_ctl_t *handle)
|
||||
|
|
@ -315,7 +315,7 @@ int snd_ctl_hcount(snd_ctl_t *handle)
|
|||
return handle->hcount;
|
||||
}
|
||||
|
||||
snd_hcontrol_t *snd_ctl_hfind(snd_ctl_t *handle, snd_control_id_t *id)
|
||||
snd_hctl_element_t *snd_ctl_hfind(snd_ctl_t *handle, snd_ctl_element_id_t *id)
|
||||
{
|
||||
void *res;
|
||||
|
||||
|
|
@ -323,13 +323,13 @@ snd_hcontrol_t *snd_ctl_hfind(snd_ctl_t *handle, snd_control_id_t *id)
|
|||
if (handle->hroot == NULL)
|
||||
return NULL;
|
||||
res = tfind(id, &handle->hroot, (__compar_fn_t)handle->hsort);
|
||||
return res == NULL ? NULL : *(snd_hcontrol_t **)res;
|
||||
return res == NULL ? NULL : *(snd_hctl_element_t **)res;
|
||||
}
|
||||
|
||||
int snd_ctl_hlist(snd_ctl_t *handle, snd_hcontrol_list_t *hlist)
|
||||
int snd_ctl_hlist(snd_ctl_t *handle, snd_hctl_element_list_t *hlist)
|
||||
{
|
||||
struct list_head *list;
|
||||
snd_hcontrol_t *hcontrol;
|
||||
snd_hctl_element_t *helem;
|
||||
unsigned int idx;
|
||||
|
||||
assert(hlist != NULL);
|
||||
|
|
@ -342,11 +342,11 @@ int snd_ctl_hlist(snd_ctl_t *handle, snd_hcontrol_list_t *hlist)
|
|||
return -EINVAL;
|
||||
idx = 0;
|
||||
list_for_each(list, &handle->hlist) {
|
||||
hcontrol = list_entry(list, snd_hcontrol_t, list);
|
||||
helem = list_entry(list, snd_hctl_element_t, list);
|
||||
if (idx >= hlist->offset + hlist->space)
|
||||
break;
|
||||
if (idx >= hlist->offset) {
|
||||
hlist->pids[idx] = hcontrol->id;
|
||||
hlist->pids[idx] = helem->id;
|
||||
hlist->used++;
|
||||
}
|
||||
idx++;
|
||||
|
|
@ -378,75 +378,75 @@ static void callback_rebuild(snd_ctl_t *handle, void *private_data ATTRIBUTE_UNU
|
|||
handle->callback_rebuild(handle, handle->callback_rebuild_private_data);
|
||||
}
|
||||
|
||||
static void callback_change(snd_ctl_t *handle, void *private_data ATTRIBUTE_UNUSED, snd_control_id_t *id)
|
||||
static void callback_change(snd_ctl_t *handle, void *private_data ATTRIBUTE_UNUSED, snd_ctl_element_id_t *id)
|
||||
{
|
||||
snd_hcontrol_t *hcontrol;
|
||||
snd_hctl_element_t *helem;
|
||||
|
||||
if (handle->herr < 0)
|
||||
return;
|
||||
hcontrol = snd_ctl_hfind(handle, id);
|
||||
if (hcontrol == NULL) {
|
||||
helem = snd_ctl_hfind(handle, id);
|
||||
if (helem == NULL) {
|
||||
handle->herr = -ENOENT;
|
||||
return;
|
||||
}
|
||||
hcontrol->change = 1;
|
||||
helem->change = 1;
|
||||
}
|
||||
|
||||
static void callback_value(snd_ctl_t *handle, void *private_data ATTRIBUTE_UNUSED, snd_control_id_t *id)
|
||||
static void callback_value(snd_ctl_t *handle, void *private_data ATTRIBUTE_UNUSED, snd_ctl_element_id_t *id)
|
||||
{
|
||||
snd_hcontrol_t *hcontrol;
|
||||
snd_hctl_element_t *helem;
|
||||
|
||||
if (handle->herr < 0)
|
||||
return;
|
||||
hcontrol = snd_ctl_hfind(handle, id);
|
||||
if (hcontrol == NULL) {
|
||||
helem = snd_ctl_hfind(handle, id);
|
||||
if (helem == NULL) {
|
||||
handle->herr = -ENOENT;
|
||||
return;
|
||||
}
|
||||
hcontrol->value = 1;
|
||||
helem->value = 1;
|
||||
}
|
||||
|
||||
static void callback_add(snd_ctl_t *handle, void *private_data ATTRIBUTE_UNUSED, snd_control_id_t *id)
|
||||
static void callback_add(snd_ctl_t *handle, void *private_data ATTRIBUTE_UNUSED, snd_ctl_element_id_t *id)
|
||||
{
|
||||
snd_hcontrol_t *hcontrol, *icontrol;
|
||||
snd_hctl_element_t *helem, *icontrol;
|
||||
|
||||
if (handle->herr < 0)
|
||||
return;
|
||||
hcontrol = (snd_hcontrol_t *)calloc(1, sizeof(snd_hcontrol_t));
|
||||
if (hcontrol == NULL) {
|
||||
helem = (snd_hctl_element_t *)calloc(1, sizeof(snd_hctl_element_t));
|
||||
if (helem == NULL) {
|
||||
handle->herr = -ENOMEM;
|
||||
return;
|
||||
}
|
||||
hcontrol->id = *id;
|
||||
hcontrol->handle = handle;
|
||||
icontrol = tsearch(hcontrol, &handle->hroot, (__compar_fn_t)handle->hsort);
|
||||
helem->id = *id;
|
||||
helem->handle = handle;
|
||||
icontrol = tsearch(helem, &handle->hroot, (__compar_fn_t)handle->hsort);
|
||||
if (icontrol == NULL) {
|
||||
free(hcontrol);
|
||||
free(helem);
|
||||
handle->herr = -ENOMEM;
|
||||
return;
|
||||
}
|
||||
if (icontrol != hcontrol) { /* double hit */
|
||||
free(hcontrol);
|
||||
if (icontrol != helem) { /* double hit */
|
||||
free(helem);
|
||||
return;
|
||||
}
|
||||
list_add_tail(&hcontrol->list, &handle->hlist);
|
||||
list_add_tail(&helem->list, &handle->hlist);
|
||||
if (handle->callback_add)
|
||||
handle->callback_add(handle, handle->callback_add_private_data, hcontrol);
|
||||
handle->callback_add(handle, handle->callback_add_private_data, helem);
|
||||
}
|
||||
|
||||
static void callback_remove(snd_ctl_t *handle, void *private_data ATTRIBUTE_UNUSED, snd_control_id_t *id)
|
||||
static void callback_remove(snd_ctl_t *handle, void *private_data ATTRIBUTE_UNUSED, snd_ctl_element_id_t *id)
|
||||
{
|
||||
snd_hcontrol_t *hcontrol;
|
||||
snd_hctl_element_t *helem;
|
||||
|
||||
if (handle->herr < 0)
|
||||
return;
|
||||
hcontrol = snd_ctl_hfind(handle, id);
|
||||
if (hcontrol == NULL) {
|
||||
helem = snd_ctl_hfind(handle, id);
|
||||
if (helem == NULL) {
|
||||
handle->herr = -ENOENT;
|
||||
return;
|
||||
}
|
||||
if (tdelete(hcontrol, &handle->hroot, (__compar_fn_t)handle->hsort) != NULL)
|
||||
snd_ctl_hfree1(hcontrol);
|
||||
if (tdelete(helem, &handle->hroot, (__compar_fn_t)handle->hsort) != NULL)
|
||||
snd_ctl_hfree1(helem);
|
||||
}
|
||||
|
||||
int snd_ctl_hevent(snd_ctl_t *handle)
|
||||
|
|
@ -461,7 +461,7 @@ int snd_ctl_hevent(snd_ctl_t *handle)
|
|||
reserved: { NULL, }
|
||||
};
|
||||
struct list_head *list;
|
||||
snd_hcontrol_t *hcontrol;
|
||||
snd_hctl_element_t *helem;
|
||||
int res;
|
||||
|
||||
assert(handle != NULL);
|
||||
|
|
@ -472,20 +472,20 @@ int snd_ctl_hevent(snd_ctl_t *handle)
|
|||
if (handle->herr < 0)
|
||||
return handle->herr;
|
||||
list_for_each(list, &handle->hlist) {
|
||||
hcontrol = list_entry(list, snd_hcontrol_t, list);
|
||||
if (hcontrol->change && hcontrol->callback_change) {
|
||||
hcontrol->callback_change(hcontrol->handle, hcontrol);
|
||||
hcontrol->change = 0;
|
||||
helem = list_entry(list, snd_hctl_element_t, list);
|
||||
if (helem->change && helem->callback_change) {
|
||||
helem->callback_change(helem->handle, helem);
|
||||
helem->change = 0;
|
||||
}
|
||||
if (hcontrol->value && hcontrol->callback_value) {
|
||||
hcontrol->callback_value(hcontrol->handle, hcontrol);
|
||||
hcontrol->value = 0;
|
||||
if (helem->value && helem->callback_value) {
|
||||
helem->callback_value(helem->handle, helem);
|
||||
helem->value = 0;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
int snd_hcontrol_list_alloc_space(snd_hcontrol_list_t *obj, unsigned int entries)
|
||||
int snd_hctl_element_list_alloc_space(snd_hctl_element_list_t *obj, unsigned int entries)
|
||||
{
|
||||
obj->pids = calloc(entries, sizeof(*obj->pids));
|
||||
if (!obj->pids) {
|
||||
|
|
@ -496,7 +496,7 @@ int snd_hcontrol_list_alloc_space(snd_hcontrol_list_t *obj, unsigned int entries
|
|||
return 0;
|
||||
}
|
||||
|
||||
void snd_hcontrol_list_free_space(snd_hcontrol_list_t *obj)
|
||||
void snd_hctl_element_list_free_space(snd_hctl_element_list_t *obj)
|
||||
{
|
||||
free(obj->pids);
|
||||
obj->pids = NULL;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
#include "mixer_local.h"
|
||||
|
||||
static void snd_mixer_simple_read_rebuild(snd_ctl_t *ctl_handle, void *private_data);
|
||||
static void snd_mixer_simple_read_add(snd_ctl_t *ctl_handle, void *private_data, snd_hcontrol_t *hcontrol);
|
||||
static void snd_mixer_simple_read_add(snd_ctl_t *ctl_handle, void *private_data, snd_hctl_element_t *helem);
|
||||
|
||||
int snd_mixer_open(snd_mixer_t **r_handle, char *name)
|
||||
{
|
||||
|
|
@ -100,7 +100,7 @@ const char *snd_mixer_simple_channel_name(snd_mixer_channel_id_t channel)
|
|||
return p;
|
||||
}
|
||||
|
||||
int snd_mixer_simple_control_list(snd_mixer_t *handle, snd_mixer_simple_control_list_t *list)
|
||||
int snd_mixer_simple_element_list(snd_mixer_t *handle, snd_mixer_simple_element_list_t *list)
|
||||
{
|
||||
struct list_head *lh;
|
||||
mixer_simple_t *s;
|
||||
|
|
@ -145,7 +145,7 @@ static mixer_simple_t *look_for_simple(snd_mixer_t *handle, snd_mixer_sid_t *sid
|
|||
return NULL;
|
||||
}
|
||||
|
||||
int snd_mixer_simple_control_read(snd_mixer_t *handle, snd_mixer_simple_control_t *control)
|
||||
int snd_mixer_simple_element_read(snd_mixer_t *handle, snd_mixer_simple_element_t *control)
|
||||
{
|
||||
mixer_simple_t *s;
|
||||
|
||||
|
|
@ -161,7 +161,7 @@ int snd_mixer_simple_control_read(snd_mixer_t *handle, snd_mixer_simple_control_
|
|||
return s->get(handle, s, control);
|
||||
}
|
||||
|
||||
int snd_mixer_simple_control_write(snd_mixer_t *handle, snd_mixer_simple_control_t *control)
|
||||
int snd_mixer_simple_element_write(snd_mixer_t *handle, snd_mixer_simple_element_t *control)
|
||||
{
|
||||
mixer_simple_t *s;
|
||||
|
||||
|
|
@ -186,7 +186,7 @@ static void snd_mixer_simple_read_rebuild(snd_ctl_t *ctl_handle, void *private_d
|
|||
handle->simple_changes++;
|
||||
}
|
||||
|
||||
static void snd_mixer_simple_read_add(snd_ctl_t *ctl_handle ATTRIBUTE_UNUSED, void *private_data, snd_hcontrol_t *hcontrol)
|
||||
static void snd_mixer_simple_read_add(snd_ctl_t *ctl_handle ATTRIBUTE_UNUSED, void *private_data, snd_hctl_element_t *helem)
|
||||
{
|
||||
snd_mixer_t *handle = (snd_mixer_t *)private_data;
|
||||
mixer_simple_t *s;
|
||||
|
|
@ -195,7 +195,7 @@ static void snd_mixer_simple_read_add(snd_ctl_t *ctl_handle ATTRIBUTE_UNUSED, vo
|
|||
list_for_each(list, &handle->simples) {
|
||||
s = list_entry(list, mixer_simple_t, list);
|
||||
if (s->event_add)
|
||||
s->event_add(handle, hcontrol);
|
||||
s->event_add(handle, helem);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,11 +23,11 @@
|
|||
#include "list.h"
|
||||
|
||||
typedef struct _mixer_simple mixer_simple_t;
|
||||
typedef struct _mixer_simple_hcontrol_private mixer_simple_hcontrol_private_t;
|
||||
typedef struct _mixer_simple_hctl_element_private mixer_simple_hctl_element_private_t;
|
||||
|
||||
typedef int (mixer_simple_get_t) (snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simple_control_t *control);
|
||||
typedef int (mixer_simple_put_t) (snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simple_control_t *control);
|
||||
typedef int (mixer_simple_event_add_t) (snd_mixer_t *handle, snd_hcontrol_t *hcontrol);
|
||||
typedef int (mixer_simple_get_t) (snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simple_element_t *control);
|
||||
typedef int (mixer_simple_put_t) (snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simple_element_t *control);
|
||||
typedef int (mixer_simple_event_add_t) (snd_mixer_t *handle, snd_hctl_element_t *helem);
|
||||
|
||||
#define MIXER_PRESENT_SINGLE_SWITCH (1<<0)
|
||||
#define MIXER_PRESENT_SINGLE_VOLUME (1<<1)
|
||||
|
|
@ -69,12 +69,12 @@ struct _mixer_simple {
|
|||
mixer_simple_put_t *put;
|
||||
mixer_simple_event_add_t *event_add;
|
||||
struct list_head list;
|
||||
void *hcontrols; /* bag of associated hcontrols */
|
||||
void *helems; /* bag of associated helems */
|
||||
unsigned long private_value;
|
||||
};
|
||||
|
||||
struct _mixer_simple_hcontrol_private {
|
||||
void *simples; /* list of associated hcontrols */
|
||||
struct _mixer_simple_hctl_element_private {
|
||||
void *simples; /* list of associated helems */
|
||||
};
|
||||
|
||||
struct _snd_mixer {
|
||||
|
|
|
|||
|
|
@ -39,48 +39,48 @@ static struct mixer_name_table {
|
|||
{0, 0},
|
||||
};
|
||||
|
||||
static snd_hcontrol_t *test_mixer_id(snd_mixer_t *handle, const char *name, int index)
|
||||
static snd_hctl_element_t *test_mixer_id(snd_mixer_t *handle, const char *name, int index)
|
||||
{
|
||||
snd_control_id_t id;
|
||||
snd_hcontrol_t *hcontrol;
|
||||
snd_ctl_element_id_t id;
|
||||
snd_hctl_element_t *helem;
|
||||
|
||||
memset(&id, 0, sizeof(id));
|
||||
id.iface = SNDRV_CONTROL_IFACE_MIXER;
|
||||
id.iface = SNDRV_CTL_ELEMENT_IFACE_MIXER;
|
||||
strcpy(id.name, name);
|
||||
id.index = index;
|
||||
hcontrol = snd_ctl_hfind(handle->ctl_handle, &id);
|
||||
// fprintf(stderr, "Looking for control: '%s', %i (0x%lx)\n", name, index, (long)hcontrol);
|
||||
return hcontrol;
|
||||
helem = snd_ctl_hfind(handle->ctl_handle, &id);
|
||||
// fprintf(stderr, "Looking for control: '%s', %i (0x%lx)\n", name, index, (long)helem);
|
||||
return helem;
|
||||
}
|
||||
|
||||
static int get_mixer_info(snd_mixer_t *handle, const char *name, int index, snd_control_info_t *info)
|
||||
static int get_mixer_info(snd_mixer_t *handle, const char *name, int index, snd_ctl_element_info_t *info)
|
||||
{
|
||||
memset(info, 0, sizeof(*info));
|
||||
info->id.iface = SNDRV_CONTROL_IFACE_MIXER;
|
||||
info->id.iface = SNDRV_CTL_ELEMENT_IFACE_MIXER;
|
||||
strcpy(info->id.name, name);
|
||||
info->id.index = index;
|
||||
return snd_ctl_cinfo(handle->ctl_handle, info);
|
||||
return snd_ctl_element_info(handle->ctl_handle, info);
|
||||
}
|
||||
|
||||
static int get_mixer_read(snd_mixer_t *handle, const char *name, int index, snd_control_t *control)
|
||||
static int get_mixer_read(snd_mixer_t *handle, const char *name, int index, snd_ctl_element_t *control)
|
||||
{
|
||||
memset(control, 0, sizeof(*control));
|
||||
control->id.iface = SNDRV_CONTROL_IFACE_MIXER;
|
||||
control->id.iface = SNDRV_CTL_ELEMENT_IFACE_MIXER;
|
||||
strcpy(control->id.name, name);
|
||||
control->id.index = index;
|
||||
return snd_ctl_cread(handle->ctl_handle, control);
|
||||
return snd_ctl_element_read(handle->ctl_handle, control);
|
||||
}
|
||||
|
||||
static int put_mixer_write(snd_mixer_t *handle, const char *name, int index, snd_control_t *control)
|
||||
static int put_mixer_write(snd_mixer_t *handle, const char *name, int index, snd_ctl_element_t *control)
|
||||
{
|
||||
control->id.numid = 0;
|
||||
control->id.iface = SNDRV_CONTROL_IFACE_MIXER;
|
||||
control->id.iface = SNDRV_CTL_ELEMENT_IFACE_MIXER;
|
||||
strcpy(control->id.name, name);
|
||||
control->id.device = control->id.subdevice = 0;
|
||||
control->id.index = index;
|
||||
control->indirect = 0;
|
||||
memset(&control->reserved, 0, sizeof(control->reserved));
|
||||
return snd_ctl_cwrite(handle->ctl_handle, control);
|
||||
return snd_ctl_element_write(handle->ctl_handle, control);
|
||||
}
|
||||
|
||||
static mixer_simple_t *simple_new(mixer_simple_t *scontrol)
|
||||
|
|
@ -96,35 +96,35 @@ static mixer_simple_t *simple_new(mixer_simple_t *scontrol)
|
|||
return s;
|
||||
}
|
||||
|
||||
static void hcontrol_event_change(snd_ctl_t *ctl_handle ATTRIBUTE_UNUSED, snd_hcontrol_t *hcontrol ATTRIBUTE_UNUSED)
|
||||
static void hctl_element_event_change(snd_ctl_t *ctl_handle ATTRIBUTE_UNUSED, snd_hctl_element_t *helem ATTRIBUTE_UNUSED)
|
||||
{
|
||||
/* ignore at this moment */
|
||||
}
|
||||
|
||||
static void hcontrol_event_value(snd_ctl_t *ctl_handle ATTRIBUTE_UNUSED, snd_hcontrol_t *hcontrol)
|
||||
static void hctl_element_event_value(snd_ctl_t *ctl_handle ATTRIBUTE_UNUSED, snd_hctl_element_t *helem)
|
||||
{
|
||||
snd_mixer_t *handle = (snd_mixer_t *)hcontrol->private_data;
|
||||
snd_mixer_t *handle = (snd_mixer_t *)helem->private_data;
|
||||
mixer_simple_t *s;
|
||||
struct list_head *list;
|
||||
list_for_each(list, &handle->simples) {
|
||||
s = list_entry(list, mixer_simple_t, list);
|
||||
if (snd_ctl_hbag_find(&s->hcontrols, &hcontrol->id))
|
||||
if (snd_ctl_hbag_find(&s->helems, &helem->id))
|
||||
s->change++;
|
||||
}
|
||||
}
|
||||
|
||||
static void hcontrol_event_remove(snd_ctl_t *ctl_handle ATTRIBUTE_UNUSED, snd_hcontrol_t *hcontrol ATTRIBUTE_UNUSED)
|
||||
static void hctl_element_event_remove(snd_ctl_t *ctl_handle ATTRIBUTE_UNUSED, snd_hctl_element_t *helem ATTRIBUTE_UNUSED)
|
||||
{
|
||||
/* ignore at this moment */
|
||||
}
|
||||
|
||||
static void hcontrol_add(snd_mixer_t *handle, void **bag, snd_hcontrol_t *hcontrol)
|
||||
static void hctl_element_add(snd_mixer_t *handle, void **bag, snd_hctl_element_t *helem)
|
||||
{
|
||||
snd_ctl_hbag_add(bag, hcontrol);
|
||||
hcontrol->callback_change = hcontrol_event_change;
|
||||
hcontrol->callback_value = hcontrol_event_value;
|
||||
hcontrol->callback_remove = hcontrol_event_remove;
|
||||
hcontrol->private_data = handle;
|
||||
snd_ctl_hbag_add(bag, helem);
|
||||
helem->callback_change = hctl_element_event_change;
|
||||
helem->callback_value = hctl_element_event_value;
|
||||
helem->callback_remove = hctl_element_event_remove;
|
||||
helem->private_data = handle;
|
||||
}
|
||||
|
||||
static int simple_add(snd_mixer_t *handle, mixer_simple_t *scontrol)
|
||||
|
|
@ -142,7 +142,7 @@ static int simple_remove(snd_mixer_t *handle, mixer_simple_t *scontrol)
|
|||
return -EINVAL;
|
||||
list_del(&scontrol->list);
|
||||
handle->simple_count--;
|
||||
snd_ctl_hbag_destroy(&scontrol->hcontrols, NULL);
|
||||
snd_ctl_hbag_destroy(&scontrol->helems, NULL);
|
||||
free(scontrol);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -167,10 +167,10 @@ static const char *get_short_name(const char *lname)
|
|||
return lname;
|
||||
}
|
||||
|
||||
static int input_get_volume(snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simple_control_t *control, const char *direction, const char *postfix, int voices)
|
||||
static int input_get_volume(snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simple_element_t *control, const char *direction, const char *postfix, int voices)
|
||||
{
|
||||
char str[128];
|
||||
snd_control_t ctl;
|
||||
snd_ctl_element_t ctl;
|
||||
int idx, err;
|
||||
|
||||
sprintf(str, "%s%s%s", get_full_name(simple->sid.name), direction, postfix);
|
||||
|
|
@ -181,10 +181,10 @@ static int input_get_volume(snd_mixer_t *handle, mixer_simple_t *simple, snd_mix
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int input_get_mute_switch(snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simple_control_t *control, const char *direction, const char *postfix, int voices)
|
||||
static int input_get_mute_switch(snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simple_element_t *control, const char *direction, const char *postfix, int voices)
|
||||
{
|
||||
char str[128];
|
||||
snd_control_t ctl;
|
||||
snd_ctl_element_t ctl;
|
||||
int idx, err;
|
||||
|
||||
sprintf(str, "%s%s%s", get_full_name(simple->sid.name), direction, postfix);
|
||||
|
|
@ -196,10 +196,10 @@ static int input_get_mute_switch(snd_mixer_t *handle, mixer_simple_t *simple, sn
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int input_get_mute_route(snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simple_control_t *control, const char *direction, int voices)
|
||||
static int input_get_mute_route(snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simple_element_t *control, const char *direction, int voices)
|
||||
{
|
||||
char str[128];
|
||||
snd_control_t ctl;
|
||||
snd_ctl_element_t ctl;
|
||||
int idx, err;
|
||||
|
||||
sprintf(str, "%s %sRoute", get_full_name(simple->sid.name), direction);
|
||||
|
|
@ -211,10 +211,10 @@ static int input_get_mute_route(snd_mixer_t *handle, mixer_simple_t *simple, snd
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int input_get_capture_switch(snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simple_control_t *control, const char *direction, int voices)
|
||||
static int input_get_capture_switch(snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simple_element_t *control, const char *direction, int voices)
|
||||
{
|
||||
char str[128];
|
||||
snd_control_t ctl;
|
||||
snd_ctl_element_t ctl;
|
||||
int idx, err;
|
||||
|
||||
sprintf(str, "%s %sSwitch", get_full_name(simple->sid.name), direction);
|
||||
|
|
@ -226,10 +226,10 @@ static int input_get_capture_switch(snd_mixer_t *handle, mixer_simple_t *simple,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int input_get_capture_route(snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simple_control_t *control, const char *direction, int voices)
|
||||
static int input_get_capture_route(snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simple_element_t *control, const char *direction, int voices)
|
||||
{
|
||||
char str[128];
|
||||
snd_control_t ctl;
|
||||
snd_ctl_element_t ctl;
|
||||
int idx, err;
|
||||
|
||||
sprintf(str, "%s %sRoute", get_full_name(simple->sid.name), direction);
|
||||
|
|
@ -241,7 +241,7 @@ static int input_get_capture_route(snd_mixer_t *handle, mixer_simple_t *simple,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int input_get(snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simple_control_t *control)
|
||||
static int input_get(snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simple_element_t *control)
|
||||
{
|
||||
int idx, err;
|
||||
|
||||
|
|
@ -288,7 +288,7 @@ static int input_get(snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simp
|
|||
} else if (simple->present & MIXER_PRESENT_CAPTURE_ROUTE) {
|
||||
input_get_capture_route(handle, simple, control, "Capture ", simple->croute_values);
|
||||
} else if (simple->present & MIXER_PRESENT_CAPTURE_SOURCE) {
|
||||
snd_control_t ctl;
|
||||
snd_ctl_element_t ctl;
|
||||
if ((err = get_mixer_read(handle, "Capture Source", 0, &ctl)) < 0)
|
||||
return err;
|
||||
for (idx = 0; idx < simple->voices && idx < 32; idx++)
|
||||
|
|
@ -299,10 +299,10 @@ static int input_get(snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simp
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int input_put_volume(snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simple_control_t *control, const char *direction, const char *postfix, int voices)
|
||||
static int input_put_volume(snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simple_element_t *control, const char *direction, const char *postfix, int voices)
|
||||
{
|
||||
char str[128];
|
||||
snd_control_t ctl;
|
||||
snd_ctl_element_t ctl;
|
||||
int idx, err;
|
||||
|
||||
sprintf(str, "%s%s%s", get_full_name(simple->sid.name), direction, postfix);
|
||||
|
|
@ -317,10 +317,10 @@ static int input_put_volume(snd_mixer_t *handle, mixer_simple_t *simple, snd_mix
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int input_put_mute_switch(snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simple_control_t *control, const char *direction, const char *postfix, int voices)
|
||||
static int input_put_mute_switch(snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simple_element_t *control, const char *direction, const char *postfix, int voices)
|
||||
{
|
||||
char str[128];
|
||||
snd_control_t ctl;
|
||||
snd_ctl_element_t ctl;
|
||||
int idx, err;
|
||||
|
||||
sprintf(str, "%s%s%s", get_full_name(simple->sid.name), direction, postfix);
|
||||
|
|
@ -333,10 +333,10 @@ static int input_put_mute_switch(snd_mixer_t *handle, mixer_simple_t *simple, sn
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int input_put_mute_route(snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simple_control_t *control, const char *direction, int voices)
|
||||
static int input_put_mute_route(snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simple_element_t *control, const char *direction, int voices)
|
||||
{
|
||||
char str[128];
|
||||
snd_control_t ctl;
|
||||
snd_ctl_element_t ctl;
|
||||
int idx, err;
|
||||
|
||||
sprintf(str, "%s %sRoute", get_full_name(simple->sid.name), direction);
|
||||
|
|
@ -351,10 +351,10 @@ static int input_put_mute_route(snd_mixer_t *handle, mixer_simple_t *simple, snd
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int input_put_capture_switch(snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simple_control_t *control, const char *direction, int voices)
|
||||
static int input_put_capture_switch(snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simple_element_t *control, const char *direction, int voices)
|
||||
{
|
||||
char str[128];
|
||||
snd_control_t ctl;
|
||||
snd_ctl_element_t ctl;
|
||||
int idx, err;
|
||||
|
||||
sprintf(str, "%s %sSwitch", get_full_name(simple->sid.name), direction);
|
||||
|
|
@ -367,10 +367,10 @@ static int input_put_capture_switch(snd_mixer_t *handle, mixer_simple_t *simple,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int input_put_capture_route(snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simple_control_t *control, const char *direction, int voices)
|
||||
static int input_put_capture_route(snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simple_element_t *control, const char *direction, int voices)
|
||||
{
|
||||
char str[128];
|
||||
snd_control_t ctl;
|
||||
snd_ctl_element_t ctl;
|
||||
int idx, err;
|
||||
|
||||
sprintf(str, "%s %sRoute", get_full_name(simple->sid.name), direction);
|
||||
|
|
@ -385,7 +385,7 @@ static int input_put_capture_route(snd_mixer_t *handle, mixer_simple_t *simple,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int input_put(snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simple_control_t *control)
|
||||
static int input_put(snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simple_element_t *control)
|
||||
{
|
||||
int err, idx;
|
||||
|
||||
|
|
@ -422,7 +422,7 @@ static int input_put(snd_mixer_t *handle, mixer_simple_t *simple, snd_mixer_simp
|
|||
} else if (simple->present & MIXER_PRESENT_CAPTURE_ROUTE) {
|
||||
input_put_capture_route(handle, simple, control, "Capture ", simple->croute_values);
|
||||
} else if (simple->present & MIXER_PRESENT_CAPTURE_SOURCE) {
|
||||
snd_control_t ctl;
|
||||
snd_ctl_element_t ctl;
|
||||
if ((err = get_mixer_read(handle, "Capture Source", 0, &ctl)) < 0)
|
||||
return err;
|
||||
// fprintf(stderr, "put capture source : %i [0x%x]\n", simple->capture_item, control->capture);
|
||||
|
|
@ -458,15 +458,15 @@ static int build_input(snd_mixer_t *handle, const char *sname)
|
|||
char str[128];
|
||||
unsigned int present, caps, capture_item, voices;
|
||||
int index = -1, err;
|
||||
snd_control_info_t global_info;
|
||||
snd_control_info_t gswitch_info, pswitch_info, cswitch_info;
|
||||
snd_control_info_t gvolume_info, pvolume_info, cvolume_info;
|
||||
snd_control_info_t groute_info, proute_info, croute_info;
|
||||
snd_control_info_t csource_info;
|
||||
snd_ctl_element_info_t global_info;
|
||||
snd_ctl_element_info_t gswitch_info, pswitch_info, cswitch_info;
|
||||
snd_ctl_element_info_t gvolume_info, pvolume_info, cvolume_info;
|
||||
snd_ctl_element_info_t groute_info, proute_info, croute_info;
|
||||
snd_ctl_element_info_t csource_info;
|
||||
long min, max;
|
||||
void *bag;
|
||||
mixer_simple_t *simple;
|
||||
snd_hcontrol_t *hcontrol;
|
||||
snd_hctl_element_t *helem;
|
||||
const char *sname1;
|
||||
|
||||
memset(&gswitch_info, 0, sizeof(gswitch_info));
|
||||
|
|
@ -484,53 +484,53 @@ static int build_input(snd_mixer_t *handle, const char *sname)
|
|||
present = caps = capture_item = 0;
|
||||
min = max = 0;
|
||||
bag = NULL;
|
||||
if ((hcontrol = test_mixer_id(handle, sname, index)) != NULL) {
|
||||
if ((helem = test_mixer_id(handle, sname, index)) != NULL) {
|
||||
if ((err = get_mixer_info(handle, sname, index, &global_info)) < 0)
|
||||
return err;
|
||||
if (global_info.type == SNDRV_CONTROL_TYPE_BOOLEAN ||
|
||||
global_info.type == SNDRV_CONTROL_TYPE_INTEGER) {
|
||||
if (global_info.type == SNDRV_CTL_ELEMENT_TYPE_BOOLEAN ||
|
||||
global_info.type == SNDRV_CTL_ELEMENT_TYPE_INTEGER) {
|
||||
if (voices < global_info.count)
|
||||
voices = global_info.count;
|
||||
caps |= global_info.type == SNDRV_CONTROL_TYPE_BOOLEAN ? SND_MIXER_SCTCAP_MUTE : SND_MIXER_SCTCAP_VOLUME;
|
||||
present |= global_info.type == SNDRV_CONTROL_TYPE_BOOLEAN ? MIXER_PRESENT_SINGLE_SWITCH : MIXER_PRESENT_SINGLE_VOLUME;
|
||||
if (global_info.type == SNDRV_CONTROL_TYPE_INTEGER) {
|
||||
caps |= global_info.type == SNDRV_CTL_ELEMENT_TYPE_BOOLEAN ? SND_MIXER_SCTCAP_MUTE : SND_MIXER_SCTCAP_VOLUME;
|
||||
present |= global_info.type == SNDRV_CTL_ELEMENT_TYPE_BOOLEAN ? MIXER_PRESENT_SINGLE_SWITCH : MIXER_PRESENT_SINGLE_VOLUME;
|
||||
if (global_info.type == SNDRV_CTL_ELEMENT_TYPE_INTEGER) {
|
||||
if (min > global_info.value.integer.min)
|
||||
min = global_info.value.integer.min;
|
||||
if (max < global_info.value.integer.max)
|
||||
max = global_info.value.integer.max;
|
||||
}
|
||||
hcontrol_add(handle, &bag, hcontrol);
|
||||
hctl_element_add(handle, &bag, helem);
|
||||
}
|
||||
}
|
||||
sprintf(str, "%s Switch", sname);
|
||||
if ((hcontrol = test_mixer_id(handle, str, index)) != NULL) {
|
||||
if ((helem = test_mixer_id(handle, str, index)) != NULL) {
|
||||
if ((err = get_mixer_info(handle, str, index, &gswitch_info)) < 0)
|
||||
return err;
|
||||
if (gswitch_info.type == SNDRV_CONTROL_TYPE_BOOLEAN) {
|
||||
if (gswitch_info.type == SNDRV_CTL_ELEMENT_TYPE_BOOLEAN) {
|
||||
if (voices < gswitch_info.count)
|
||||
voices = gswitch_info.count;
|
||||
caps |= SND_MIXER_SCTCAP_MUTE;
|
||||
present |= MIXER_PRESENT_GLOBAL_SWITCH;
|
||||
hcontrol_add(handle, &bag, hcontrol);
|
||||
hctl_element_add(handle, &bag, helem);
|
||||
}
|
||||
}
|
||||
sprintf(str, "%s Route", sname);
|
||||
if ((hcontrol = test_mixer_id(handle, str, index)) != NULL) {
|
||||
if ((helem = test_mixer_id(handle, str, index)) != NULL) {
|
||||
if ((err = get_mixer_info(handle, str, index, &groute_info)) < 0)
|
||||
return err;
|
||||
if (groute_info.type == SNDRV_CONTROL_TYPE_BOOLEAN && groute_info.count == 4) {
|
||||
if (groute_info.type == SNDRV_CTL_ELEMENT_TYPE_BOOLEAN && groute_info.count == 4) {
|
||||
if (voices < 2)
|
||||
voices = 2;
|
||||
caps |= SND_MIXER_SCTCAP_MUTE;
|
||||
present |= MIXER_PRESENT_GLOBAL_ROUTE;
|
||||
hcontrol_add(handle, &bag, hcontrol);
|
||||
hctl_element_add(handle, &bag, helem);
|
||||
}
|
||||
}
|
||||
sprintf(str, "%s Volume", sname);
|
||||
if ((hcontrol = test_mixer_id(handle, str, index)) != NULL) {
|
||||
if ((helem = test_mixer_id(handle, str, index)) != NULL) {
|
||||
if ((err = get_mixer_info(handle, str, index, &gvolume_info)) < 0)
|
||||
return err;
|
||||
if (gvolume_info.type == SNDRV_CONTROL_TYPE_INTEGER) {
|
||||
if (gvolume_info.type == SNDRV_CTL_ELEMENT_TYPE_INTEGER) {
|
||||
if (voices < gvolume_info.count)
|
||||
voices = gvolume_info.count;
|
||||
if (min > gvolume_info.value.integer.min)
|
||||
|
|
@ -539,62 +539,62 @@ static int build_input(snd_mixer_t *handle, const char *sname)
|
|||
max = gvolume_info.value.integer.max;
|
||||
caps |= SND_MIXER_SCTCAP_VOLUME;
|
||||
present |= MIXER_PRESENT_GLOBAL_VOLUME;
|
||||
hcontrol_add(handle, &bag, hcontrol);
|
||||
hctl_element_add(handle, &bag, helem);
|
||||
}
|
||||
}
|
||||
sprintf(str, "%s Playback Switch", sname);
|
||||
if ((hcontrol = test_mixer_id(handle, str, index)) != NULL) {
|
||||
if ((helem = test_mixer_id(handle, str, index)) != NULL) {
|
||||
if ((err = get_mixer_info(handle, str, index, &pswitch_info)) < 0)
|
||||
return err;
|
||||
if (pswitch_info.type == SNDRV_CONTROL_TYPE_BOOLEAN) {
|
||||
if (pswitch_info.type == SNDRV_CTL_ELEMENT_TYPE_BOOLEAN) {
|
||||
if (voices < pswitch_info.count)
|
||||
voices = pswitch_info.count;
|
||||
caps |= SND_MIXER_SCTCAP_MUTE;
|
||||
present |= MIXER_PRESENT_PLAYBACK_SWITCH;
|
||||
hcontrol_add(handle, &bag, hcontrol);
|
||||
hctl_element_add(handle, &bag, helem);
|
||||
}
|
||||
}
|
||||
sprintf(str, "%s Playback Route", sname);
|
||||
if ((hcontrol = test_mixer_id(handle, str, index)) != NULL) {
|
||||
if ((helem = test_mixer_id(handle, str, index)) != NULL) {
|
||||
if ((err = get_mixer_info(handle, str, index, &proute_info)) < 0)
|
||||
return err;
|
||||
if (proute_info.type == SNDRV_CONTROL_TYPE_BOOLEAN && proute_info.count == 4) {
|
||||
if (proute_info.type == SNDRV_CTL_ELEMENT_TYPE_BOOLEAN && proute_info.count == 4) {
|
||||
if (voices < 2)
|
||||
voices = 2;
|
||||
caps |= SND_MIXER_SCTCAP_MUTE;
|
||||
present |= MIXER_PRESENT_PLAYBACK_ROUTE;
|
||||
hcontrol_add(handle, &bag, hcontrol);
|
||||
hctl_element_add(handle, &bag, helem);
|
||||
}
|
||||
}
|
||||
sprintf(str, "%s Capture Switch", sname);
|
||||
if ((hcontrol = test_mixer_id(handle, str, index)) != NULL) {
|
||||
if ((helem = test_mixer_id(handle, str, index)) != NULL) {
|
||||
if ((err = get_mixer_info(handle, str, index, &cswitch_info)) < 0)
|
||||
return err;
|
||||
if (cswitch_info.type == SNDRV_CONTROL_TYPE_BOOLEAN) {
|
||||
if (cswitch_info.type == SNDRV_CTL_ELEMENT_TYPE_BOOLEAN) {
|
||||
if (voices < cswitch_info.count)
|
||||
voices = cswitch_info.count;
|
||||
caps |= SND_MIXER_SCTCAP_CAPTURE;
|
||||
present |= MIXER_PRESENT_CAPTURE_SWITCH;
|
||||
hcontrol_add(handle, &bag, hcontrol);
|
||||
hctl_element_add(handle, &bag, helem);
|
||||
}
|
||||
}
|
||||
sprintf(str, "%s Capture Route", sname);
|
||||
if ((hcontrol = test_mixer_id(handle, str, index)) != NULL) {
|
||||
if ((helem = test_mixer_id(handle, str, index)) != NULL) {
|
||||
if ((err = get_mixer_info(handle, str, index, &croute_info)) < 0)
|
||||
return err;
|
||||
if (croute_info.type == SNDRV_CONTROL_TYPE_BOOLEAN && croute_info.count == 4) {
|
||||
if (croute_info.type == SNDRV_CTL_ELEMENT_TYPE_BOOLEAN && croute_info.count == 4) {
|
||||
if (voices < 2)
|
||||
voices = 2;
|
||||
caps |= SND_MIXER_SCTCAP_CAPTURE;
|
||||
present |= MIXER_PRESENT_CAPTURE_ROUTE;
|
||||
hcontrol_add(handle, &bag, hcontrol);
|
||||
hctl_element_add(handle, &bag, helem);
|
||||
}
|
||||
}
|
||||
sprintf(str, "%s Playback Volume", sname);
|
||||
if ((hcontrol = test_mixer_id(handle, str, index)) != NULL) {
|
||||
if ((helem = test_mixer_id(handle, str, index)) != NULL) {
|
||||
if ((err = get_mixer_info(handle, str, index, &pvolume_info)) < 0)
|
||||
return err;
|
||||
if (pvolume_info.type == SNDRV_CONTROL_TYPE_INTEGER) {
|
||||
if (pvolume_info.type == SNDRV_CTL_ELEMENT_TYPE_INTEGER) {
|
||||
if (voices < pvolume_info.count)
|
||||
voices = pvolume_info.count;
|
||||
if (min > pvolume_info.value.integer.min)
|
||||
|
|
@ -603,14 +603,14 @@ static int build_input(snd_mixer_t *handle, const char *sname)
|
|||
max = pvolume_info.value.integer.max;
|
||||
caps |= SND_MIXER_SCTCAP_VOLUME;
|
||||
present |= MIXER_PRESENT_PLAYBACK_VOLUME;
|
||||
hcontrol_add(handle, &bag, hcontrol);
|
||||
hctl_element_add(handle, &bag, helem);
|
||||
}
|
||||
}
|
||||
sprintf(str, "%s Capture Volume", sname);
|
||||
if ((hcontrol = test_mixer_id(handle, str, index)) != NULL) {
|
||||
if ((helem = test_mixer_id(handle, str, index)) != NULL) {
|
||||
if ((err = get_mixer_info(handle, str, index, &cvolume_info)) < 0)
|
||||
return err;
|
||||
if (cvolume_info.type == SNDRV_CONTROL_TYPE_INTEGER) {
|
||||
if (cvolume_info.type == SNDRV_CTL_ELEMENT_TYPE_INTEGER) {
|
||||
if (voices < cvolume_info.count)
|
||||
voices = cvolume_info.count;
|
||||
if (min > pvolume_info.value.integer.min)
|
||||
|
|
@ -619,10 +619,10 @@ static int build_input(snd_mixer_t *handle, const char *sname)
|
|||
max = pvolume_info.value.integer.max;
|
||||
caps |= SND_MIXER_SCTCAP_VOLUME;
|
||||
present |= MIXER_PRESENT_CAPTURE_VOLUME;
|
||||
hcontrol_add(handle, &bag, hcontrol);
|
||||
hctl_element_add(handle, &bag, helem);
|
||||
}
|
||||
}
|
||||
if (index == 0 && (hcontrol = test_mixer_id(handle, "Capture Source", 0)) != NULL) {
|
||||
if (index == 0 && (helem = test_mixer_id(handle, "Capture Source", 0)) != NULL) {
|
||||
if ((err = get_mixer_info(handle, "Capture Source", 0, &csource_info)) < 0)
|
||||
return err;
|
||||
strcpy(str, sname);
|
||||
|
|
@ -630,24 +630,24 @@ static int build_input(snd_mixer_t *handle, const char *sname)
|
|||
strcpy(str, "Mix");
|
||||
else if (!strcmp(str, "Master Mono")) /* special case */
|
||||
strcpy(str, "Mono Mix");
|
||||
if (csource_info.type == SNDRV_CONTROL_TYPE_ENUMERATED) {
|
||||
if (csource_info.type == SNDRV_CTL_ELEMENT_TYPE_ENUMERATED) {
|
||||
capture_item = 0;
|
||||
if (!strcmp(csource_info.value.enumerated.name, str)) {
|
||||
if (voices < csource_info.count)
|
||||
voices = csource_info.count;
|
||||
caps |= SND_MIXER_SCTCAP_CAPTURE;
|
||||
present |= MIXER_PRESENT_CAPTURE_SOURCE;
|
||||
hcontrol_add(handle, &bag, hcontrol);
|
||||
hctl_element_add(handle, &bag, helem);
|
||||
} else for (capture_item = 1; capture_item < csource_info.value.enumerated.items; capture_item++) {
|
||||
csource_info.value.enumerated.item = capture_item;
|
||||
if ((err = snd_ctl_cinfo(handle->ctl_handle, &csource_info)) < 0)
|
||||
if ((err = snd_ctl_element_info(handle->ctl_handle, &csource_info)) < 0)
|
||||
return err;
|
||||
if (!strcmp(csource_info.value.enumerated.name, str)) {
|
||||
if (voices < csource_info.count)
|
||||
voices = csource_info.count;
|
||||
caps |= SND_MIXER_SCTCAP_CAPTURE;
|
||||
present |= MIXER_PRESENT_CAPTURE_SOURCE;
|
||||
hcontrol_add(handle, &bag, hcontrol);
|
||||
hctl_element_add(handle, &bag, helem);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -722,7 +722,7 @@ static int build_input(snd_mixer_t *handle, const char *sname)
|
|||
simple->voices = voices;
|
||||
simple->min = min;
|
||||
simple->max = max;
|
||||
simple->hcontrols = bag;
|
||||
simple->helems = bag;
|
||||
// fprintf(stderr, "sname = '%s', index = %i, present = 0x%x, voices = %i\n", sname, index, present, voices);
|
||||
};
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -144,7 +144,6 @@ int snd_rawmidi_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
|
|||
snd_config_t *rawmidi_conf, *conf, *type_conf;
|
||||
snd_config_iterator_t i;
|
||||
snd_rawmidi_params_t params;
|
||||
unsigned int stream;
|
||||
const char *lib = NULL, *open = NULL;
|
||||
int (*open_func)(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
|
||||
char *name, snd_config_t *conf, int mode);
|
||||
|
|
|
|||
|
|
@ -171,8 +171,7 @@ int snd_rawmidi_hw_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
|
|||
snd_rawmidi_t *rmidi;
|
||||
snd_rawmidi_hw_t *hw = NULL;
|
||||
snd_rawmidi_info_t info;
|
||||
int fmode, str;
|
||||
int c;
|
||||
int fmode;
|
||||
|
||||
if (inputp)
|
||||
*inputp = NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue