mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-31 22:25:35 -04:00
ucm: add a check for the empty configuration
Return an error if the UCM configuration is empty (no verbs or no boot sequence). Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
e80f35611d
commit
22d5ca8b6b
1 changed files with 23 additions and 3 deletions
|
|
@ -568,6 +568,20 @@ static int import_master_config(snd_use_case_mgr_t *uc_mgr)
|
||||||
return add_auto_values(uc_mgr);
|
return add_auto_values(uc_mgr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Check, if the UCM configuration is empty
|
||||||
|
* \param uc_mgr Use case Manager
|
||||||
|
* \return zero on success, otherwise a negative error code
|
||||||
|
*/
|
||||||
|
static int check_empty_configuration(snd_use_case_mgr_t *uc_mgr)
|
||||||
|
{
|
||||||
|
if (!list_empty(&uc_mgr->verb_list))
|
||||||
|
return 0;
|
||||||
|
if (!list_empty(&uc_mgr->once_list))
|
||||||
|
return 0;
|
||||||
|
return -ENXIO;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Universal find - string in a list
|
* \brief Universal find - string in a list
|
||||||
* \param list List of structures
|
* \param list List of structures
|
||||||
|
|
@ -981,14 +995,20 @@ int snd_use_case_mgr_open(snd_use_case_mgr_t **uc_mgr,
|
||||||
err = import_master_config(mgr);
|
err = import_master_config(mgr);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
uc_error("error: failed to import %s use case configuration %d",
|
uc_error("error: failed to import %s use case configuration %d",
|
||||||
card_name, err);
|
card_name, err);
|
||||||
goto err;
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = check_empty_configuration(mgr);
|
||||||
|
if (err < 0) {
|
||||||
|
uc_error("error: failed to import %s (empty configuration)", card_name);
|
||||||
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
*uc_mgr = mgr;
|
*uc_mgr = mgr;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err:
|
_err:
|
||||||
uc_mgr_free(mgr);
|
uc_mgr_free(mgr);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue