From aa68b89c370842f61075decc8fdde3577662a2ae Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Mon, 26 Nov 2001 15:19:19 +0000 Subject: [PATCH] Added snd_config_get_ireal function --- include/conf.h | 1 + src/conf.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/include/conf.h b/include/conf.h index c9e0e727..f525dfa8 100644 --- a/include/conf.h +++ b/include/conf.h @@ -112,6 +112,7 @@ int snd_config_set_pointer(snd_config_t *config, const void *ptr); int snd_config_get_id(snd_config_t *config, const char **value); int snd_config_get_integer(snd_config_t *config, long *value); int snd_config_get_real(snd_config_t *config, double *value); +int snd_config_get_ireal(snd_config_t *config, double *value); int snd_config_get_string(snd_config_t *config, const char **value); int snd_config_get_ascii(snd_config_t *config, char **value); int snd_config_get_pointer(snd_config_t *config, const void **value); diff --git a/src/conf.c b/src/conf.c index 1b93cfe4..ecd1b96d 100644 --- a/src/conf.c +++ b/src/conf.c @@ -1809,6 +1809,27 @@ int snd_config_get_real(snd_config_t *config, double *ptr) } /** + * \brief Get the value of a real or integer config node + * \param config Config node handle + * \param ptr Returned value pointer + * \return 0 on success otherwise a negative error code + * + * Note: If the config type is integer, it is converted + * to the double type on the fly. + */ +int snd_config_get_ireal(snd_config_t *config, double *ptr) +{ + assert(config && ptr); + if (config->type == SND_CONFIG_TYPE_REAL) + *ptr = config->u.real; + else if (config->type == SND_CONFIG_TYPE_INTEGER) + *ptr = config->u.integer; + else + return -EINVAL; + return 0; +} + +/** * \brief Get the value of a string config node * \param config Config node handle * \param ptr Returned value pointer -- 2.11.0