mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2026-02-20 01:40:08 -05:00
ucm: replace uc_error with snd_error calls
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
11235095bf
commit
9ab488b86c
9 changed files with 319 additions and 296 deletions
107
src/ucm/main.c
107
src/ucm/main.c
|
|
@ -182,8 +182,9 @@ static int read_tlv_file(unsigned int **res,
|
|||
}
|
||||
sz = st.st_size;
|
||||
if (sz > 16 * 1024 * 1024 || sz < 8 || sz % 4) {
|
||||
uc_error("File size should be less than 16 MB "
|
||||
"and multiple of 4");
|
||||
snd_error(UCM, "File size should be less than 16 MB "
|
||||
"and multiple of 4");
|
||||
|
||||
err = -EINVAL;
|
||||
goto __fail;
|
||||
}
|
||||
|
|
@ -201,7 +202,7 @@ static int read_tlv_file(unsigned int **res,
|
|||
/* Check if the tlv file specifies valid size. */
|
||||
tlv = (struct snd_ctl_tlv *)(*res);
|
||||
if (tlv->length + 2 * sizeof(unsigned int) != sz) {
|
||||
uc_error("Invalid tlv size: %d", tlv->length);
|
||||
snd_error(UCM, "Invalid tlv size: %d", tlv->length);
|
||||
err = -EINVAL;
|
||||
free(*res);
|
||||
*res = NULL;
|
||||
|
|
@ -229,7 +230,7 @@ static int binary_file_parse(snd_ctl_elem_value_t *dst,
|
|||
|
||||
type = snd_ctl_elem_info_get_type(info);
|
||||
if (type != SND_CTL_ELEM_TYPE_BYTES) {
|
||||
uc_error("only support byte type!");
|
||||
snd_error(UCM, "only support byte type!");
|
||||
err = -EINVAL;
|
||||
goto __fail;
|
||||
}
|
||||
|
|
@ -245,7 +246,7 @@ static int binary_file_parse(snd_ctl_elem_value_t *dst,
|
|||
sz = st.st_size;
|
||||
count = snd_ctl_elem_info_get_count(info);
|
||||
if (sz != count || sz > sizeof(dst->value.bytes)) {
|
||||
uc_error("invalid parameter size %d!", sz);
|
||||
snd_error(UCM, "invalid parameter size %d!", sz);
|
||||
err = -EINVAL;
|
||||
goto __fail;
|
||||
}
|
||||
|
|
@ -308,11 +309,11 @@ static const char *parse_uint(const char *p, const char *prefix, size_t len,
|
|||
p += len;
|
||||
v = strtol(p, &end, 0);
|
||||
if (*end != '\0' && *end != ' ' && *end != ',') {
|
||||
uc_error("unable to parse '%s'", prefix);
|
||||
snd_error(UCM, "unable to parse '%s'", prefix);
|
||||
return NULL;
|
||||
}
|
||||
if ((unsigned int)v < min || (unsigned int)v > max) {
|
||||
uc_error("value '%s' out of range %u-%u %(%ld)", min, max, v);
|
||||
snd_error(UCM, "value '%s' out of range %u-%u %(%ld)", min, max, v);
|
||||
return NULL;
|
||||
}
|
||||
*rval = v;
|
||||
|
|
@ -399,7 +400,7 @@ next:
|
|||
*pos = p;
|
||||
return 0;
|
||||
er:
|
||||
uc_error("unknown syntax '%s'", p);
|
||||
snd_error(UCM, "unknown syntax '%s'", p);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
@ -428,7 +429,7 @@ static int execute_cset(snd_ctl_t *ctl, const char *cset, unsigned int type)
|
|||
snd_ctl_elem_info_set_id(info2, id);
|
||||
err = parse_cset_new_info(info2, pos, &pos);
|
||||
if (err < 0 || !*pos) {
|
||||
uc_error("undefined or wrong id config for cset-new", cset);
|
||||
snd_error(UCM, "undefined or wrong id config for cset-new", cset);
|
||||
err = -EINVAL;
|
||||
goto __fail;
|
||||
}
|
||||
|
|
@ -437,12 +438,12 @@ static int execute_cset(snd_ctl_t *ctl, const char *cset, unsigned int type)
|
|||
}
|
||||
if (!*pos) {
|
||||
if (type != SEQUENCE_ELEMENT_TYPE_CTL_REMOVE) {
|
||||
uc_error("undefined value for cset >%s<", cset);
|
||||
snd_error(UCM, "undefined value for cset >%s<", cset);
|
||||
err = -EINVAL;
|
||||
goto __fail;
|
||||
}
|
||||
} else if (type == SEQUENCE_ELEMENT_TYPE_CTL_REMOVE) {
|
||||
uc_error("extra value for ctl-remove >%s<", cset);
|
||||
snd_error(UCM, "extra value for ctl-remove >%s<", cset);
|
||||
err = -EINVAL;
|
||||
goto __fail;
|
||||
}
|
||||
|
|
@ -454,7 +455,7 @@ static int execute_cset(snd_ctl_t *ctl, const char *cset, unsigned int type)
|
|||
if (err >= 0) {
|
||||
err = snd_ctl_elem_remove(ctl, id);
|
||||
if (err < 0) {
|
||||
uc_error("unable to remove control");
|
||||
snd_error(UCM, "unable to remove control");
|
||||
err = -EINVAL;
|
||||
goto __fail;
|
||||
}
|
||||
|
|
@ -463,7 +464,7 @@ static int execute_cset(snd_ctl_t *ctl, const char *cset, unsigned int type)
|
|||
goto __ok;
|
||||
err = __snd_ctl_add_elem_set(ctl, info2, info2->owner, info2->count);
|
||||
if (err < 0) {
|
||||
uc_error("unable to create new control");
|
||||
snd_error(UCM, "unable to create new control");
|
||||
goto __fail;
|
||||
}
|
||||
/* new id copy */
|
||||
|
|
@ -574,7 +575,7 @@ static int execute_sysw(const char *sysw)
|
|||
free(s);
|
||||
if (ignore_error)
|
||||
return 0;
|
||||
uc_error("unable to open '%s' for write", path);
|
||||
snd_error(UCM, "unable to open '%s' for write", path);
|
||||
return -EINVAL;
|
||||
}
|
||||
wlen = write(fd, value, len);
|
||||
|
|
@ -585,7 +586,7 @@ static int execute_sysw(const char *sysw)
|
|||
goto __end;
|
||||
|
||||
if (wlen != (ssize_t)len) {
|
||||
uc_error("unable to write '%s' to '%s': %s", value, path, strerror(myerrno));
|
||||
snd_error(UCM, "unable to write '%s' to '%s': %s", value, path, strerror(myerrno));
|
||||
free(s);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
@ -619,14 +620,14 @@ static int execute_cfgsave(snd_use_case_mgr_t *uc_mgr, const char *filename)
|
|||
}
|
||||
err = snd_config_search(config, root, &config);
|
||||
if (err < 0) {
|
||||
uc_error("Unable to find subtree '%s'", root);
|
||||
snd_error(UCM, "Unable to find subtree '%s'", root);
|
||||
goto _err;
|
||||
}
|
||||
}
|
||||
|
||||
err = snd_output_stdio_open(&out, file, "w+");
|
||||
if (err < 0) {
|
||||
uc_error("unable to open file '%s': %s", file, snd_strerror(err));
|
||||
snd_error(UCM, "unable to open file '%s': %s", file, snd_strerror(err));
|
||||
goto _err;
|
||||
}
|
||||
if (!config || snd_config_is_empty(config)) {
|
||||
|
|
@ -641,7 +642,7 @@ static int execute_cfgsave(snd_use_case_mgr_t *uc_mgr, const char *filename)
|
|||
}
|
||||
snd_output_close(out);
|
||||
if (err < 0) {
|
||||
uc_error("unable to save configuration: %s", snd_strerror(err));
|
||||
snd_error(UCM, "unable to save configuration: %s", snd_strerror(err));
|
||||
goto _err;
|
||||
}
|
||||
_err:
|
||||
|
|
@ -691,13 +692,13 @@ static int run_device_sequence(snd_use_case_mgr_t *uc_mgr, struct use_case_verb
|
|||
snd_trace(UCM, "device sequence '%s/%s': %s", verb->name, name, uc_mgr_enable_str(enable));
|
||||
|
||||
if (verb == NULL) {
|
||||
uc_error("error: enadev2 / disdev2 must be executed inside the verb context");
|
||||
snd_error(UCM, "error: enadev2 / disdev2 must be executed inside the verb context");
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
device = find_device(uc_mgr, verb, name, 0);
|
||||
if (device == NULL) {
|
||||
uc_error("error: unable to find device '%s'\n", name);
|
||||
snd_error(UCM, "error: unable to find device '%s'\n", name);
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
|
|
@ -717,7 +718,7 @@ static int run_device_all_sequence(snd_use_case_mgr_t *uc_mgr, struct use_case_v
|
|||
snd_trace(UCM, "disable all devices sequence for '%s'", verb->name);
|
||||
|
||||
if (verb == NULL) {
|
||||
uc_error("error: disdevall must be executed inside the verb context");
|
||||
snd_error(UCM, "error: disdevall must be executed inside the verb context");
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
|
|
@ -757,7 +758,7 @@ static int execute_sequence(snd_use_case_mgr_t *uc_mgr,
|
|||
int err = 0;
|
||||
|
||||
if (uc_mgr->sequence_hops > 100) {
|
||||
uc_error("error: too many inner sequences!");
|
||||
snd_error(UCM, "error: too many inner sequences!");
|
||||
return -EINVAL;
|
||||
}
|
||||
uc_mgr->sequence_hops++;
|
||||
|
|
@ -781,7 +782,7 @@ static int execute_sequence(snd_use_case_mgr_t *uc_mgr,
|
|||
* its parent's cdev stored by ucm manager.
|
||||
*/
|
||||
if (uc_mgr->cdev == NULL) {
|
||||
uc_error("cdev is not defined!");
|
||||
snd_error(UCM, "cdev is not defined!");
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
@ -797,7 +798,7 @@ static int execute_sequence(snd_use_case_mgr_t *uc_mgr,
|
|||
value_list2,
|
||||
value_list3);
|
||||
if (err < 0 && err != -ENOENT) {
|
||||
uc_error("cdev is not defined!");
|
||||
snd_error(UCM, "cdev is not defined!");
|
||||
return err;
|
||||
}
|
||||
err = get_value3(uc_mgr, &capture_ctl, "CaptureCTL",
|
||||
|
|
@ -806,12 +807,12 @@ static int execute_sequence(snd_use_case_mgr_t *uc_mgr,
|
|||
value_list3);
|
||||
if (err < 0 && err != -ENOENT) {
|
||||
free(playback_ctl);
|
||||
uc_error("cdev is not defined!");
|
||||
snd_error(UCM, "cdev is not defined!");
|
||||
return err;
|
||||
}
|
||||
if (playback_ctl == NULL &&
|
||||
capture_ctl == NULL) {
|
||||
uc_error("cdev is not defined!");
|
||||
snd_error(UCM, "cdev is not defined!");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (playback_ctl != NULL &&
|
||||
|
|
@ -819,7 +820,7 @@ static int execute_sequence(snd_use_case_mgr_t *uc_mgr,
|
|||
strcmp(playback_ctl, capture_ctl) != 0) {
|
||||
free(playback_ctl);
|
||||
free(capture_ctl);
|
||||
uc_error("cdev is not equal for playback and capture!");
|
||||
snd_error(UCM, "cdev is not equal for playback and capture!");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (playback_ctl != NULL) {
|
||||
|
|
@ -832,14 +833,14 @@ static int execute_sequence(snd_use_case_mgr_t *uc_mgr,
|
|||
if (ctl == NULL) {
|
||||
err = uc_mgr_open_ctl(uc_mgr, &ctl_list, cdev, 1);
|
||||
if (err < 0) {
|
||||
uc_error("unable to open ctl device '%s'", cdev);
|
||||
snd_error(UCM, "unable to open ctl device '%s'", cdev);
|
||||
goto __fail;
|
||||
}
|
||||
ctl = ctl_list->ctl;
|
||||
}
|
||||
err = execute_cset(ctl, s->data.cset, s->type);
|
||||
if (err < 0) {
|
||||
uc_error("unable to execute cset '%s'", s->data.cset);
|
||||
snd_error(UCM, "unable to execute cset '%s'", s->data.cset);
|
||||
goto __fail;
|
||||
}
|
||||
break;
|
||||
|
|
@ -858,7 +859,7 @@ static int execute_sequence(snd_use_case_mgr_t *uc_mgr,
|
|||
ignore_error = s->data.exec[0] == '-';
|
||||
err = uc_mgr_exec(s->data.exec + (ignore_error ? 1 : 0));
|
||||
if (ignore_error == false && err != 0) {
|
||||
uc_error("exec '%s' failed (exit code %d)", s->data.exec, err);
|
||||
snd_error(UCM, "exec '%s' failed (exit code %d)", s->data.exec, err);
|
||||
goto __fail;
|
||||
}
|
||||
break;
|
||||
|
|
@ -873,7 +874,7 @@ shell_retry:
|
|||
err = -EINTR;
|
||||
} if (WIFEXITED(err)) {
|
||||
if (ignore_error == false && WEXITSTATUS(err) != 0) {
|
||||
uc_error("command '%s' failed (exit code %d)", s->data.exec, WEXITSTATUS(err));
|
||||
snd_error(UCM, "command '%s' failed (exit code %d)", s->data.exec, WEXITSTATUS(err));
|
||||
err = -EINVAL;
|
||||
goto __fail;
|
||||
}
|
||||
|
|
@ -915,7 +916,7 @@ shell_retry:
|
|||
goto __fail;
|
||||
break;
|
||||
default:
|
||||
uc_error("unknown sequence command %i", s->type);
|
||||
snd_error(UCM, "unknown sequence command %i", s->type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -1031,7 +1032,7 @@ static int set_defaults(snd_use_case_mgr_t *uc_mgr, bool force)
|
|||
err = execute_sequence(uc_mgr, NULL, &uc_mgr->default_list,
|
||||
&uc_mgr->value_list, NULL, NULL);
|
||||
if (err < 0) {
|
||||
uc_error("Unable to execute default sequence");
|
||||
snd_error(UCM, "Unable to execute default sequence");
|
||||
return err;
|
||||
}
|
||||
uc_mgr->default_list_executed = 1;
|
||||
|
|
@ -1499,7 +1500,7 @@ const char *parse_open_variables(snd_use_case_mgr_t *uc_mgr, const char *name)
|
|||
|
||||
err = snd_config_load_string(&cfg, args, 0);
|
||||
if (err < 0) {
|
||||
uc_error("error: open arguments are not valid (%s)", args);
|
||||
snd_error(UCM, "error: open arguments are not valid (%s)", args);
|
||||
goto skip;
|
||||
}
|
||||
|
||||
|
|
@ -1572,14 +1573,15 @@ int snd_use_case_mgr_open(snd_use_case_mgr_t **uc_mgr,
|
|||
if (err < 0) {
|
||||
if (err == -ENXIO && mgr->suppress_nodev_errors)
|
||||
goto _err;
|
||||
uc_error("error: failed to import %s use case configuration %d",
|
||||
card_name, err);
|
||||
snd_error(UCM, "error: failed to import %s use case configuration %d",
|
||||
card_name, err);
|
||||
|
||||
goto _err;
|
||||
}
|
||||
|
||||
err = check_empty_configuration(mgr);
|
||||
if (err < 0) {
|
||||
uc_error("error: failed to import %s (empty configuration)", card_name);
|
||||
snd_error(UCM, "error: failed to import %s (empty configuration)", card_name);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
|
|
@ -1611,7 +1613,7 @@ int snd_use_case_mgr_reload(snd_use_case_mgr_t *uc_mgr)
|
|||
/* reload all use cases */
|
||||
err = import_master_config(uc_mgr);
|
||||
if (err < 0) {
|
||||
uc_error("error: failed to reload use cases");
|
||||
snd_error(UCM, "error: failed to reload use cases");
|
||||
pthread_mutex_unlock(&uc_mgr->mutex);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
@ -1643,7 +1645,7 @@ static int dismantle_use_case(snd_use_case_mgr_t *uc_mgr)
|
|||
active_list);
|
||||
err = set_modifier(uc_mgr, modifier, 0);
|
||||
if (err < 0)
|
||||
uc_error("Unable to disable modifier %s", modifier->name);
|
||||
snd_error(UCM, "Unable to disable modifier %s", modifier->name);
|
||||
}
|
||||
INIT_LIST_HEAD(&uc_mgr->active_modifiers);
|
||||
|
||||
|
|
@ -1652,13 +1654,13 @@ static int dismantle_use_case(snd_use_case_mgr_t *uc_mgr)
|
|||
active_list);
|
||||
err = set_device(uc_mgr, device, 0);
|
||||
if (err < 0)
|
||||
uc_error("Unable to disable device %s", device->name);
|
||||
snd_error(UCM, "Unable to disable device %s", device->name);
|
||||
}
|
||||
INIT_LIST_HEAD(&uc_mgr->active_devices);
|
||||
|
||||
err = set_verb(uc_mgr, uc_mgr->active_verb, 0);
|
||||
if (err < 0) {
|
||||
uc_error("Unable to disable verb %s", uc_mgr->active_verb->name);
|
||||
snd_error(UCM, "Unable to disable verb %s", uc_mgr->active_verb->name);
|
||||
return err;
|
||||
}
|
||||
uc_mgr->active_verb = NULL;
|
||||
|
|
@ -2478,7 +2480,7 @@ static int set_fixedboot_user(snd_use_case_mgr_t *uc_mgr,
|
|||
int err;
|
||||
|
||||
if (value != NULL && *value) {
|
||||
uc_error("error: wrong value for _fboot (%s)", value);
|
||||
snd_error(UCM, "error: wrong value for _fboot (%s)", value);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (list_empty(&uc_mgr->fixedboot_list))
|
||||
|
|
@ -2486,7 +2488,7 @@ static int set_fixedboot_user(snd_use_case_mgr_t *uc_mgr,
|
|||
err = execute_sequence(uc_mgr, NULL, &uc_mgr->fixedboot_list,
|
||||
&uc_mgr->value_list, NULL, NULL);
|
||||
if (err < 0) {
|
||||
uc_error("Unable to execute force boot sequence");
|
||||
snd_error(UCM, "Unable to execute force boot sequence");
|
||||
return err;
|
||||
}
|
||||
return err;
|
||||
|
|
@ -2498,7 +2500,7 @@ static int set_boot_user(snd_use_case_mgr_t *uc_mgr,
|
|||
int err;
|
||||
|
||||
if (value != NULL && *value) {
|
||||
uc_error("error: wrong value for _boot (%s)", value);
|
||||
snd_error(UCM, "error: wrong value for _boot (%s)", value);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (list_empty(&uc_mgr->boot_list))
|
||||
|
|
@ -2506,7 +2508,7 @@ static int set_boot_user(snd_use_case_mgr_t *uc_mgr,
|
|||
err = execute_sequence(uc_mgr, NULL, &uc_mgr->boot_list,
|
||||
&uc_mgr->value_list, NULL, NULL);
|
||||
if (err < 0) {
|
||||
uc_error("Unable to execute boot sequence");
|
||||
snd_error(UCM, "Unable to execute boot sequence");
|
||||
return err;
|
||||
}
|
||||
return err;
|
||||
|
|
@ -2516,7 +2518,7 @@ static int set_defaults_user(snd_use_case_mgr_t *uc_mgr,
|
|||
const char *value)
|
||||
{
|
||||
if (value != NULL && *value) {
|
||||
uc_error("error: wrong value for _defaults (%s)", value);
|
||||
snd_error(UCM, "error: wrong value for _defaults (%s)", value);
|
||||
return -EINVAL;
|
||||
}
|
||||
return set_defaults(uc_mgr, false);
|
||||
|
|
@ -2579,8 +2581,9 @@ static int set_verb_user(snd_use_case_mgr_t *uc_mgr,
|
|||
if (verb) {
|
||||
err = set_verb(uc_mgr, verb, 1);
|
||||
if (err < 0)
|
||||
uc_error("error: failed to initialize new use case: %s",
|
||||
verb_name);
|
||||
snd_error(UCM, "error: failed to initialize new use case: %s",
|
||||
verb_name);
|
||||
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
|
@ -2631,11 +2634,11 @@ static int switch_device(snd_use_case_mgr_t *uc_mgr,
|
|||
if (uc_mgr->active_verb == NULL)
|
||||
return -ENOENT;
|
||||
if (device_status(uc_mgr, old_device) == 0) {
|
||||
uc_error("error: device %s not enabled", old_device);
|
||||
snd_error(UCM, "error: device %s not enabled", old_device);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (device_status(uc_mgr, new_device) != 0) {
|
||||
uc_error("error: device %s already enabled", new_device);
|
||||
snd_error(UCM, "error: device %s already enabled", new_device);
|
||||
return -EINVAL;
|
||||
}
|
||||
xold = find_device(uc_mgr, uc_mgr->active_verb, old_device, 1);
|
||||
|
|
@ -2687,11 +2690,11 @@ static int switch_modifier(snd_use_case_mgr_t *uc_mgr,
|
|||
if (uc_mgr->active_verb == NULL)
|
||||
return -ENOENT;
|
||||
if (modifier_status(uc_mgr, old_modifier) == 0) {
|
||||
uc_error("error: modifier %s not enabled", old_modifier);
|
||||
snd_error(UCM, "error: modifier %s not enabled", old_modifier);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (modifier_status(uc_mgr, new_modifier) != 0) {
|
||||
uc_error("error: modifier %s already enabled", new_modifier);
|
||||
snd_error(UCM, "error: modifier %s already enabled", new_modifier);
|
||||
return -EINVAL;
|
||||
}
|
||||
xold = find_modifier(uc_mgr, uc_mgr->active_verb, old_modifier, 1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue