From 10079828feee9a5b45937a7b9615c926a286782b Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Tue, 5 Jan 2010 06:04:04 +0100 Subject: [PATCH] Add get_btr_samplerate() and get_btr_channels(). These are needed by more than one writer. --- write_common.c | 28 ++++++++++++++++++++++++++++ write_common.h | 2 ++ 2 files changed, 30 insertions(+) diff --git a/write_common.c b/write_common.c index 14ce8195..9af8d682 100644 --- a/write_common.c +++ b/write_common.c @@ -304,3 +304,31 @@ void print_writer_helps(int detailed) ggo_print_help(&w->help, detailed); } } + +static int get_btr_value(struct btr_node *btrn, const char *key, int32_t *result) +{ + char *buf = NULL; + int ret = btr_exec_up(btrn, key, &buf); + + if (ret < 0) + return ret; + ret = para_atoi32(buf, result); + free(buf); + return ret; +} + +/* + * Ask parent btr nodes for the samplerate of the current stream. + */ +int get_btr_samplerate(struct btr_node *btrn, int32_t *result) +{ + return get_btr_value(btrn, "samplerate", result); +} + +/* + * Ask parent btr nodes for the channel count of the current stream. + */ +int get_btr_channels(struct btr_node *btrn, int32_t *result) +{ + return get_btr_value(btrn, "channels", result); +} diff --git a/write_common.h b/write_common.h index f34ad3fe..ef5a7c03 100644 --- a/write_common.h +++ b/write_common.h @@ -14,3 +14,5 @@ void *check_writer_arg(const char *wa, int *writer_num); struct writer_node_group *setup_default_wng(void); void print_writer_helps(int detailed); struct writer_node *setup_writer_node(const char *arg, struct btr_node *parent); +int get_btr_samplerate(struct btr_node *btrn, int32_t *result); +int get_btr_channels(struct btr_node *btrn, int32_t *result); -- 2.39.2