]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - write_common.c
audiod: Properly handle wng open failures.
[paraslash.git] / write_common.c
index 3bf5d1199f560e9ce93b7d97a06e278ce495591f..4619d40702338901d3437a4989afaf54889e334d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006-2008 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2006-2009 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
@@ -10,6 +10,7 @@
 #include "string.h"
 #include "list.h"
 #include "sched.h"
+#include "ggo.h"
 #include "write.h"
 #include "error.h"
 
@@ -26,6 +27,8 @@ static void wng_pre_select(__a_unused struct sched *s, struct task *t)
 
        FOR_EACH_WRITER_NODE(i, g) {
                struct writer_node *wn = &g->writer_nodes[i];
+               if (!wn->writer->pre_select)
+                       continue;
                t->error = wn->writer->pre_select(s, wn);
                if (t->error < 0)
                        return;
@@ -60,7 +63,7 @@ static void wng_post_select(struct sched *s, struct task *t)
        }
        if (*g->loaded && min_written) {
 //             PARA_INFO_LOG("moving %zd bytes\n", *g->loaded);
-               memmove(g->buf, g->buf + min_written, *g->loaded);
+               memmove(*g->bufp, *g->bufp + min_written, *g->loaded);
        }
 }
 
@@ -85,8 +88,6 @@ int wng_open(struct writer_node_group *g)
                ret = wn->writer->open(wn);
                if (ret < 0)
                        goto err_out;
-               wn->chunk_bytes = ret;
-               g->max_chunk_bytes = PARA_MAX(g->max_chunk_bytes, ret);
        }
        sprintf(g->task.status, "%s", "writer node group");
        register_task(&g->task);
@@ -98,7 +99,9 @@ err_out:
                struct writer_node *wn = &g->writer_nodes[--i];
                wn->writer->close(wn);
        }
+       free(g->writer_nodes);
        g->num_writers = 0;
+       g->task.error = -E_TASK_UNREGISTERED;
        return ret;
 }
 
@@ -143,9 +146,9 @@ struct writer_node_group *wng_new(unsigned num_writers)
 }
 
 /**
- * call the init function of each supported paraslash writer
+ * Call the init function of each supported paraslash writer.
  */
-void init_supported_writers(void)
+void writer_init(void)
 {
        int i;
 
@@ -210,3 +213,21 @@ struct writer_node_group *setup_default_wng(void)
        wng->writer_nodes[0].conf = writers[DEFAULT_WRITER].parse_config("");
        return wng;
 }
+
+void print_writer_helps(int detailed)
+{
+       int i;
+
+       printf_or_die("\nAvailable writers: \n\t");
+       FOR_EACH_WRITER(i)
+               printf_or_die("%s%s", i? " " : "", writer_names[i]);
+       printf_or_die("\n\n");
+       FOR_EACH_WRITER(i) {
+               struct writer *w = writers + i;
+
+               if (!w->help.short_help)
+                       continue;
+               printf_or_die("Options for %s:\n", writer_names[i]);
+               ggo_print_help(&w->help, detailed);
+       }
+}