From: Andre Noll Date: Mon, 4 Jan 2010 22:02:42 +0000 (+0100) Subject: Introduce prepare_writer_node(). X-Git-Tag: v0.4.2~204 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=03683166610b241183b3cdb311069c96144fa53e;p=paraslash.git Introduce prepare_writer_node(). Unused yet. --- diff --git a/error.h b/error.h index 1a2b3a4c..08d6bd6e 100644 --- a/error.h +++ b/error.h @@ -423,6 +423,7 @@ extern const char **para_errlist[]; #define WRITE_COMMON_ERRORS \ PARA_ERROR(WRITE_COMMON_SYNTAX, "syntax error in write option"), \ + PARA_ERROR(WRITE_COMMON_EOF, "write: end of file"), \ #define AACDEC_FILTER_ERRORS \ diff --git a/write.h b/write.h index a88b3537..49e56c38 100644 --- a/write.h +++ b/write.h @@ -25,6 +25,7 @@ struct writer_node { size_t written; struct btr_node *btrn; struct task task; + size_t min_iqs; }; /** Describes one supported writer. */ diff --git a/write_common.c b/write_common.c index 7c0d9521..ff8999f6 100644 --- a/write_common.c +++ b/write_common.c @@ -303,3 +303,20 @@ void print_writer_helps(int detailed) ggo_print_help(&w->help, detailed); } } + +int prepare_writer_node(struct writer_node *wn) +{ + struct btr_node *btrn = wn->btrn; + size_t iqs; + + if (btr_eof(btrn)) + return -E_WRITE_COMMON_EOF; + iqs = btr_get_input_queue_size(btrn); + if (iqs < wn->min_iqs && !btr_no_parent(btrn)) + return 0; + assert(iqs != 0); + /* avoid "buffer too small" errors from the decoder */ + btr_merge(btrn, wn->min_iqs); + return 1; +} + diff --git a/write_common.h b/write_common.h index f34ad3fe..34e21cee 100644 --- a/write_common.h +++ b/write_common.h @@ -14,3 +14,4 @@ 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 prepare_writer_node(struct writer_node *wn);