Introduce prepare_writer_node().
authorAndre Noll <maan@systemlinux.org>
Mon, 4 Jan 2010 22:02:42 +0000 (23:02 +0100)
committerAndre Noll <maan@systemlinux.org>
Mon, 4 Jan 2010 22:02:42 +0000 (23:02 +0100)
Unused yet.

error.h
write.h
write_common.c
write_common.h

diff --git a/error.h b/error.h
index 1a2b3a4..08d6bd6 100644 (file)
--- 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 a88b353..49e56c3 100644 (file)
--- 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. */
index 7c0d952..ff8999f 100644 (file)
@@ -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;
+}
+
index f34ad3f..34e21ce 100644 (file)
@@ -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);