X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=write_common.c;h=41c3eb23728ab11cde71f837d4c58a1ef6908d24;hp=14cc98a4189a5f74907f8bfcf416f62bcc2515c5;hb=8af63afe0ce633fd488f0669614e2d08680f90bc;hpb=d31995b3074bb19aa4da66ce5c4774ca9ed101a1 diff --git a/write_common.c b/write_common.c index 14cc98a4..41c3eb23 100644 --- a/write_common.c +++ b/write_common.c @@ -174,24 +174,24 @@ void print_writer_helps(bool detailed) } } -static void get_btr_value(struct btr_node *btrn, const char *cmd, +static int get_btr_value(struct btr_node *btrn, const char *cmd, int32_t *result) { char *buf = NULL; int ret = btr_exec_up(btrn, cmd, &buf); - if (ret < 0) { - /* - * This really should not happen. It means one of our parent - * nodes died unexpectedly. Proceed with fingers crossed. - */ - PARA_CRIT_LOG("cmd %s: %s\n", cmd, para_strerror(-ret)); - *result = 0; - return; - } + *result = 0; + /* + * Errors may happen when the decoder returns EOF before the writer had + * a chance to query the buffer tree for the channel count, sample rate + * etc. + */ + if (ret < 0) + return ret; ret = para_atoi32(buf, result); assert(ret >= 0); free(buf); + return ret; } /** @@ -200,11 +200,11 @@ static void get_btr_value(struct btr_node *btrn, const char *cmd, * \param btrn Where to start the search. * \param result Filled in by this function. * - * This function is assumed to succeed and terminates on errors. + * \return Standard. */ -void get_btr_sample_rate(struct btr_node *btrn, int32_t *result) +int get_btr_sample_rate(struct btr_node *btrn, int32_t *result) { - get_btr_value(btrn, "sample_rate", result); + return get_btr_value(btrn, "sample_rate", result); } /** @@ -212,10 +212,12 @@ void get_btr_sample_rate(struct btr_node *btrn, int32_t *result) * * \param btrn See \ref get_btr_sample_rate. * \param result See \ref get_btr_sample_rate. + * + * \return Standard. */ -void get_btr_channels(struct btr_node *btrn, int32_t *result) +int get_btr_channels(struct btr_node *btrn, int32_t *result) { - get_btr_value(btrn, "channels", result); + return get_btr_value(btrn, "channels", result); } /** @@ -223,8 +225,10 @@ void get_btr_channels(struct btr_node *btrn, int32_t *result) * * \param btrn See \ref get_btr_sample_rate. * \param result Contains the sample format as an enum sample_format type. + * + * \return Standard. */ -void get_btr_sample_format(struct btr_node *btrn, int32_t *result) +int get_btr_sample_format(struct btr_node *btrn, int32_t *result) { - get_btr_value(btrn, "sample_format", result); + return get_btr_value(btrn, "sample_format", result); }