static char *rval_card_id(snd_use_case_mgr_t *uc_mgr)
{
- struct list_head *pos;
- struct ctl_list *ctl_list = NULL;
-
- list_for_each(pos, &uc_mgr->ctl_list) {
- if (ctl_list) {
- uc_error("multiple control device names were found!");
- return NULL;
- }
- ctl_list = list_entry(pos, struct ctl_list, list);
- }
+ struct ctl_list *ctl_list;
+ ctl_list = uc_mgr_get_one_ctl(uc_mgr);
if (ctl_list == NULL)
return NULL;
-
- return strdup(ctl_list->ctl_id);
+ return strdup(snd_ctl_card_info_get_id(ctl_list->ctl_info));
}
static char *rval_card_name(snd_use_case_mgr_t *uc_mgr)
{
- if (uc_mgr->card_short_name)
- return strdup(uc_mgr->card_short_name);
- return NULL;
+ struct ctl_list *ctl_list;
+
+ ctl_list = uc_mgr_get_one_ctl(uc_mgr);
+ if (ctl_list == NULL)
+ return NULL;
+ return strdup(snd_ctl_card_info_get_name(ctl_list->ctl_info));
}
static char *rval_card_longname(snd_use_case_mgr_t *uc_mgr)
{
- if (uc_mgr->card_long_name[0])
- return strdup(uc_mgr->card_long_name);
- return NULL;
+ struct ctl_list *ctl_list;
+
+ ctl_list = uc_mgr_get_one_ctl(uc_mgr);
+ if (ctl_list == NULL)
+ return NULL;
+ return strdup(snd_ctl_card_info_get_longname(ctl_list->ctl_info));
}
static char *rval_env(snd_use_case_mgr_t *uc_mgr ATTRIBUTE_UNUSED, const char *id)
}
/* find the card in the local machine and store the card long name */
-static int get_card_long_name(snd_use_case_mgr_t *mgr)
+static int get_card_long_name(snd_use_case_mgr_t *mgr, char *longname)
{
const char *card_name = mgr->card_name;
int card, err;
_long_name = snd_ctl_card_info_get_longname(info);
if (!strcmp(card_name, _name) ||
!strcmp(card_name, _long_name)) {
- snd_strlcpy(mgr->card_short_name, _name, sizeof(mgr->card_short_name));
- snd_strlcpy(mgr->card_long_name, _long_name, sizeof(mgr->card_long_name));
+ snd_strlcpy(longname, _long_name, MAX_CARD_LONG_NAME);
return 0;
}
}
}
/* set the driver name and long name by the card ctl name */
-static int get_by_card(snd_use_case_mgr_t *mgr, const char *ctl_name)
+static int get_by_card(snd_use_case_mgr_t *mgr, const char *ctl_name, char *longname)
{
snd_ctl_t *ctl;
snd_ctl_card_info_t *info;
_name = snd_ctl_card_info_get_name(info);
_long_name = snd_ctl_card_info_get_longname(info);
-
- snd_strlcpy(mgr->card_short_name, _name, sizeof(mgr->card_short_name));
- snd_strlcpy(mgr->card_long_name, _long_name, sizeof(mgr->card_long_name));
snd_strlcpy(mgr->conf_file_name, _name, sizeof(mgr->conf_file_name));
+ snd_strlcpy(longname, _long_name, MAX_CARD_LONG_NAME);
return 0;
}
{
snd_config_t *cfg;
const char *name = uc_mgr->card_name;
+ char longname[MAX_CARD_LONG_NAME];
int err;
snd_strlcpy(uc_mgr->conf_file_name, uc_mgr->card_name, sizeof(uc_mgr->conf_file_name));
if (strncmp(name, "hw:", 3) == 0) {
- err = get_by_card(uc_mgr, name);
+ err = get_by_card(uc_mgr, name, longname);
if (err == 0)
goto __longname;
uc_error("card '%s' is not valid", name);
goto __error;
} else if (strncmp(name, "strict:", 7)) {
- err = get_card_long_name(uc_mgr);
+ err = get_card_long_name(uc_mgr, longname);
if (err == 0) { /* load file that matches the card long name */
__longname:
- err = load_master_config(uc_mgr, uc_mgr->card_long_name, &cfg, 1);
+ err = load_master_config(uc_mgr, longname, &cfg, 1);
}
if (err == 0) {
/* got device-specific file that matches the card long name */
- snd_strlcpy(uc_mgr->conf_file_name, uc_mgr->card_long_name, sizeof(uc_mgr->conf_file_name));
+ snd_strlcpy(uc_mgr->conf_file_name, longname, sizeof(uc_mgr->conf_file_name));
goto __parse;
}
}
struct ctl_list {
struct list_head list;
struct list_head dev_list;
- char *ctl_id;
snd_ctl_t *ctl;
+ snd_ctl_card_info_t *ctl_info;
};
/*
*/
struct snd_use_case_mgr {
char *card_name;
- char card_short_name[MAX_CARD_SHORT_NAME];
- char card_long_name[MAX_CARD_LONG_NAME];
char conf_file_name[MAX_CARD_LONG_NAME];
char *comment;
int conf_format;
snd_ctl_t **ctl,
const char *device);
+struct ctl_list *uc_mgr_get_one_ctl(snd_use_case_mgr_t *uc_mgr);
void uc_mgr_free_ctl_list(snd_use_case_mgr_t *uc_mgr);
/** The name of the environment variable containing the UCM directory */
va_end(va);
}
+struct ctl_list *uc_mgr_get_one_ctl(snd_use_case_mgr_t *uc_mgr)
+{
+ struct list_head *pos;
+ struct ctl_list *ctl_list = NULL;
+
+ list_for_each(pos, &uc_mgr->ctl_list) {
+ if (ctl_list) {
+ uc_error("multiple control device names were found!");
+ return NULL;
+ }
+ ctl_list = list_entry(pos, struct ctl_list, list);
+ }
+ return ctl_list;
+}
+
static void uc_mgr_free_ctl(struct ctl_list *ctl_list)
{
struct list_head *pos, *npos;
free(ctl_dev->device);
free(ctl_dev);
}
- free(ctl_list->ctl_id);
+ snd_ctl_card_info_free(ctl_list->ctl_info);
free(ctl_list);
}
static int uc_mgr_ctl_add(snd_use_case_mgr_t *uc_mgr,
struct ctl_list *ctl_list,
- snd_ctl_t *ctl, int card, snd_ctl_card_info_t *info,
+ snd_ctl_t *ctl, int card,
+ snd_ctl_card_info_t *info,
const char *device)
{
struct ctl_list *cl = NULL;
return -ENOMEM;
INIT_LIST_HEAD(&cl->dev_list);
cl->ctl = ctl;
- cl->ctl_id = strdup(id);
- if (cl->ctl_id == NULL) {
+ if (snd_ctl_card_info_malloc(&cl->ctl_info) < 0) {
free(cl);
return -ENOMEM;
}
+ snd_ctl_card_info_copy(cl->ctl_info, info);
ctl_list = cl;
}
if (card >= 0) {
/* insert to cache, if just name differs */
list_for_each(pos1, &uc_mgr->ctl_list) {
ctl_list = list_entry(pos1, struct ctl_list, list);
- if (strcmp(id, ctl_list->ctl_id) == 0) {
+ if (strcmp(id, snd_ctl_card_info_get_id(ctl_list->ctl_info)) == 0) {
card = snd_card_get_index(id);
err = uc_mgr_ctl_add(uc_mgr, ctl_list, *ctl, card, info, device);
if (err < 0)