diff options
-rw-r--r-- | src/config.c | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/src/config.c b/src/config.c index 2681706..d762d33 100644 --- a/src/config.c +++ b/src/config.c @@ -154,12 +154,36 @@ static enum aufmt resolve_aufmt(const struct pl *fmt) } +static int conf_get_aufmt(const struct conf *conf, const char *name, + int *fmtp) +{ + struct pl pl; + int fmt; + int err; + + err = conf_get(conf, name, &pl); + if (err) + return err; + + fmt = resolve_aufmt(&pl); + if (fmt == -1) { + warning("config: %s: sample format not supported" + " (%r)\n", name, &pl); + return EINVAL; + } + + *fmtp = fmt; + + return 0; +} + + int config_parse_conf(struct config *cfg, const struct conf *conf) { struct pl pollm, as, ap; enum poll_method method; struct vidsz size = {0, 0}; - struct pl fmt, txmode; + struct pl txmode; uint32_t v; int err = 0; @@ -236,31 +260,8 @@ int config_parse_conf(struct config *cfg, const struct conf *conf) (void)conf_get_bool(conf, "audio_level", &cfg->audio.level); - if (0 == conf_get(conf, "ausrc_format", &fmt)) { - - cfg->audio.src_fmt = resolve_aufmt(&fmt); - if (cfg->audio.src_fmt == -1) { - warning("ausrc_format: sample format not supported" - " (%r)\n", &fmt); - return EINVAL; - } - - info("ausrc: using audio sample format `%s'\n", - aufmt_name(cfg->audio.src_fmt)); - } - - if (0 == conf_get(conf, "auplay_format", &fmt)) { - - cfg->audio.play_fmt = resolve_aufmt(&fmt); - if (cfg->audio.play_fmt == -1) { - warning("auplay_format: audio format not supported" - " (%r)\n", &fmt); - return EINVAL; - } - - info("auplay: using audio sample format `%s'\n", - aufmt_name(cfg->audio.play_fmt)); - } + conf_get_aufmt(conf, "ausrc_format", &cfg->audio.src_fmt); + conf_get_aufmt(conf, "auplay_format", &cfg->audio.play_fmt); #ifdef USE_VIDEO /* Video */ |