mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-02 09:01:48 -05:00
conf: extend hook load_for_all_cards
Pass also card integer number. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
c132509a86
commit
619cf45cb9
2 changed files with 84 additions and 9 deletions
20
src/conf.c
20
src/conf.c
|
|
@ -4009,7 +4009,7 @@ int snd_config_hook_load_for_all_cards(snd_config_t *root, snd_config_t *config,
|
|||
if (err < 0)
|
||||
return err;
|
||||
if (card >= 0) {
|
||||
snd_config_t *n, *private_data = NULL;
|
||||
snd_config_t *n, *v, *private_data = NULL;
|
||||
const char *driver;
|
||||
char *fdriver = NULL;
|
||||
err = snd_determine_driver(card, &fdriver);
|
||||
|
|
@ -4030,9 +4030,25 @@ int snd_config_hook_load_for_all_cards(snd_config_t *root, snd_config_t *config,
|
|||
} else {
|
||||
driver = fdriver;
|
||||
}
|
||||
err = snd_config_imake_string(&private_data, "string", driver);
|
||||
err = snd_config_make_compound(&private_data, NULL, 0);
|
||||
if (err < 0)
|
||||
goto __err;
|
||||
err = snd_config_imake_integer(&v, "integer", card);
|
||||
if (err < 0)
|
||||
goto __err;
|
||||
err = snd_config_add(private_data, v);
|
||||
if (err < 0) {
|
||||
snd_config_delete(v);
|
||||
goto __err;
|
||||
}
|
||||
err = snd_config_imake_string(&v, "string", driver);
|
||||
if (err < 0)
|
||||
goto __err;
|
||||
err = snd_config_add(private_data, v);
|
||||
if (err < 0) {
|
||||
snd_config_delete(v);
|
||||
goto __err;
|
||||
}
|
||||
err = snd_config_hook_load(root, config, &n, private_data);
|
||||
__err:
|
||||
if (private_data)
|
||||
|
|
|
|||
|
|
@ -645,6 +645,28 @@ static int string_from_integer(char **dst, long v)
|
|||
}
|
||||
#endif
|
||||
|
||||
int _snd_func_private_data(snd_config_t **dst, snd_config_t *src,
|
||||
snd_config_t **private_data, const char *id)
|
||||
{
|
||||
int err;
|
||||
|
||||
if (*private_data == NULL)
|
||||
return snd_config_copy(dst, src);
|
||||
if (snd_config_get_type(*private_data) == SND_CONFIG_TYPE_COMPOUND) {
|
||||
err = snd_config_search(*private_data, id, private_data);
|
||||
if (err)
|
||||
goto notfound;
|
||||
}
|
||||
err = snd_config_test_id(*private_data, id);
|
||||
if (err) {
|
||||
notfound:
|
||||
SNDERR("field %s not found", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Returns the string from \c private_data.
|
||||
* \param dst The function puts the handle to the result configuration node
|
||||
|
|
@ -668,13 +690,9 @@ int snd_func_private_string(snd_config_t **dst, snd_config_t *root ATTRIBUTE_UNU
|
|||
int err;
|
||||
const char *str, *id;
|
||||
|
||||
if (private_data == NULL)
|
||||
return snd_config_copy(dst, src);
|
||||
err = snd_config_test_id(private_data, "string");
|
||||
if (err) {
|
||||
SNDERR("field string not found");
|
||||
return -EINVAL;
|
||||
}
|
||||
err = _snd_func_private_data(dst, src, &private_data, "string");
|
||||
if (err)
|
||||
return err;
|
||||
err = snd_config_get_string(private_data, &str);
|
||||
if (err < 0) {
|
||||
SNDERR("field string is not a string");
|
||||
|
|
@ -689,6 +707,47 @@ int snd_func_private_string(snd_config_t **dst, snd_config_t *root ATTRIBUTE_UNU
|
|||
SND_DLSYM_BUILD_VERSION(snd_func_private_string, SND_CONFIG_DLSYM_VERSION_EVALUATE);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Returns the integer from \c private_data.
|
||||
* \param dst The function puts the handle to the result configuration node
|
||||
* (with type integer) at the address specified by \p dst.
|
||||
* \param root Handle to the root source node.
|
||||
* \param src Handle to the source node.
|
||||
* \param private_data Handle to the \c private_data node (type integer,
|
||||
* id "integer").
|
||||
* \return A non-negative value if successful, otherwise a negative error code.
|
||||
*
|
||||
* Example:
|
||||
\code
|
||||
{
|
||||
@func private_integer
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
int snd_func_private_integer(snd_config_t **dst, snd_config_t *root ATTRIBUTE_UNUSED,
|
||||
snd_config_t *src, snd_config_t *private_data)
|
||||
{
|
||||
int err;
|
||||
const char *id;
|
||||
long val;
|
||||
|
||||
err = _snd_func_private_data(dst, src, &private_data, "integer");
|
||||
if (err)
|
||||
return err;
|
||||
err = snd_config_get_integer(private_data, &val);
|
||||
if (err < 0) {
|
||||
SNDERR("field integer is not a string");
|
||||
return err;
|
||||
}
|
||||
err = snd_config_get_id(src, &id);
|
||||
if (err >= 0)
|
||||
err = snd_config_imake_integer(dst, id, val);
|
||||
return err;
|
||||
}
|
||||
#ifndef DOC_HIDDEN
|
||||
SND_DLSYM_BUILD_VERSION(snd_func_private_integer, SND_CONFIG_DLSYM_VERSION_EVALUATE);
|
||||
#endif
|
||||
|
||||
#ifndef DOC_HIDDEN
|
||||
int snd_determine_driver(int card, char **driver)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue