mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-11-10 00:45:41 +01:00
Better names for control API
This commit is contained in:
parent
4b6c8ce82e
commit
7d75ba2c1b
4 changed files with 327 additions and 327 deletions
|
@ -63,16 +63,16 @@ static void help(void)
|
|||
printf(" from configuration file\n");
|
||||
}
|
||||
|
||||
char *id_str(snd_control_id_t *id)
|
||||
char *id_str(snd_ctl_element_id_t *id)
|
||||
{
|
||||
static char str[128];
|
||||
assert(id);
|
||||
sprintf(str, "%i,%i,%i,%s,%i",
|
||||
snd_enum_to_int(snd_control_id_get_interface(id)),
|
||||
snd_control_id_get_device(id),
|
||||
snd_control_id_get_subdevice(id),
|
||||
snd_control_id_get_name(id),
|
||||
snd_control_id_get_index(id));
|
||||
snd_enum_to_int(snd_ctl_element_id_get_interface(id)),
|
||||
snd_ctl_element_id_get_device(id),
|
||||
snd_ctl_element_id_get_subdevice(id),
|
||||
snd_ctl_element_id_get_name(id),
|
||||
snd_ctl_element_id_get_index(id));
|
||||
return str;
|
||||
}
|
||||
|
||||
|
@ -140,10 +140,10 @@ static int snd_config_compound_add(snd_config_t *father, const char *id, int joi
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int get_control(snd_ctl_t *handle, snd_control_id_t *id, snd_config_t *top)
|
||||
static int get_control(snd_ctl_t *handle, snd_ctl_element_id_t *id, snd_config_t *top)
|
||||
{
|
||||
snd_control_t *ctl;
|
||||
snd_control_info_t *info;
|
||||
snd_ctl_element_t *ctl;
|
||||
snd_ctl_element_info_t *info;
|
||||
snd_config_t *control, *comment, *item, *value;
|
||||
const char *s;
|
||||
char buf[256];
|
||||
|
@ -151,27 +151,27 @@ static int get_control(snd_ctl_t *handle, snd_control_id_t *id, snd_config_t *to
|
|||
int err;
|
||||
unsigned int device, subdevice, index;
|
||||
const char *name;
|
||||
snd_control_type_t type;
|
||||
snd_ctl_element_type_t type;
|
||||
unsigned int count;
|
||||
snd_control_alloca(&ctl);
|
||||
snd_control_info_alloca(&info);
|
||||
snd_control_info_set_id(info, id);
|
||||
err = snd_ctl_cinfo(handle, info);
|
||||
snd_ctl_element_alloca(&ctl);
|
||||
snd_ctl_element_info_alloca(&info);
|
||||
snd_ctl_element_info_set_id(info, id);
|
||||
err = snd_ctl_element_info(handle, info);
|
||||
if (err < 0) {
|
||||
error("Cannot read control info '%s': %s", id_str(id), snd_strerror(err));
|
||||
return err;
|
||||
}
|
||||
|
||||
if (!snd_control_info_is_readable(info))
|
||||
if (!snd_ctl_element_info_is_readable(info))
|
||||
return 0;
|
||||
snd_control_set_id(ctl, id);
|
||||
err = snd_ctl_cread(handle, ctl);
|
||||
snd_ctl_element_set_id(ctl, id);
|
||||
err = snd_ctl_element_read(handle, ctl);
|
||||
if (err < 0) {
|
||||
error("Cannot read control '%s': %s", id_str(id), snd_strerror(err));
|
||||
return err;
|
||||
}
|
||||
|
||||
err = snd_config_compound_add(top, num_str(snd_control_info_get_numid(info)), 0, &control);
|
||||
err = snd_config_compound_add(top, num_str(snd_ctl_element_info_get_numid(info)), 0, &control);
|
||||
if (err < 0) {
|
||||
error("snd_config_compound_add: %s", snd_strerror(err));
|
||||
return err;
|
||||
|
@ -184,17 +184,17 @@ static int get_control(snd_ctl_t *handle, snd_control_id_t *id, snd_config_t *to
|
|||
|
||||
buf[0] = '\0';
|
||||
buf[1] = '\0';
|
||||
if (snd_control_info_is_readable(info))
|
||||
if (snd_ctl_element_info_is_readable(info))
|
||||
strcat(buf, " read");
|
||||
if (snd_control_info_is_writable(info))
|
||||
if (snd_ctl_element_info_is_writable(info))
|
||||
strcat(buf, " write");
|
||||
if (snd_control_info_is_inactive(info))
|
||||
if (snd_ctl_element_info_is_inactive(info))
|
||||
strcat(buf, " inactive");
|
||||
if (snd_control_info_is_volatile(info))
|
||||
if (snd_ctl_element_info_is_volatile(info))
|
||||
strcat(buf, " volatile");
|
||||
if (snd_control_info_is_locked(info))
|
||||
if (snd_ctl_element_info_is_locked(info))
|
||||
strcat(buf, " locked");
|
||||
if (snd_control_info_is_indirect(info))
|
||||
if (snd_ctl_element_info_is_indirect(info))
|
||||
strcat(buf, " indirect");
|
||||
err = snd_config_string_add(comment, "access", buf + 1);
|
||||
if (err < 0) {
|
||||
|
@ -202,13 +202,13 @@ static int get_control(snd_ctl_t *handle, snd_control_id_t *id, snd_config_t *to
|
|||
return err;
|
||||
}
|
||||
|
||||
type = snd_control_info_get_type(info);
|
||||
device = snd_control_info_get_device(info);
|
||||
subdevice = snd_control_info_get_subdevice(info);
|
||||
index = snd_control_info_get_index(info);
|
||||
name = snd_control_info_get_name(info);
|
||||
count = snd_control_info_get_count(info);
|
||||
s = snd_control_type_name(type);
|
||||
type = snd_ctl_element_info_get_type(info);
|
||||
device = snd_ctl_element_info_get_device(info);
|
||||
subdevice = snd_ctl_element_info_get_subdevice(info);
|
||||
index = snd_ctl_element_info_get_index(info);
|
||||
name = snd_ctl_element_info_get_name(info);
|
||||
count = snd_ctl_element_info_get_count(info);
|
||||
s = snd_ctl_element_type_name(type);
|
||||
err = snd_config_string_add(comment, "type", s);
|
||||
if (err < 0) {
|
||||
error("snd_config_string_add: %s", snd_strerror(err));
|
||||
|
@ -216,13 +216,13 @@ static int get_control(snd_ctl_t *handle, snd_control_id_t *id, snd_config_t *to
|
|||
}
|
||||
|
||||
switch (snd_enum_to_int(type)) {
|
||||
case SND_CONTROL_TYPE_BOOLEAN:
|
||||
case SND_CTL_ELEMENT_TYPE_BOOLEAN:
|
||||
break;
|
||||
case SND_CONTROL_TYPE_INTEGER:
|
||||
case SND_CTL_ELEMENT_TYPE_INTEGER:
|
||||
{
|
||||
long min = snd_control_info_get_min(info);
|
||||
long max = snd_control_info_get_max(info);
|
||||
long step = snd_control_info_get_step(info);
|
||||
long min = snd_ctl_element_info_get_min(info);
|
||||
long max = snd_ctl_element_info_get_max(info);
|
||||
long step = snd_ctl_element_info_get_step(info);
|
||||
if (step)
|
||||
sprintf(buf, "%li - %li (step %li)", min, max, step);
|
||||
else
|
||||
|
@ -234,7 +234,7 @@ static int get_control(snd_ctl_t *handle, snd_control_id_t *id, snd_config_t *to
|
|||
}
|
||||
break;
|
||||
}
|
||||
case SND_CONTROL_TYPE_ENUMERATED:
|
||||
case SND_CTL_ELEMENT_TYPE_ENUMERATED:
|
||||
{
|
||||
unsigned int items;
|
||||
err = snd_config_compound_add(comment, "item", 1, &item);
|
||||
|
@ -242,15 +242,15 @@ static int get_control(snd_ctl_t *handle, snd_control_id_t *id, snd_config_t *to
|
|||
error("snd_config_compound_add: %s", snd_strerror(err));
|
||||
return err;
|
||||
}
|
||||
items = snd_control_info_get_items(info);
|
||||
items = snd_ctl_element_info_get_items(info);
|
||||
for (idx = 0; idx < items; idx++) {
|
||||
snd_control_info_set_item(info, idx);
|
||||
err = snd_ctl_cinfo(handle, info);
|
||||
snd_ctl_element_info_set_item(info, idx);
|
||||
err = snd_ctl_element_info(handle, info);
|
||||
if (err < 0) {
|
||||
error("snd_ctl_info: %s", snd_strerror(err));
|
||||
error("snd_ctl_card_info: %s", snd_strerror(err));
|
||||
return err;
|
||||
}
|
||||
err = snd_config_string_add(item, num_str(idx), snd_control_info_get_item_name(info));
|
||||
err = snd_config_string_add(item, num_str(idx), snd_ctl_element_info_get_item_name(info));
|
||||
if (err < 0) {
|
||||
error("snd_config_string_add: %s", snd_strerror(err));
|
||||
return err;
|
||||
|
@ -261,7 +261,7 @@ static int get_control(snd_ctl_t *handle, snd_control_id_t *id, snd_config_t *to
|
|||
default:
|
||||
break;
|
||||
}
|
||||
s = snd_control_iface_name(snd_control_info_get_interface(info));
|
||||
s = snd_ctl_element_iface_name(snd_ctl_element_info_get_interface(info));
|
||||
err = snd_config_string_add(control, "iface", s);
|
||||
if (err < 0) {
|
||||
error("snd_config_string_add: %s", snd_strerror(err));
|
||||
|
@ -295,15 +295,15 @@ static int get_control(snd_ctl_t *handle, snd_control_id_t *id, snd_config_t *to
|
|||
}
|
||||
|
||||
switch (snd_enum_to_int(type)) {
|
||||
case SND_CONTROL_TYPE_BYTES:
|
||||
case SND_CONTROL_TYPE_IEC958:
|
||||
case SND_CTL_ELEMENT_TYPE_BYTES:
|
||||
case SND_CTL_ELEMENT_TYPE_IEC958:
|
||||
{
|
||||
size_t size = type == SND_CONTROL_TYPE_BYTES ?
|
||||
size_t size = type == SND_CTL_ELEMENT_TYPE_BYTES ?
|
||||
count : sizeof(snd_aes_iec958_t);
|
||||
char buf[count * 2 + 1];
|
||||
char *p = buf;
|
||||
char *hex = "0123456789abcdef";
|
||||
const char *bytes = snd_control_get_bytes(ctl);
|
||||
const char *bytes = snd_ctl_element_get_bytes(ctl);
|
||||
for (idx = 0; idx < size; idx++) {
|
||||
int v = bytes[idx];
|
||||
*p++ = hex[v >> 4];
|
||||
|
@ -323,23 +323,23 @@ static int get_control(snd_ctl_t *handle, snd_control_id_t *id, snd_config_t *to
|
|||
|
||||
if (count == 1) {
|
||||
switch (snd_enum_to_int(type)) {
|
||||
case SND_CONTROL_TYPE_BOOLEAN:
|
||||
err = snd_config_string_add(control, "value", snd_control_get_boolean(ctl, 0) ? "true" : "false");
|
||||
case SND_CTL_ELEMENT_TYPE_BOOLEAN:
|
||||
err = snd_config_string_add(control, "value", snd_ctl_element_get_boolean(ctl, 0) ? "true" : "false");
|
||||
if (err < 0) {
|
||||
error("snd_config_string_add: %s", snd_strerror(err));
|
||||
return err;
|
||||
}
|
||||
return 0;
|
||||
case SND_CONTROL_TYPE_INTEGER:
|
||||
err = snd_config_integer_add(control, "value", snd_control_get_integer(ctl, 0));
|
||||
case SND_CTL_ELEMENT_TYPE_INTEGER:
|
||||
err = snd_config_integer_add(control, "value", snd_ctl_element_get_integer(ctl, 0));
|
||||
if (err < 0) {
|
||||
error("snd_config_integer_add: %s", snd_strerror(err));
|
||||
return err;
|
||||
}
|
||||
return 0;
|
||||
case SND_CONTROL_TYPE_ENUMERATED:
|
||||
case SND_CTL_ELEMENT_TYPE_ENUMERATED:
|
||||
{
|
||||
unsigned int v = snd_control_get_enumerated(ctl, 0);
|
||||
unsigned int v = snd_ctl_element_get_enumerated(ctl, 0);
|
||||
snd_config_t *c;
|
||||
err = snd_config_search(item, num_str(v), &c);
|
||||
if (err == 0) {
|
||||
|
@ -366,27 +366,27 @@ static int get_control(snd_ctl_t *handle, snd_control_id_t *id, snd_config_t *to
|
|||
}
|
||||
|
||||
switch (snd_enum_to_int(type)) {
|
||||
case SND_CONTROL_TYPE_BOOLEAN:
|
||||
case SND_CTL_ELEMENT_TYPE_BOOLEAN:
|
||||
for (idx = 0; idx < count; idx++) {
|
||||
err = snd_config_string_add(value, num_str(idx), snd_control_get_boolean(ctl, idx) ? "true" : "false");
|
||||
err = snd_config_string_add(value, num_str(idx), snd_ctl_element_get_boolean(ctl, idx) ? "true" : "false");
|
||||
if (err < 0) {
|
||||
error("snd_config_string_add: %s", snd_strerror(err));
|
||||
return err;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SND_CONTROL_TYPE_INTEGER:
|
||||
case SND_CTL_ELEMENT_TYPE_INTEGER:
|
||||
for (idx = 0; idx < count; idx++) {
|
||||
err = snd_config_integer_add(value, num_str(idx), snd_control_get_integer(ctl, idx));
|
||||
err = snd_config_integer_add(value, num_str(idx), snd_ctl_element_get_integer(ctl, idx));
|
||||
if (err < 0) {
|
||||
error("snd_config_integer_add: %s", snd_strerror(err));
|
||||
return err;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SND_CONTROL_TYPE_ENUMERATED:
|
||||
case SND_CTL_ELEMENT_TYPE_ENUMERATED:
|
||||
for (idx = 0; idx < count; idx++) {
|
||||
unsigned int v = snd_control_get_enumerated(ctl, idx);
|
||||
unsigned int v = snd_ctl_element_get_enumerated(ctl, idx);
|
||||
snd_config_t *c;
|
||||
err = snd_config_search(item, num_str(v), &c);
|
||||
if (err == 0) {
|
||||
|
@ -413,16 +413,16 @@ static int get_control(snd_ctl_t *handle, snd_control_id_t *id, snd_config_t *to
|
|||
static int get_controls(int cardno, snd_config_t *top)
|
||||
{
|
||||
snd_ctl_t *handle;
|
||||
snd_ctl_info_t *info;
|
||||
snd_ctl_card_info_t *info;
|
||||
snd_config_t *state, *card, *control;
|
||||
snd_control_list_t *list;
|
||||
snd_ctl_element_list_t *list;
|
||||
unsigned int idx;
|
||||
int err;
|
||||
char name[32];
|
||||
unsigned int count;
|
||||
const char *id;
|
||||
snd_ctl_info_alloca(&info);
|
||||
snd_control_list_alloca(&list);
|
||||
snd_ctl_card_info_alloca(&info);
|
||||
snd_ctl_element_list_alloca(&list);
|
||||
|
||||
sprintf(name, "hw:%d", cardno);
|
||||
err = snd_ctl_open(&handle, name);
|
||||
|
@ -430,12 +430,12 @@ static int get_controls(int cardno, snd_config_t *top)
|
|||
error("snd_ctl_open error: %s", snd_strerror(err));
|
||||
return err;
|
||||
}
|
||||
err = snd_ctl_info(handle, info);
|
||||
err = snd_ctl_card_info(handle, info);
|
||||
if (err < 0) {
|
||||
error("snd_ctl_info error: %s", snd_strerror(err));
|
||||
error("snd_ctl_card_info error: %s", snd_strerror(err));
|
||||
goto _close;
|
||||
}
|
||||
id = snd_ctl_info_get_id(info);
|
||||
id = snd_ctl_card_info_get_id(info);
|
||||
err = snd_config_search(top, "state", &state);
|
||||
if (err == 0 &&
|
||||
snd_config_get_type(state) != SND_CONFIG_TYPE_COMPOUND) {
|
||||
|
@ -482,13 +482,13 @@ static int get_controls(int cardno, snd_config_t *top)
|
|||
error("Cannot determine controls: %s", snd_strerror(err));
|
||||
goto _close;
|
||||
}
|
||||
count = snd_control_list_get_count(list);
|
||||
count = snd_ctl_element_list_get_count(list);
|
||||
if (count <= 0) {
|
||||
err = 0;
|
||||
goto _close;
|
||||
}
|
||||
snd_control_list_set_offset(list, 0);
|
||||
if (snd_control_list_alloc_space(list, count) < 0) {
|
||||
snd_ctl_element_list_set_offset(list, 0);
|
||||
if (snd_ctl_element_list_alloc_space(list, count) < 0) {
|
||||
error("No enough memory...");
|
||||
goto _close;
|
||||
}
|
||||
|
@ -497,9 +497,9 @@ static int get_controls(int cardno, snd_config_t *top)
|
|||
goto _free;
|
||||
}
|
||||
for (idx = 0; idx < count; ++idx) {
|
||||
snd_control_id_t *id;
|
||||
snd_control_id_alloca(&id);
|
||||
snd_control_list_get_id(list, idx, id);
|
||||
snd_ctl_element_id_t *id;
|
||||
snd_ctl_element_id_alloca(&id);
|
||||
snd_ctl_element_list_get_id(list, idx, id);
|
||||
err = get_control(handle, id, control);
|
||||
if (err < 0)
|
||||
goto _free;
|
||||
|
@ -507,7 +507,7 @@ static int get_controls(int cardno, snd_config_t *top)
|
|||
|
||||
err = 0;
|
||||
_free:
|
||||
snd_control_list_free_space(list);
|
||||
snd_ctl_element_list_free_space(list);
|
||||
_close:
|
||||
snd_ctl_close(handle);
|
||||
return err;
|
||||
|
@ -517,7 +517,7 @@ static int get_controls(int cardno, snd_config_t *top)
|
|||
static int config_iface(snd_config_t *n)
|
||||
{
|
||||
unsigned long i;
|
||||
snd_control_iface_t idx;
|
||||
snd_ctl_element_iface_t idx;
|
||||
const char *str;
|
||||
switch (snd_enum_to_int(snd_config_get_type(n))) {
|
||||
case SND_CONFIG_TYPE_INTEGER:
|
||||
|
@ -529,8 +529,8 @@ static int config_iface(snd_config_t *n)
|
|||
default:
|
||||
return -1;
|
||||
}
|
||||
for (idx = 0; idx <= SND_CONTROL_IFACE_LAST; snd_enum_incr(idx)) {
|
||||
if (strcasecmp(snd_control_iface_name(idx), str) == 0)
|
||||
for (idx = 0; idx <= SND_CTL_ELEMENT_IFACE_LAST; snd_enum_incr(idx)) {
|
||||
if (strcasecmp(snd_ctl_element_iface_name(idx), str) == 0)
|
||||
return snd_enum_to_int(idx);
|
||||
}
|
||||
return -1;
|
||||
|
@ -560,7 +560,7 @@ static int config_bool(snd_config_t *n)
|
|||
}
|
||||
|
||||
static int config_enumerated(snd_config_t *n, snd_ctl_t *handle,
|
||||
snd_control_info_t *info)
|
||||
snd_ctl_element_info_t *info)
|
||||
{
|
||||
const char *str;
|
||||
long val;
|
||||
|
@ -575,16 +575,16 @@ static int config_enumerated(snd_config_t *n, snd_ctl_t *handle,
|
|||
default:
|
||||
return -1;
|
||||
}
|
||||
items = snd_control_info_get_items(info);
|
||||
items = snd_ctl_element_info_get_items(info);
|
||||
for (idx = 0; idx < items; idx++) {
|
||||
int err;
|
||||
snd_control_info_set_item(info, idx);
|
||||
err = snd_ctl_cinfo(handle, info);
|
||||
snd_ctl_element_info_set_item(info, idx);
|
||||
err = snd_ctl_element_info(handle, info);
|
||||
if (err < 0) {
|
||||
error("snd_ctl_info: %s", snd_strerror(err));
|
||||
error("snd_ctl_card_info: %s", snd_strerror(err));
|
||||
return err;
|
||||
}
|
||||
if (strcmp(str, snd_control_info_get_item_name(info)) == 0)
|
||||
if (strcmp(str, snd_ctl_element_info_get_item_name(info)) == 0)
|
||||
return idx;
|
||||
}
|
||||
return -1;
|
||||
|
@ -592,13 +592,13 @@ static int config_enumerated(snd_config_t *n, snd_ctl_t *handle,
|
|||
|
||||
static int set_control(snd_ctl_t *handle, snd_config_t *control)
|
||||
{
|
||||
snd_control_t *ctl;
|
||||
snd_control_info_t *info;
|
||||
snd_ctl_element_t *ctl;
|
||||
snd_ctl_element_info_t *info;
|
||||
snd_config_iterator_t i;
|
||||
unsigned int numid1, iface1, device1, subdevice1, index1;
|
||||
const char *name1;
|
||||
unsigned int numid;
|
||||
snd_control_type_t type;
|
||||
snd_ctl_element_type_t type;
|
||||
unsigned int count;
|
||||
long iface = -1;
|
||||
long device = -1;
|
||||
|
@ -610,8 +610,8 @@ static int set_control(snd_ctl_t *handle, snd_config_t *control)
|
|||
unsigned int idx;
|
||||
int err;
|
||||
char *set;
|
||||
snd_control_alloca(&ctl);
|
||||
snd_control_info_alloca(&info);
|
||||
snd_ctl_element_alloca(&ctl);
|
||||
snd_ctl_element_info_alloca(&info);
|
||||
if (snd_config_get_type(control) != SND_CONFIG_TYPE_COMPOUND) {
|
||||
error("control is not a compound");
|
||||
return -EINVAL;
|
||||
|
@ -679,31 +679,31 @@ static int set_control(snd_ctl_t *handle, snd_config_t *control)
|
|||
if (index < 0)
|
||||
index = 0;
|
||||
|
||||
snd_control_info_set_numid(info, numid);
|
||||
err = snd_ctl_cinfo(handle, info);
|
||||
snd_ctl_element_info_set_numid(info, numid);
|
||||
err = snd_ctl_element_info(handle, info);
|
||||
if (err < 0) {
|
||||
if (iface >= 0 && name) {
|
||||
snd_control_info_set_numid(info, 0);
|
||||
snd_control_info_set_interface(info, snd_int_to_enum(iface));
|
||||
snd_control_info_set_device(info, device);
|
||||
snd_control_info_set_subdevice(info, subdevice);
|
||||
snd_control_info_set_name(info, name);
|
||||
snd_control_info_set_index(info, index);
|
||||
err = snd_ctl_cinfo(handle, info);
|
||||
snd_ctl_element_info_set_numid(info, 0);
|
||||
snd_ctl_element_info_set_interface(info, snd_int_to_enum(iface));
|
||||
snd_ctl_element_info_set_device(info, device);
|
||||
snd_ctl_element_info_set_subdevice(info, subdevice);
|
||||
snd_ctl_element_info_set_name(info, name);
|
||||
snd_ctl_element_info_set_index(info, index);
|
||||
err = snd_ctl_element_info(handle, info);
|
||||
}
|
||||
}
|
||||
if (err < 0) {
|
||||
error("failed to obtain info for control #%d (%s)", numid, snd_strerror(err));
|
||||
return -ENOENT;
|
||||
}
|
||||
numid1 = snd_control_info_get_numid(info);
|
||||
iface1 = snd_enum_to_int(snd_control_info_get_interface(info));
|
||||
device1 = snd_control_info_get_device(info);
|
||||
subdevice1 = snd_control_info_get_subdevice(info);
|
||||
name1 = snd_control_info_get_name(info);
|
||||
index1 = snd_control_info_get_index(info);
|
||||
count = snd_control_info_get_count(info);
|
||||
type = snd_control_info_get_type(info);
|
||||
numid1 = snd_ctl_element_info_get_numid(info);
|
||||
iface1 = snd_enum_to_int(snd_ctl_element_info_get_interface(info));
|
||||
device1 = snd_ctl_element_info_get_device(info);
|
||||
subdevice1 = snd_ctl_element_info_get_subdevice(info);
|
||||
name1 = snd_ctl_element_info_get_name(info);
|
||||
index1 = snd_ctl_element_info_get_index(info);
|
||||
count = snd_ctl_element_info_get_count(info);
|
||||
type = snd_ctl_element_info_get_type(info);
|
||||
if (numid != numid1)
|
||||
error("warning: numid mismatch (%d/%d) for control #%d",
|
||||
numid, numid1, numid);
|
||||
|
@ -718,35 +718,35 @@ static int set_control(snd_ctl_t *handle, snd_config_t *control)
|
|||
if (index != index1)
|
||||
error("warning: index mismatch (%ld/%d) for control #%d", index, index1, numid);
|
||||
|
||||
if (!snd_control_info_is_writable(info))
|
||||
if (!snd_ctl_element_info_is_writable(info))
|
||||
return 0;
|
||||
snd_control_set_numid(ctl, numid);
|
||||
snd_ctl_element_set_numid(ctl, numid);
|
||||
|
||||
if (count == 1) {
|
||||
switch (snd_enum_to_int(type)) {
|
||||
case SND_CONTROL_TYPE_BOOLEAN:
|
||||
case SND_CTL_ELEMENT_TYPE_BOOLEAN:
|
||||
val = config_bool(value);
|
||||
if (val >= 0) {
|
||||
snd_control_set_boolean(ctl, 0, val);
|
||||
snd_ctl_element_set_boolean(ctl, 0, val);
|
||||
goto _ok;
|
||||
}
|
||||
break;
|
||||
case SND_CONTROL_TYPE_INTEGER:
|
||||
case SND_CTL_ELEMENT_TYPE_INTEGER:
|
||||
err = snd_config_get_integer(value, &val);
|
||||
if (err == 0) {
|
||||
snd_control_set_integer(ctl, 0, val);
|
||||
snd_ctl_element_set_integer(ctl, 0, val);
|
||||
goto _ok;
|
||||
}
|
||||
break;
|
||||
case SND_CONTROL_TYPE_ENUMERATED:
|
||||
case SND_CTL_ELEMENT_TYPE_ENUMERATED:
|
||||
val = config_enumerated(value, handle, info);
|
||||
if (val >= 0) {
|
||||
snd_control_set_enumerated(ctl, 0, val);
|
||||
snd_ctl_element_set_enumerated(ctl, 0, val);
|
||||
goto _ok;
|
||||
}
|
||||
break;
|
||||
case SND_CONTROL_TYPE_BYTES:
|
||||
case SND_CONTROL_TYPE_IEC958:
|
||||
case SND_CTL_ELEMENT_TYPE_BYTES:
|
||||
case SND_CTL_ELEMENT_TYPE_IEC958:
|
||||
break;
|
||||
default:
|
||||
error("Unknow control type: %d", snd_enum_to_int(type));
|
||||
|
@ -754,8 +754,8 @@ static int set_control(snd_ctl_t *handle, snd_config_t *control)
|
|||
}
|
||||
}
|
||||
switch (snd_enum_to_int(type)) {
|
||||
case SND_CONTROL_TYPE_BYTES:
|
||||
case SND_CONTROL_TYPE_IEC958:
|
||||
case SND_CTL_ELEMENT_TYPE_BYTES:
|
||||
case SND_CTL_ELEMENT_TYPE_IEC958:
|
||||
{
|
||||
const char *buf;
|
||||
err = snd_config_get_string(value, &buf);
|
||||
|
@ -763,7 +763,7 @@ static int set_control(snd_ctl_t *handle, snd_config_t *control)
|
|||
int c1 = 0;
|
||||
int len = strlen(buf);
|
||||
unsigned int idx = 0;
|
||||
int size = type == SND_CONTROL_TYPE_BYTES ?
|
||||
int size = type == SND_CTL_ELEMENT_TYPE_BYTES ?
|
||||
count : sizeof(snd_aes_iec958_t);
|
||||
if (size * 2 != len) {
|
||||
error("bad control.%d.value contents\n", numid);
|
||||
|
@ -783,7 +783,7 @@ static int set_control(snd_ctl_t *handle, snd_config_t *control)
|
|||
}
|
||||
idx++;
|
||||
if (idx % 2 == 0)
|
||||
snd_control_set_byte(ctl, idx / 2, c1 << 4 | c);
|
||||
snd_ctl_element_set_byte(ctl, idx / 2, c1 << 4 | c);
|
||||
else
|
||||
c1 = c;
|
||||
}
|
||||
|
@ -809,38 +809,38 @@ static int set_control(snd_ctl_t *handle, snd_config_t *control)
|
|||
return -EINVAL;
|
||||
}
|
||||
switch (snd_enum_to_int(type)) {
|
||||
case SND_CONTROL_TYPE_BOOLEAN:
|
||||
case SND_CTL_ELEMENT_TYPE_BOOLEAN:
|
||||
val = config_bool(n);
|
||||
if (val < 0) {
|
||||
error("bad control.%d.value.%d content", numid, idx);
|
||||
return -EINVAL;
|
||||
}
|
||||
snd_control_set_boolean(ctl, idx, val);
|
||||
snd_ctl_element_set_boolean(ctl, idx, val);
|
||||
break;
|
||||
case SND_CONTROL_TYPE_INTEGER:
|
||||
case SND_CTL_ELEMENT_TYPE_INTEGER:
|
||||
err = snd_config_get_integer(n, &val);
|
||||
if (err < 0) {
|
||||
error("bad control.%d.value.%d content", numid, idx);
|
||||
return -EINVAL;
|
||||
}
|
||||
snd_control_set_integer(ctl, idx, val);
|
||||
snd_ctl_element_set_integer(ctl, idx, val);
|
||||
break;
|
||||
case SND_CONTROL_TYPE_ENUMERATED:
|
||||
case SND_CTL_ELEMENT_TYPE_ENUMERATED:
|
||||
val = config_enumerated(n, handle, info);
|
||||
if (val < 0) {
|
||||
error("bad control.%d.value.%d content", numid, idx);
|
||||
return -EINVAL;
|
||||
}
|
||||
snd_control_set_enumerated(ctl, idx, val);
|
||||
snd_ctl_element_set_enumerated(ctl, idx, val);
|
||||
break;
|
||||
case SND_CONTROL_TYPE_BYTES:
|
||||
case SND_CONTROL_TYPE_IEC958:
|
||||
case SND_CTL_ELEMENT_TYPE_BYTES:
|
||||
case SND_CTL_ELEMENT_TYPE_IEC958:
|
||||
err = snd_config_get_integer(n, &val);
|
||||
if (err < 0 || val < 0 || val > 255) {
|
||||
error("bad control.%d.value.%d content", numid, idx);
|
||||
return -EINVAL;
|
||||
}
|
||||
snd_control_set_byte(ctl, idx, val);
|
||||
snd_ctl_element_set_byte(ctl, idx, val);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -855,11 +855,11 @@ static int set_control(snd_ctl_t *handle, snd_config_t *control)
|
|||
}
|
||||
|
||||
_ok:
|
||||
err = snd_ctl_cwrite(handle, ctl);
|
||||
err = snd_ctl_element_write(handle, ctl);
|
||||
if (err < 0) {
|
||||
snd_control_id_t *id;
|
||||
snd_control_id_alloca(&id);
|
||||
snd_control_get_id(ctl, id);
|
||||
snd_ctl_element_id_t *id;
|
||||
snd_ctl_element_id_alloca(&id);
|
||||
snd_ctl_element_get_id(ctl, id);
|
||||
error("Cannot write control '%s': %s", id_str(id), snd_strerror(err));
|
||||
return err;
|
||||
}
|
||||
|
@ -869,13 +869,13 @@ static int set_control(snd_ctl_t *handle, snd_config_t *control)
|
|||
static int set_controls(int card, snd_config_t *top)
|
||||
{
|
||||
snd_ctl_t *handle;
|
||||
snd_ctl_info_t *info;
|
||||
snd_ctl_card_info_t *info;
|
||||
snd_config_t *control;
|
||||
snd_config_iterator_t i;
|
||||
int err;
|
||||
char name[32];
|
||||
const char *id;
|
||||
snd_ctl_info_alloca(&info);
|
||||
snd_ctl_card_info_alloca(&info);
|
||||
|
||||
sprintf(name, "hw:%d", card);
|
||||
err = snd_ctl_open(&handle, name);
|
||||
|
@ -883,12 +883,12 @@ static int set_controls(int card, snd_config_t *top)
|
|||
error("snd_ctl_open error: %s", snd_strerror(err));
|
||||
return err;
|
||||
}
|
||||
err = snd_ctl_info(handle, info);
|
||||
err = snd_ctl_card_info(handle, info);
|
||||
if (err < 0) {
|
||||
error("snd_ctl_info error: %s", snd_strerror(err));
|
||||
error("snd_ctl_card_info error: %s", snd_strerror(err));
|
||||
goto _close;
|
||||
}
|
||||
id = snd_ctl_info_get_id(info);
|
||||
id = snd_ctl_card_info_get_id(info);
|
||||
err = snd_config_searchv(top, &control, "state", id, "control", 0);
|
||||
if (err < 0) {
|
||||
err = 0;
|
||||
|
|
|
@ -469,7 +469,7 @@ mixer_conv(int val, int omin, int omax, int nmin, int nmax)
|
|||
}
|
||||
|
||||
static int
|
||||
mixer_calc_volume(snd_mixer_simple_control_t *scontrol, int vol, snd_mixer_channel_id_t chn)
|
||||
mixer_calc_volume(snd_mixer_simple_element_t *scontrol, int vol, snd_mixer_channel_id_t chn)
|
||||
{
|
||||
int vol1;
|
||||
vol1 = (vol < 0) ? -vol : vol;
|
||||
|
@ -492,7 +492,7 @@ mixer_calc_volume(snd_mixer_simple_control_t *scontrol, int vol, snd_mixer_chann
|
|||
static void
|
||||
mixer_write_cbar (int elem_index)
|
||||
{
|
||||
snd_mixer_simple_control_t scontrol;
|
||||
snd_mixer_simple_element_t scontrol;
|
||||
int vleft, vright, vbalance;
|
||||
int type;
|
||||
snd_mixer_channel_id_t chn_left, chn_right, chn;
|
||||
|
@ -502,8 +502,8 @@ mixer_write_cbar (int elem_index)
|
|||
if (mixer_sid == NULL)
|
||||
return;
|
||||
scontrol.sid = mixer_sid[mixer_grpidx[elem_index]];
|
||||
if ((err = snd_mixer_simple_control_read (mixer_handle, &scontrol)) < 0)
|
||||
CHECK_ABORT (ERR_FCN, "snd_mixer_simple_control_read()", err);
|
||||
if ((err = snd_mixer_simple_element_read (mixer_handle, &scontrol)) < 0)
|
||||
CHECK_ABORT (ERR_FCN, "snd_mixer_simple_element_read()", err);
|
||||
|
||||
type = mixer_type[elem_index];
|
||||
chn_left = mixer_elem_chn[type][MIXER_CHN_LEFT];
|
||||
|
@ -587,8 +587,8 @@ mixer_write_cbar (int elem_index)
|
|||
mixer_toggle_capture = 0;
|
||||
|
||||
if (changed) {
|
||||
if ((err = snd_mixer_simple_control_write (mixer_handle, &scontrol)) < 0)
|
||||
CHECK_ABORT (ERR_FCN, "snd_mixer_simple_control_write()", err);
|
||||
if ((err = snd_mixer_simple_element_write (mixer_handle, &scontrol)) < 0)
|
||||
CHECK_ABORT (ERR_FCN, "snd_mixer_simple_element_write()", err);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -598,7 +598,7 @@ mixer_update_cbar (int elem_index)
|
|||
{
|
||||
char string[128], string1[64];
|
||||
int err, dc;
|
||||
snd_mixer_simple_control_t scontrol;
|
||||
snd_mixer_simple_element_t scontrol;
|
||||
int vleft, vright;
|
||||
int type;
|
||||
snd_mixer_channel_id_t chn_left, chn_right;
|
||||
|
@ -611,8 +611,8 @@ mixer_update_cbar (int elem_index)
|
|||
if (mixer_sid == NULL)
|
||||
return;
|
||||
scontrol.sid = mixer_sid[mixer_grpidx[elem_index]];
|
||||
if ((err = snd_mixer_simple_control_read (mixer_handle, &scontrol)) < 0)
|
||||
CHECK_ABORT (ERR_FCN, "snd_mixer_simple_control_read()", err);
|
||||
if ((err = snd_mixer_simple_element_read (mixer_handle, &scontrol)) < 0)
|
||||
CHECK_ABORT (ERR_FCN, "snd_mixer_simple_element_read()", err);
|
||||
|
||||
type = mixer_type[elem_index];
|
||||
chn_left = mixer_elem_chn[type][MIXER_CHN_LEFT];
|
||||
|
@ -627,8 +627,8 @@ mixer_update_cbar (int elem_index)
|
|||
|
||||
/* first, read values for the numbers to be displayed
|
||||
*/
|
||||
if ((err = snd_mixer_simple_control_read (mixer_handle, &scontrol)) < 0)
|
||||
CHECK_ABORT (ERR_FCN, "snd_mixer_simple_control_read()", err);
|
||||
if ((err = snd_mixer_simple_element_read (mixer_handle, &scontrol)) < 0)
|
||||
CHECK_ABORT (ERR_FCN, "snd_mixer_simple_element_read()", err);
|
||||
|
||||
vleft = scontrol.volume.values[c_left];
|
||||
vleft = mixer_conv(vleft, scontrol.min, scontrol.max, 0, 100);
|
||||
|
@ -1213,15 +1213,15 @@ mixer_show_procinfo (void)
|
|||
static void
|
||||
mixer_init (void)
|
||||
{
|
||||
snd_ctl_info_t *hw_info;
|
||||
snd_ctl_card_info_t *hw_info;
|
||||
snd_ctl_t *ctl_handle;
|
||||
int err;
|
||||
snd_ctl_info_alloca(&hw_info);
|
||||
snd_ctl_card_info_alloca(&hw_info);
|
||||
|
||||
if ((err = snd_ctl_open (&ctl_handle, card_id)) < 0)
|
||||
mixer_abort (ERR_OPEN, "snd_ctl_open", err);
|
||||
if ((err = snd_ctl_info (ctl_handle, hw_info)) < 0)
|
||||
mixer_abort (ERR_FCN, "snd_ctl_info", err);
|
||||
if ((err = snd_ctl_card_info (ctl_handle, hw_info)) < 0)
|
||||
mixer_abort (ERR_FCN, "snd_ctl_card_info", err);
|
||||
snd_ctl_close (ctl_handle);
|
||||
/* open mixer device
|
||||
*/
|
||||
|
@ -1230,14 +1230,14 @@ mixer_init (void)
|
|||
|
||||
/* setup global variables
|
||||
*/
|
||||
strcpy(mixer_card_name, snd_ctl_info_get_name(hw_info));
|
||||
strcpy(mixer_device_name, snd_ctl_info_get_mixername(hw_info));
|
||||
strcpy(mixer_card_name, snd_ctl_card_info_get_name(hw_info));
|
||||
strcpy(mixer_device_name, snd_ctl_card_info_get_mixername(hw_info));
|
||||
}
|
||||
|
||||
static void
|
||||
mixer_reinit (void)
|
||||
{
|
||||
snd_mixer_simple_control_list_t scontrols;
|
||||
snd_mixer_simple_element_list_t scontrols;
|
||||
int idx, err, elem_index, i;
|
||||
snd_mixer_sid_t focus_gid;
|
||||
int focus_type = -1;
|
||||
|
@ -1248,8 +1248,8 @@ mixer_reinit (void)
|
|||
}
|
||||
while (1) {
|
||||
bzero(&scontrols, sizeof(scontrols));
|
||||
if ((err = snd_mixer_simple_control_list(mixer_handle, &scontrols)) < 0)
|
||||
mixer_abort (ERR_FCN, "snd_mixer_simple_control_list", err);
|
||||
if ((err = snd_mixer_simple_element_list(mixer_handle, &scontrols)) < 0)
|
||||
mixer_abort (ERR_FCN, "snd_mixer_simple_element_list", err);
|
||||
mixer_n_scontrols = scontrols.controls;
|
||||
if (mixer_n_scontrols > 0) {
|
||||
scontrols.controls_request = mixer_n_scontrols;
|
||||
|
@ -1258,8 +1258,8 @@ mixer_reinit (void)
|
|||
mixer_abort (ERR_FCN, "malloc", 0);
|
||||
scontrols.controls_offset = 0;
|
||||
scontrols.controls_count = 0;
|
||||
if ((err = snd_mixer_simple_control_list(mixer_handle, &scontrols)) < 0)
|
||||
mixer_abort (ERR_FCN, "snd_mixer_simple_control_list", err);
|
||||
if ((err = snd_mixer_simple_element_list(mixer_handle, &scontrols)) < 0)
|
||||
mixer_abort (ERR_FCN, "snd_mixer_simple_element_list", err);
|
||||
if (scontrols.controls > scontrols.controls_count) {
|
||||
free(scontrols.pids);
|
||||
continue;
|
||||
|
@ -1276,11 +1276,11 @@ mixer_reinit (void)
|
|||
|
||||
mixer_n_elems = 0;
|
||||
for (idx = 0; idx < mixer_n_scontrols; idx++) {
|
||||
snd_mixer_simple_control_t scontrol;
|
||||
snd_mixer_simple_element_t scontrol;
|
||||
bzero(&scontrol, sizeof(scontrol));
|
||||
scontrol.sid = mixer_sid[idx];
|
||||
if ((err = snd_mixer_simple_control_read(mixer_handle, &scontrol)) < 0)
|
||||
CHECK_ABORT (ERR_FCN, "snd_mixer_simple_control_read()", 0);
|
||||
if ((err = snd_mixer_simple_element_read(mixer_handle, &scontrol)) < 0)
|
||||
CHECK_ABORT (ERR_FCN, "snd_mixer_simple_element_read()", 0);
|
||||
for (i = 0; i < MIXER_ELEM_END; i++) {
|
||||
if (scontrol.channels & mixer_elem_mask[i])
|
||||
mixer_n_elems++;
|
||||
|
@ -1299,11 +1299,11 @@ mixer_reinit (void)
|
|||
mixer_abort(ERR_FCN, "malloc", 0);
|
||||
elem_index = 0;
|
||||
for (idx = 0; idx < mixer_n_scontrols; idx++) {
|
||||
snd_mixer_simple_control_t scontrol;
|
||||
snd_mixer_simple_element_t scontrol;
|
||||
bzero(&scontrol, sizeof(scontrol));
|
||||
scontrol.sid = mixer_sid[idx];
|
||||
if ((err = snd_mixer_simple_control_read(mixer_handle, &scontrol)) < 0)
|
||||
CHECK_ABORT (ERR_FCN, "snd_mixer_simple_control_read()", err);
|
||||
if ((err = snd_mixer_simple_element_read(mixer_handle, &scontrol)) < 0)
|
||||
CHECK_ABORT (ERR_FCN, "snd_mixer_simple_element_read()", err);
|
||||
for (i = 0; i < MIXER_ELEM_END; i++) {
|
||||
if (scontrol.channels & mixer_elem_mask[i]) {
|
||||
mixer_grpidx[elem_index] = idx;
|
||||
|
|
294
amixer/amixer.c
294
amixer/amixer.c
|
@ -77,36 +77,36 @@ static int info(void)
|
|||
int err;
|
||||
snd_ctl_t *handle;
|
||||
snd_mixer_t *mhandle;
|
||||
snd_ctl_info_t *info;
|
||||
snd_control_list_t *clist;
|
||||
snd_mixer_simple_control_list_t slist;
|
||||
snd_ctl_info_alloca(&info);
|
||||
snd_control_list_alloca(&clist);
|
||||
snd_ctl_card_info_t *info;
|
||||
snd_ctl_element_list_t *clist;
|
||||
snd_mixer_simple_element_list_t slist;
|
||||
snd_ctl_card_info_alloca(&info);
|
||||
snd_ctl_element_list_alloca(&clist);
|
||||
|
||||
if ((err = snd_ctl_open(&handle, card)) < 0) {
|
||||
error("Control device %i open error: %s", card, snd_strerror(err));
|
||||
return err;
|
||||
}
|
||||
if ((err = snd_ctl_info(handle, info)) < 0) {
|
||||
if ((err = snd_ctl_card_info(handle, info)) < 0) {
|
||||
error("Control device %i hw info error: %s", card, snd_strerror(err));
|
||||
return err;
|
||||
}
|
||||
printf("Card %s '%s'/'%s'\n", card, snd_ctl_info_get_id(info),
|
||||
snd_ctl_info_get_longname(info));
|
||||
printf(" Mixer ID : '%s'\n", snd_ctl_info_get_mixerid(info));
|
||||
printf(" Mixer name : '%s'\n", snd_ctl_info_get_mixername(info));
|
||||
printf("Card %s '%s'/'%s'\n", card, snd_ctl_card_info_get_id(info),
|
||||
snd_ctl_card_info_get_longname(info));
|
||||
printf(" Mixer ID : '%s'\n", snd_ctl_card_info_get_mixerid(info));
|
||||
printf(" Mixer name : '%s'\n", snd_ctl_card_info_get_mixername(info));
|
||||
if ((err = snd_ctl_clist(handle, clist)) < 0) {
|
||||
error("snd_ctl_clist failure: %s", snd_strerror(err));
|
||||
} else {
|
||||
printf(" Controls : %i\n", snd_control_list_get_count(clist));
|
||||
printf(" Controls : %i\n", snd_ctl_element_list_get_count(clist));
|
||||
}
|
||||
snd_ctl_close(handle);
|
||||
if ((err = snd_mixer_open(&mhandle, card)) < 0) {
|
||||
error("Mixer %s open error: %s", card, snd_strerror(err));
|
||||
return err;
|
||||
}
|
||||
if ((err = snd_mixer_simple_control_list(mhandle, &slist)) < 0) {
|
||||
error("snd_mixer_simple_control_list failure: %s\n", snd_strerror(err));
|
||||
if ((err = snd_mixer_simple_element_list(mhandle, &slist)) < 0) {
|
||||
error("snd_mixer_simple_element_list failure: %s\n", snd_strerror(err));
|
||||
} else {
|
||||
printf(" Simple ctrls : %i\n", slist.controls);
|
||||
}
|
||||
|
@ -114,26 +114,26 @@ static int info(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static const char *control_iface(snd_control_id_t *id)
|
||||
static const char *control_iface(snd_ctl_element_id_t *id)
|
||||
{
|
||||
return snd_control_iface_name(snd_control_id_get_interface(id));
|
||||
return snd_ctl_element_iface_name(snd_ctl_element_id_get_interface(id));
|
||||
}
|
||||
|
||||
static const char *control_type(snd_control_info_t *info)
|
||||
static const char *control_type(snd_ctl_element_info_t *info)
|
||||
{
|
||||
return snd_control_type_name(snd_control_info_get_type(info));
|
||||
return snd_ctl_element_type_name(snd_ctl_element_info_get_type(info));
|
||||
}
|
||||
|
||||
static const char *control_access(snd_control_info_t *info)
|
||||
static const char *control_access(snd_ctl_element_info_t *info)
|
||||
{
|
||||
static char result[10];
|
||||
char *res = result;
|
||||
|
||||
*res++ = snd_control_info_is_readable(info) ? 'r' : '-';
|
||||
*res++ = snd_control_info_is_writable(info) ? 'w' : '-';
|
||||
*res++ = snd_control_info_is_inactive(info) ? 'i' : '-';
|
||||
*res++ = snd_control_info_is_volatile(info) ? 'v' : '-';
|
||||
*res++ = snd_control_info_is_locked(info) ? 'l' : '-';
|
||||
*res++ = snd_ctl_element_info_is_readable(info) ? 'r' : '-';
|
||||
*res++ = snd_ctl_element_info_is_writable(info) ? 'w' : '-';
|
||||
*res++ = snd_ctl_element_info_is_inactive(info) ? 'i' : '-';
|
||||
*res++ = snd_ctl_element_info_is_volatile(info) ? 'v' : '-';
|
||||
*res++ = snd_ctl_element_info_is_locked(info) ? 'l' : '-';
|
||||
*res++ = '\0';
|
||||
return result;
|
||||
}
|
||||
|
@ -293,16 +293,16 @@ static int get_volume_simple(char **ptr, int min, int max, int orig)
|
|||
return tmp1;
|
||||
}
|
||||
|
||||
static void show_control_id(snd_control_id_t *id)
|
||||
static void show_control_id(snd_ctl_element_id_t *id)
|
||||
{
|
||||
unsigned int index, device, subdevice;
|
||||
printf("numid=%u,iface=%s,name='%s'",
|
||||
snd_control_id_get_numid(id),
|
||||
snd_ctl_element_id_get_numid(id),
|
||||
control_iface(id),
|
||||
snd_control_id_get_name(id));
|
||||
index = snd_control_id_get_index(id);
|
||||
device = snd_control_id_get_device(id);
|
||||
subdevice = snd_control_id_get_subdevice(id);
|
||||
snd_ctl_element_id_get_name(id));
|
||||
index = snd_ctl_element_id_get_index(id);
|
||||
device = snd_ctl_element_id_get_device(id);
|
||||
subdevice = snd_ctl_element_id_get_subdevice(id);
|
||||
if (index)
|
||||
printf(",index=%i", index);
|
||||
if (device)
|
||||
|
@ -311,47 +311,47 @@ static void show_control_id(snd_control_id_t *id)
|
|||
printf(",subdevice=%i", subdevice);
|
||||
}
|
||||
|
||||
static int show_control(const char *space, snd_ctl_t *handle, snd_control_id_t *id, int level)
|
||||
static int show_control(const char *space, snd_ctl_t *handle, snd_ctl_element_id_t *id, int level)
|
||||
{
|
||||
int err;
|
||||
unsigned int item, idx;
|
||||
snd_control_info_t *info;
|
||||
snd_control_t *control;
|
||||
snd_ctl_element_info_t *info;
|
||||
snd_ctl_element_t *control;
|
||||
unsigned int count;
|
||||
snd_control_type_t type;
|
||||
snd_control_info_alloca(&info);
|
||||
snd_control_alloca(&control);
|
||||
snd_control_info_set_id(info, id);
|
||||
if ((err = snd_ctl_cinfo(handle, info)) < 0) {
|
||||
snd_ctl_element_type_t type;
|
||||
snd_ctl_element_info_alloca(&info);
|
||||
snd_ctl_element_alloca(&control);
|
||||
snd_ctl_element_info_set_id(info, id);
|
||||
if ((err = snd_ctl_element_info(handle, info)) < 0) {
|
||||
error("Control %s cinfo error: %s\n", card, snd_strerror(err));
|
||||
return err;
|
||||
}
|
||||
if (level & 2) {
|
||||
snd_control_info_get_id(info, id);
|
||||
snd_ctl_element_info_get_id(info, id);
|
||||
show_control_id(id);
|
||||
printf("\n");
|
||||
}
|
||||
count = snd_control_info_get_count(info);
|
||||
type = snd_control_info_get_type(info);
|
||||
count = snd_ctl_element_info_get_count(info);
|
||||
type = snd_ctl_element_info_get_type(info);
|
||||
printf("%s; type=%s,access=%s,values=%i", space, control_type(info), control_access(info), count);
|
||||
switch (snd_enum_to_int(type)) {
|
||||
case SND_CONTROL_TYPE_INTEGER:
|
||||
case SND_CTL_ELEMENT_TYPE_INTEGER:
|
||||
printf(",min=%li,max=%li,step=%li\n",
|
||||
snd_control_info_get_min(info),
|
||||
snd_control_info_get_max(info),
|
||||
snd_control_info_get_step(info));
|
||||
snd_ctl_element_info_get_min(info),
|
||||
snd_ctl_element_info_get_max(info),
|
||||
snd_ctl_element_info_get_step(info));
|
||||
break;
|
||||
case SND_CONTROL_TYPE_ENUMERATED:
|
||||
case SND_CTL_ELEMENT_TYPE_ENUMERATED:
|
||||
{
|
||||
unsigned int items = snd_control_info_get_items(info);
|
||||
unsigned int items = snd_ctl_element_info_get_items(info);
|
||||
printf(",items=%u\n", items);
|
||||
for (item = 0; item < items; item++) {
|
||||
snd_control_info_set_item(info, item);
|
||||
if ((err = snd_ctl_cinfo(handle, info)) < 0) {
|
||||
snd_ctl_element_info_set_item(info, item);
|
||||
if ((err = snd_ctl_element_info(handle, info)) < 0) {
|
||||
error("Control %s cinfo error: %s\n", card, snd_strerror(err));
|
||||
return err;
|
||||
}
|
||||
printf("%s; Item #%u '%s'\n", space, item, snd_control_info_get_item_name(info));
|
||||
printf("%s; Item #%u '%s'\n", space, item, snd_ctl_element_info_get_item_name(info));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -360,8 +360,8 @@ static int show_control(const char *space, snd_ctl_t *handle, snd_control_id_t *
|
|||
break;
|
||||
}
|
||||
if (level & 1) {
|
||||
snd_control_set_id(control, id);
|
||||
if ((err = snd_ctl_cread(handle, control)) < 0) {
|
||||
snd_ctl_element_set_id(control, id);
|
||||
if ((err = snd_ctl_element_read(handle, control)) < 0) {
|
||||
error("Control %s cread error: %s\n", card, snd_strerror(err));
|
||||
return err;
|
||||
}
|
||||
|
@ -370,17 +370,17 @@ static int show_control(const char *space, snd_ctl_t *handle, snd_control_id_t *
|
|||
if (idx > 0)
|
||||
printf(",");
|
||||
switch (snd_enum_to_int(type)) {
|
||||
case SND_CONTROL_TYPE_BOOLEAN:
|
||||
printf("%s", snd_control_get_boolean(control, idx) ? "on" : "off");
|
||||
case SND_CTL_ELEMENT_TYPE_BOOLEAN:
|
||||
printf("%s", snd_ctl_element_get_boolean(control, idx) ? "on" : "off");
|
||||
break;
|
||||
case SND_CONTROL_TYPE_INTEGER:
|
||||
printf("%li", snd_control_get_integer(control, idx));
|
||||
case SND_CTL_ELEMENT_TYPE_INTEGER:
|
||||
printf("%li", snd_ctl_element_get_integer(control, idx));
|
||||
break;
|
||||
case SND_CONTROL_TYPE_ENUMERATED:
|
||||
printf("%u", snd_control_get_enumerated(control, idx));
|
||||
case SND_CTL_ELEMENT_TYPE_ENUMERATED:
|
||||
printf("%u", snd_ctl_element_get_enumerated(control, idx));
|
||||
break;
|
||||
case SND_CONTROL_TYPE_BYTES:
|
||||
printf("0x%02x", snd_control_get_byte(control, idx));
|
||||
case SND_CTL_ELEMENT_TYPE_BYTES:
|
||||
printf("0x%02x", snd_ctl_element_get_byte(control, idx));
|
||||
break;
|
||||
default:
|
||||
printf("?");
|
||||
|
@ -398,10 +398,10 @@ static int controls(int level)
|
|||
unsigned int idx;
|
||||
snd_ctl_t *handle;
|
||||
unsigned int count;
|
||||
snd_hcontrol_list_t *list;
|
||||
snd_control_id_t *id;
|
||||
snd_hcontrol_list_alloca(&list);
|
||||
snd_control_id_alloca(&id);
|
||||
snd_hctl_element_list_t *list;
|
||||
snd_ctl_element_id_t *id;
|
||||
snd_hctl_element_list_alloca(&list);
|
||||
snd_ctl_element_id_alloca(&id);
|
||||
|
||||
if ((err = snd_ctl_open(&handle, card)) < 0) {
|
||||
error("Control %s open error: %s", card, snd_strerror(err));
|
||||
|
@ -415,9 +415,9 @@ static int controls(int level)
|
|||
error("Control %s clist error: %s", card, snd_strerror(err));
|
||||
return err;
|
||||
}
|
||||
count = snd_hcontrol_list_get_count(list);
|
||||
snd_hcontrol_list_set_offset(list, 0);
|
||||
if (snd_hcontrol_list_alloc_space(list, count) < 0) {
|
||||
count = snd_hctl_element_list_get_count(list);
|
||||
snd_hctl_element_list_set_offset(list, 0);
|
||||
if (snd_hctl_element_list_alloc_space(list, count) < 0) {
|
||||
error("Not enough memory");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
@ -426,27 +426,27 @@ static int controls(int level)
|
|||
return err;
|
||||
}
|
||||
for (idx = 0; idx < count; idx++) {
|
||||
snd_hcontrol_list_get_id(list, idx, id);
|
||||
snd_hctl_element_list_get_id(list, idx, id);
|
||||
show_control_id(id);
|
||||
printf("\n");
|
||||
if (level > 0)
|
||||
show_control(" ", handle, id, 1);
|
||||
}
|
||||
snd_hcontrol_list_free_space(list);
|
||||
snd_hctl_element_list_free_space(list);
|
||||
snd_ctl_close(handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int show_simple_control(void *handle, snd_mixer_sid_t *sid, const char *space, int level)
|
||||
static int show_simple_element(void *handle, snd_mixer_sid_t *sid, const char *space, int level)
|
||||
{
|
||||
int err;
|
||||
snd_mixer_channel_id_t chn;
|
||||
snd_mixer_simple_control_t scontrol;
|
||||
snd_mixer_simple_element_t scontrol;
|
||||
|
||||
bzero(&scontrol, sizeof(scontrol));
|
||||
scontrol.sid = *sid;
|
||||
if ((err = snd_mixer_simple_control_read(handle, &scontrol)) < 0) {
|
||||
error("Mixer %s simple_control error: %s", card, snd_strerror(err));
|
||||
if ((err = snd_mixer_simple_element_read(handle, &scontrol)) < 0) {
|
||||
error("Mixer %s simple_element error: %s", card, snd_strerror(err));
|
||||
return err;
|
||||
}
|
||||
if ((level & 1) != 0 && scontrol.channels) {
|
||||
|
@ -501,12 +501,12 @@ static int show_simple_control(void *handle, snd_mixer_sid_t *sid, const char *s
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int simple_controls(int level)
|
||||
static int simple_elements(int level)
|
||||
{
|
||||
int err;
|
||||
unsigned int idx;
|
||||
snd_mixer_t *handle;
|
||||
snd_mixer_simple_control_list_t list;
|
||||
snd_mixer_simple_element_list_t list;
|
||||
snd_mixer_sid_t *sid;
|
||||
char name[simple_name_size];
|
||||
|
||||
|
@ -515,8 +515,8 @@ static int simple_controls(int level)
|
|||
return err;
|
||||
}
|
||||
memset(&list, 0, sizeof(list));
|
||||
if ((err = snd_mixer_simple_control_list(handle, &list)) < 0) {
|
||||
error("Mixer %s simple_control_list error: %s", card, snd_strerror(err));
|
||||
if ((err = snd_mixer_simple_element_list(handle, &list)) < 0) {
|
||||
error("Mixer %s simple_element_list error: %s", card, snd_strerror(err));
|
||||
return err;
|
||||
}
|
||||
list.pids = (snd_mixer_sid_t *)malloc(list.controls * sizeof(snd_mixer_sid_t));
|
||||
|
@ -525,21 +525,21 @@ static int simple_controls(int level)
|
|||
return -ENOMEM;
|
||||
}
|
||||
list.controls_request = list.controls;
|
||||
if ((err = snd_mixer_simple_control_list(handle, &list)) < 0) {
|
||||
error("Mixer %s simple_control_list (2) error: %s", card, snd_strerror(err));
|
||||
if ((err = snd_mixer_simple_element_list(handle, &list)) < 0) {
|
||||
error("Mixer %s simple_element_list (2) error: %s", card, snd_strerror(err));
|
||||
return err;
|
||||
}
|
||||
for (idx = 0; idx < list.controls_count; idx++) {
|
||||
sid = &list.pids[idx];
|
||||
printf("Simple mixer control '%s',%i\n", simple_name(sid->name, name), sid->index);
|
||||
show_simple_control(handle, sid, " ", level);
|
||||
show_simple_element(handle, sid, " ", level);
|
||||
}
|
||||
free(list.pids);
|
||||
snd_mixer_close(handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int parse_control_id(const char *str, snd_control_id_t *id)
|
||||
static int parse_control_id(const char *str, snd_ctl_element_id_t *id)
|
||||
{
|
||||
int c, size;
|
||||
char *ptr;
|
||||
|
@ -548,32 +548,32 @@ static int parse_control_id(const char *str, snd_control_id_t *id)
|
|||
str++;
|
||||
if (!(*str))
|
||||
return -EINVAL;
|
||||
snd_control_id_set_interface(id, SND_CONTROL_IFACE_MIXER); /* default */
|
||||
snd_ctl_element_id_set_interface(id, SND_CTL_ELEMENT_IFACE_MIXER); /* default */
|
||||
while (*str) {
|
||||
if (!strncasecmp(str, "numid=", 6)) {
|
||||
str += 6;
|
||||
snd_control_id_set_numid(id, atoi(str));
|
||||
snd_ctl_element_id_set_numid(id, atoi(str));
|
||||
while (isdigit(*str))
|
||||
str++;
|
||||
} else if (!strncasecmp(str, "iface=", 6)) {
|
||||
str += 6;
|
||||
if (!strncasecmp(str, "card", 4)) {
|
||||
snd_control_id_set_interface(id, SND_CONTROL_IFACE_CARD);
|
||||
snd_ctl_element_id_set_interface(id, SND_CTL_ELEMENT_IFACE_CARD);
|
||||
str += 4;
|
||||
} else if (!strncasecmp(str, "mixer", 5)) {
|
||||
snd_control_id_set_interface(id, SND_CONTROL_IFACE_MIXER);
|
||||
snd_ctl_element_id_set_interface(id, SND_CTL_ELEMENT_IFACE_MIXER);
|
||||
str += 5;
|
||||
} else if (!strncasecmp(str, "pcm", 3)) {
|
||||
snd_control_id_set_interface(id, SND_CONTROL_IFACE_PCM);
|
||||
snd_ctl_element_id_set_interface(id, SND_CTL_ELEMENT_IFACE_PCM);
|
||||
str += 3;
|
||||
} else if (!strncasecmp(str, "rawmidi", 7)) {
|
||||
snd_control_id_set_interface(id, SND_CONTROL_IFACE_RAWMIDI);
|
||||
snd_ctl_element_id_set_interface(id, SND_CTL_ELEMENT_IFACE_RAWMIDI);
|
||||
str += 7;
|
||||
} else if (!strncasecmp(str, "timer", 5)) {
|
||||
snd_control_id_set_interface(id, SND_CONTROL_IFACE_TIMER);
|
||||
snd_ctl_element_id_set_interface(id, SND_CTL_ELEMENT_IFACE_TIMER);
|
||||
str += 5;
|
||||
} else if (!strncasecmp(str, "sequencer", 9)) {
|
||||
snd_control_id_set_interface(id, SND_CONTROL_IFACE_SEQUENCER);
|
||||
snd_ctl_element_id_set_interface(id, SND_CTL_ELEMENT_IFACE_SEQUENCER);
|
||||
str += 9;
|
||||
} else {
|
||||
return -EINVAL;
|
||||
|
@ -604,20 +604,20 @@ static int parse_control_id(const char *str, snd_control_id_t *id)
|
|||
}
|
||||
*ptr = '\0';
|
||||
}
|
||||
snd_control_id_set_name(id, buf);
|
||||
snd_ctl_element_id_set_name(id, buf);
|
||||
} else if (!strncasecmp(str, "index=", 6)) {
|
||||
str += 6;
|
||||
snd_control_id_set_index(id, atoi(str));
|
||||
snd_ctl_element_id_set_index(id, atoi(str));
|
||||
while (isdigit(*str))
|
||||
str++;
|
||||
} else if (!strncasecmp(str, "device=", 7)) {
|
||||
str += 7;
|
||||
snd_control_id_set_device(id, atoi(str));
|
||||
snd_ctl_element_id_set_device(id, atoi(str));
|
||||
while (isdigit(*str))
|
||||
str++;
|
||||
} else if (!strncasecmp(str, "subdevice=", 10)) {
|
||||
str += 10;
|
||||
snd_control_id_set_subdevice(id, atoi(str));
|
||||
snd_ctl_element_id_set_subdevice(id, atoi(str));
|
||||
while (isdigit(*str))
|
||||
str++;
|
||||
}
|
||||
|
@ -678,16 +678,16 @@ static int cset(int argc, char *argv[], int roflag)
|
|||
{
|
||||
int err;
|
||||
snd_ctl_t *handle;
|
||||
snd_control_info_t *info;
|
||||
snd_control_id_t *id;
|
||||
snd_control_t *control;
|
||||
snd_ctl_element_info_t *info;
|
||||
snd_ctl_element_id_t *id;
|
||||
snd_ctl_element_t *control;
|
||||
char *ptr;
|
||||
unsigned int idx, count;
|
||||
long tmp;
|
||||
snd_control_type_t type;
|
||||
snd_control_info_alloca(&info);
|
||||
snd_control_id_alloca(&id);
|
||||
snd_control_alloca(&control);
|
||||
snd_ctl_element_type_t type;
|
||||
snd_ctl_element_info_alloca(&info);
|
||||
snd_ctl_element_id_alloca(&id);
|
||||
snd_ctl_element_alloca(&control);
|
||||
|
||||
if (argc < 1) {
|
||||
fprintf(stderr, "Specify a full control identifier: [[iface=<iface>,][name='name',][index=<index>,][device=<device>,][subdevice=<subdevice>]]|[numid=<numid>]\n");
|
||||
|
@ -706,20 +706,20 @@ static int cset(int argc, char *argv[], int roflag)
|
|||
error("Control %s open error: %s\n", card, snd_strerror(err));
|
||||
return err;
|
||||
}
|
||||
snd_control_info_set_id(info, id);
|
||||
if ((err = snd_ctl_cinfo(handle, info)) < 0) {
|
||||
snd_ctl_element_info_set_id(info, id);
|
||||
if ((err = snd_ctl_element_info(handle, info)) < 0) {
|
||||
error("Control %s cinfo error: %s\n", card, snd_strerror(err));
|
||||
return err;
|
||||
}
|
||||
type = snd_control_info_get_type(info);
|
||||
count = snd_control_info_get_count(info);
|
||||
snd_control_set_id(control, id);
|
||||
type = snd_ctl_element_info_get_type(info);
|
||||
count = snd_ctl_element_info_get_count(info);
|
||||
snd_ctl_element_set_id(control, id);
|
||||
|
||||
if (!roflag) {
|
||||
ptr = argv[1];
|
||||
for (idx = 0; idx < count && idx < 128 && *ptr; idx++) {
|
||||
switch (snd_enum_to_int(type)) {
|
||||
case SND_CONTROL_TYPE_BOOLEAN:
|
||||
case SND_CTL_ELEMENT_TYPE_BOOLEAN:
|
||||
tmp = 0;
|
||||
if (!strncasecmp(ptr, "on", 2) || !strncasecmp(ptr, "up", 2)) {
|
||||
tmp = 1;
|
||||
|
@ -732,21 +732,21 @@ static int cset(int argc, char *argv[], int roflag)
|
|||
while (isdigit(*ptr))
|
||||
ptr++;
|
||||
}
|
||||
snd_control_set_boolean(control, idx, tmp);
|
||||
snd_ctl_element_set_boolean(control, idx, tmp);
|
||||
break;
|
||||
case SND_CONTROL_TYPE_INTEGER:
|
||||
case SND_CTL_ELEMENT_TYPE_INTEGER:
|
||||
tmp = get_integer(&ptr,
|
||||
snd_control_info_get_min(info),
|
||||
snd_control_info_get_max(info));
|
||||
snd_control_set_integer(control, idx, tmp);
|
||||
snd_ctl_element_info_get_min(info),
|
||||
snd_ctl_element_info_get_max(info));
|
||||
snd_ctl_element_set_integer(control, idx, tmp);
|
||||
break;
|
||||
case SND_CONTROL_TYPE_ENUMERATED:
|
||||
tmp = get_integer(&ptr, 0, snd_control_info_get_items(info) - 1);
|
||||
snd_control_set_enumerated(control, idx, tmp);
|
||||
case SND_CTL_ELEMENT_TYPE_ENUMERATED:
|
||||
tmp = get_integer(&ptr, 0, snd_ctl_element_info_get_items(info) - 1);
|
||||
snd_ctl_element_set_enumerated(control, idx, tmp);
|
||||
break;
|
||||
case SND_CONTROL_TYPE_BYTES:
|
||||
case SND_CTL_ELEMENT_TYPE_BYTES:
|
||||
tmp = get_integer(&ptr, 0, 255);
|
||||
snd_control_set_byte(control, idx, tmp);
|
||||
snd_ctl_element_set_byte(control, idx, tmp);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -756,7 +756,7 @@ static int cset(int argc, char *argv[], int roflag)
|
|||
else if (*ptr == ',')
|
||||
ptr++;
|
||||
}
|
||||
if ((err = snd_ctl_cwrite(handle, control)) < 0) {
|
||||
if ((err = snd_ctl_element_write(handle, control)) < 0) {
|
||||
error("Control %s cwrite error: %s\n", card, snd_strerror(err));
|
||||
return err;
|
||||
}
|
||||
|
@ -805,7 +805,7 @@ static int sset(unsigned int argc, char *argv[], int roflag)
|
|||
unsigned int channels;
|
||||
snd_mixer_t *handle;
|
||||
snd_mixer_sid_t sid;
|
||||
snd_mixer_simple_control_t control;
|
||||
snd_mixer_simple_element_t control;
|
||||
char name[simple_name_size];
|
||||
|
||||
if (argc < 1) {
|
||||
|
@ -826,7 +826,7 @@ static int sset(unsigned int argc, char *argv[], int roflag)
|
|||
}
|
||||
memset(&control, 0, sizeof(control));
|
||||
control.sid = sid;
|
||||
if ((err = snd_mixer_simple_control_read(handle, &control))<0) {
|
||||
if ((err = snd_mixer_simple_element_read(handle, &control))<0) {
|
||||
error("Unable to read simple control '%s',%i: %s\n", simple_name(sid.name, name), sid.index, snd_strerror(err));
|
||||
snd_mixer_close(handle);
|
||||
return err;
|
||||
|
@ -878,7 +878,7 @@ static int sset(unsigned int argc, char *argv[], int roflag)
|
|||
return err;
|
||||
}
|
||||
}
|
||||
if ((err = snd_mixer_simple_control_write(handle, &control))<0) {
|
||||
if ((err = snd_mixer_simple_element_write(handle, &control))<0) {
|
||||
error("Unable to write control '%s',%i: %s\n", simple_name(sid.name, name), sid.index, snd_strerror(err));
|
||||
snd_mixer_close(handle);
|
||||
return err;
|
||||
|
@ -886,37 +886,37 @@ static int sset(unsigned int argc, char *argv[], int roflag)
|
|||
__skip_write:
|
||||
if (!quiet) {
|
||||
printf("Simple mixer control '%s',%i\n", simple_name(sid.name, name), sid.index);
|
||||
show_simple_control(handle, &sid, " ", 1);
|
||||
show_simple_element(handle, &sid, " ", 1);
|
||||
}
|
||||
snd_mixer_close(handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void events_change(snd_ctl_t *handle ATTRIBUTE_UNUSED, snd_hcontrol_t *hcontrol)
|
||||
static void events_change(snd_ctl_t *handle ATTRIBUTE_UNUSED, snd_hctl_element_t *helem)
|
||||
{
|
||||
snd_control_id_t *id;
|
||||
snd_control_id_alloca(&id);
|
||||
snd_hcontrol_get_id(hcontrol, id);
|
||||
snd_ctl_element_id_t *id;
|
||||
snd_ctl_element_id_alloca(&id);
|
||||
snd_hctl_element_get_id(helem, id);
|
||||
printf("event change: ");
|
||||
show_control_id(id);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
static void events_value(snd_ctl_t *handle ATTRIBUTE_UNUSED, snd_hcontrol_t *hcontrol)
|
||||
static void events_value(snd_ctl_t *handle ATTRIBUTE_UNUSED, snd_hctl_element_t *helem)
|
||||
{
|
||||
snd_control_id_t *id;
|
||||
snd_control_id_alloca(&id);
|
||||
snd_hcontrol_get_id(hcontrol, id);
|
||||
snd_ctl_element_id_t *id;
|
||||
snd_ctl_element_id_alloca(&id);
|
||||
snd_hctl_element_get_id(helem, id);
|
||||
printf("event value: ");
|
||||
show_control_id(id);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
static void events_remove(snd_ctl_t *handle ATTRIBUTE_UNUSED, snd_hcontrol_t *hcontrol)
|
||||
static void events_remove(snd_ctl_t *handle ATTRIBUTE_UNUSED, snd_hctl_element_t *helem)
|
||||
{
|
||||
snd_control_id_t *id;
|
||||
snd_control_id_alloca(&id);
|
||||
snd_hcontrol_get_id(hcontrol, id);
|
||||
snd_ctl_element_id_t *id;
|
||||
snd_ctl_element_id_alloca(&id);
|
||||
snd_hctl_element_get_id(helem, id);
|
||||
printf("event remove: ");
|
||||
show_control_id(id);
|
||||
printf("\n");
|
||||
|
@ -928,24 +928,24 @@ static void events_rebuild(snd_ctl_t *handle ATTRIBUTE_UNUSED, void *private_dat
|
|||
printf("event rebuild\n");
|
||||
}
|
||||
|
||||
static void events_add(snd_ctl_t *handle ATTRIBUTE_UNUSED, void *private_data, snd_hcontrol_t *hcontrol)
|
||||
static void events_add(snd_ctl_t *handle ATTRIBUTE_UNUSED, void *private_data, snd_hctl_element_t *helem)
|
||||
{
|
||||
snd_control_id_t *id;
|
||||
snd_control_id_alloca(&id);
|
||||
snd_hcontrol_get_id(hcontrol, id);
|
||||
snd_ctl_element_id_t *id;
|
||||
snd_ctl_element_id_alloca(&id);
|
||||
snd_hctl_element_get_id(helem, id);
|
||||
assert(private_data != (void *)1);
|
||||
printf("event add: ");
|
||||
show_control_id(id);
|
||||
printf("\n");
|
||||
snd_hcontrol_set_callback_change(hcontrol, events_change);
|
||||
snd_hcontrol_set_callback_value(hcontrol, events_value);
|
||||
snd_hcontrol_set_callback_remove(hcontrol, events_remove);
|
||||
snd_hctl_element_set_callback_change(helem, events_change);
|
||||
snd_hctl_element_set_callback_value(helem, events_value);
|
||||
snd_hctl_element_set_callback_remove(helem, events_remove);
|
||||
}
|
||||
|
||||
static int events(int argc ATTRIBUTE_UNUSED, char *argv[] ATTRIBUTE_UNUSED)
|
||||
{
|
||||
snd_ctl_t *handle;
|
||||
snd_hcontrol_t *hcontrol;
|
||||
snd_hctl_element_t *helem;
|
||||
int err;
|
||||
|
||||
if ((err = snd_ctl_open(&handle, card)) < 0) {
|
||||
|
@ -964,10 +964,10 @@ static int events(int argc ATTRIBUTE_UNUSED, char *argv[] ATTRIBUTE_UNUSED)
|
|||
error("Control %s hcallback_add error: %s\n", card, snd_strerror(err));
|
||||
return err;
|
||||
}
|
||||
for (hcontrol = snd_ctl_hfirst(handle); hcontrol; hcontrol = snd_ctl_hnext(handle, hcontrol)) {
|
||||
snd_hcontrol_set_callback_change(hcontrol, events_change);
|
||||
snd_hcontrol_set_callback_value(hcontrol, events_value);
|
||||
snd_hcontrol_set_callback_remove(hcontrol, events_remove);
|
||||
for (helem = snd_ctl_hfirst(handle); helem; helem = snd_ctl_hnext(handle, helem)) {
|
||||
snd_hctl_element_set_callback_change(helem, events_change);
|
||||
snd_hctl_element_set_callback_value(helem, events_value);
|
||||
snd_hctl_element_set_callback_remove(helem, events_remove);
|
||||
}
|
||||
printf("Ready to listen...\n");
|
||||
while (1) {
|
||||
|
@ -1104,7 +1104,7 @@ int main(int argc, char *argv[])
|
|||
return 1;
|
||||
}
|
||||
if (argc - optind <= 0) {
|
||||
return simple_controls(1) ? 1 : 0;
|
||||
return simple_elements(1) ? 1 : 0;
|
||||
}
|
||||
if (!strcmp(argv[optind], "help")) {
|
||||
return help() ? 1 : 0;
|
||||
|
@ -1115,9 +1115,9 @@ int main(int argc, char *argv[])
|
|||
} else if (!strcmp(argv[optind], "contents")) {
|
||||
return controls(1) ? 1 : 0;
|
||||
} else if (!strcmp(argv[optind], "scontrols") || !strcmp(argv[optind], "simple")) {
|
||||
return simple_controls(0) ? 1 : 0;
|
||||
return simple_elements(0) ? 1 : 0;
|
||||
} else if (!strcmp(argv[optind], "scontents")) {
|
||||
return simple_controls(1) ? 1 : 0;
|
||||
return simple_elements(1) ? 1 : 0;
|
||||
} else if (!strcmp(argv[optind], "sset") || !strcmp(argv[optind], "set")) {
|
||||
return sset(argc - optind - 1, argc - optind > 1 ? argv + optind + 1 : NULL, 0) ? 1 : 0;
|
||||
} else if (!strcmp(argv[optind], "sget") || !strcmp(argv[optind], "get")) {
|
||||
|
|
|
@ -83,7 +83,7 @@ static int verbose = 0;
|
|||
static int buffer_pos = 0;
|
||||
static size_t bits_per_sample, bits_per_frame;
|
||||
static size_t chunk_bytes;
|
||||
static snd_control_type_t digtype = SND_CONTROL_TYPE_NONE;
|
||||
static snd_ctl_element_type_t digtype = SND_CTL_ELEMENT_TYPE_NONE;
|
||||
static snd_aes_iec958_t spdif;
|
||||
static snd_output_t *log;
|
||||
|
||||
|
@ -173,9 +173,9 @@ static void device_list(void)
|
|||
{
|
||||
snd_ctl_t *handle;
|
||||
int card, err, dev, idx;
|
||||
snd_ctl_info_t *info;
|
||||
snd_ctl_card_info_t *info;
|
||||
snd_pcm_info_t *pcminfo;
|
||||
snd_ctl_info_alloca(&info);
|
||||
snd_ctl_card_info_alloca(&info);
|
||||
snd_pcm_info_alloca(&pcminfo);
|
||||
|
||||
card = -1;
|
||||
|
@ -190,7 +190,7 @@ static void device_list(void)
|
|||
error("control open (%i): %s", card, snd_strerror(err));
|
||||
continue;
|
||||
}
|
||||
if ((err = snd_ctl_info(handle, info)) < 0) {
|
||||
if ((err = snd_ctl_card_info(handle, info)) < 0) {
|
||||
error("control hardware info (%i): %s", card, snd_strerror(err));
|
||||
snd_ctl_close(handle);
|
||||
continue;
|
||||
|
@ -211,7 +211,7 @@ static void device_list(void)
|
|||
continue;
|
||||
}
|
||||
fprintf(stderr, "card %i: %s [%s], device %i: %s [%s]\n",
|
||||
card, snd_ctl_info_get_id(info), snd_ctl_info_get_name(info),
|
||||
card, snd_ctl_card_info_get_id(info), snd_ctl_card_info_get_name(info),
|
||||
dev,
|
||||
snd_pcm_info_get_id(pcminfo),
|
||||
snd_pcm_info_get_name(pcminfo));
|
||||
|
@ -410,7 +410,7 @@ int main(int argc, char *argv[])
|
|||
interleaved = 0;
|
||||
break;
|
||||
case 'C':
|
||||
digtype = SND_CONTROL_TYPE_IEC958;
|
||||
digtype = SND_CTL_ELEMENT_TYPE_IEC958;
|
||||
spdif.status[0] = IEC958_AES0_NONAUDIO |
|
||||
IEC958_AES0_CON_EMPHASIS_NONE;
|
||||
spdif.status[1] = IEC958_AES1_CON_ORIGINAL |
|
||||
|
@ -419,7 +419,7 @@ int main(int argc, char *argv[])
|
|||
spdif.status[3] = IEC958_AES3_CON_FS_48000;
|
||||
break;
|
||||
case 'P':
|
||||
digtype = SND_CONTROL_TYPE_IEC958;
|
||||
digtype = SND_CTL_ELEMENT_TYPE_IEC958;
|
||||
spdif.status[0] = IEC958_AES0_PROFESSIONAL |
|
||||
IEC958_AES0_NONAUDIO |
|
||||
IEC958_AES0_PRO_EMPHASIS_NONE |
|
||||
|
@ -447,17 +447,17 @@ int main(int argc, char *argv[])
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (digtype != SND_CONTROL_TYPE_NONE) {
|
||||
snd_control_t *ctl;
|
||||
if (digtype != SND_CTL_ELEMENT_TYPE_NONE) {
|
||||
snd_ctl_element_t *ctl;
|
||||
snd_ctl_t *ctl_handle;
|
||||
char ctl_name[12];
|
||||
int ctl_card;
|
||||
snd_control_alloca(&ctl);
|
||||
snd_control_set_interface(ctl, SND_CONTROL_IFACE_PCM);
|
||||
snd_control_set_device(ctl, snd_pcm_info_get_device(info));
|
||||
snd_control_set_subdevice(ctl, snd_pcm_info_get_subdevice(info));
|
||||
snd_control_set_name(ctl, "IEC958 (S/PDIF) Stream");
|
||||
snd_control_set_iec958(ctl, &spdif);
|
||||
snd_ctl_element_alloca(&ctl);
|
||||
snd_ctl_element_set_interface(ctl, SND_CTL_ELEMENT_IFACE_PCM);
|
||||
snd_ctl_element_set_device(ctl, snd_pcm_info_get_device(info));
|
||||
snd_ctl_element_set_subdevice(ctl, snd_pcm_info_get_subdevice(info));
|
||||
snd_ctl_element_set_name(ctl, "IEC958 (S/PDIF) Stream");
|
||||
snd_ctl_element_set_iec958(ctl, &spdif);
|
||||
ctl_card = snd_pcm_info_get_card(info);
|
||||
if (ctl_card < 0) {
|
||||
error("Unable to setup the IEC958 (S/PDIF) interface - PCM has no assigned card");
|
||||
|
@ -468,7 +468,7 @@ int main(int argc, char *argv[])
|
|||
error("Unable to open the control interface '%s': %s", ctl_name, snd_strerror(err));
|
||||
goto __diga_end;
|
||||
}
|
||||
if ((err = snd_ctl_cwrite(ctl_handle, ctl)) < 0) {
|
||||
if ((err = snd_ctl_element_write(ctl_handle, ctl)) < 0) {
|
||||
error("Unable to update the IEC958 control: %s", snd_strerror(err));
|
||||
goto __diga_end;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue