From 37e0dfe7bf7737863c63e515e9ed06c2f479f5a3 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 28 Oct 2012 15:21:56 +0100 Subject: [PATCH] check_wav: Ask parent nodes before falling back to defaults. This instructs the ->execute handler of the check_wav task to ask its parent nodes for the channel count, sample rate and sample format in case no wav header was found and no value for the query was given at the command line. Currently this can never succeed, since the only parent node of the check_wav task is the stdin task, which has no clue about these things. However, once check_wav is being used by the resample filter, one parent might be a decoder which can tell. This requires to add the new public btr_parent() to buffer_tree.c to let the check_wav node obtain the node to start the search from. --- buffer_tree.c | 5 +++++ buffer_tree.h | 1 + check_wav.c | 7 +++++++ 3 files changed, 13 insertions(+) diff --git a/buffer_tree.c b/buffer_tree.c index 63be36d7..4bcc88ab 100644 --- a/buffer_tree.c +++ b/buffer_tree.c @@ -1225,3 +1225,8 @@ void btr_get_node_start(struct btr_node *btrn, struct timeval *tv) { *tv = btrn->start; } + +struct btr_node *btr_parent(struct btr_node *btrn) +{ + return btrn->parent; +} diff --git a/buffer_tree.h b/buffer_tree.h index b0817759..071b055c 100644 --- a/buffer_tree.h +++ b/buffer_tree.h @@ -204,3 +204,4 @@ int btr_node_status(struct btr_node *btrn, size_t min_iqs, void btr_get_node_start(struct btr_node *btrn, struct timeval *tv); struct btr_node *btr_search_node(const char *name, struct btr_node *root); void btr_drain(struct btr_node *btrn); +struct btr_node *btr_parent(struct btr_node *btrn); diff --git a/check_wav.c b/check_wav.c index 12f44b5b..ab1c6188 100644 --- a/check_wav.c +++ b/check_wav.c @@ -77,6 +77,13 @@ out: val = header_val; break; case CWS_NO_HEADER: + /* + * No wav header available and no value specified at + * the command line. Maybe one of our parent nodes + * knows. + */ + if (btr_exec_up(btr_parent(cwc->btrn), cmd, result) >= 0) + return 1; /* Use default value */ val = arg; break; -- 2.39.5