X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=write.c;h=818175a4ebb56117e58843844edca6b092cced48;hp=9b7a92113e69ff236e08ce235ca306c9c410fd07;hb=c6675d53d29b87bf0ac4c713edbaae630611048e;hpb=5b4b082e7c37b46d5fa1729dff6496da8840085f diff --git a/write.c b/write.c index 9b7a9211..818175a4 100644 --- a/write.c +++ b/write.c @@ -1,13 +1,15 @@ /* - * Copyright (C) 2005-2008 Andre Noll + * Copyright (C) 2005-2009 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ /** \file write.c Paraslash's standalone wav/raw player. */ +#include #include #include +#include #include "para.h" #include "string.h" @@ -20,6 +22,7 @@ #include "write_common.h" #include "fd.h" #include "error.h" +#include "buffer_tree.h" INIT_WRITE_ERRLISTS; @@ -122,7 +125,8 @@ register_check_wav: s->timeout.tv_usec = 1; } -INIT_STDERR_LOGGING(conf.loglevel_arg) +static int loglevel; +INIT_STDERR_LOGGING(loglevel) static struct writer_node_group *check_args(void) { @@ -130,6 +134,7 @@ static struct writer_node_group *check_args(void) struct writer_node_group *g = NULL; struct initial_delay_task *idt = &the_initial_delay_task; + loglevel = get_loglevel_by_name(conf.loglevel_arg); if (conf.start_time_given) { long unsigned sec, usec; if (sscanf(conf.start_time_arg, "%lu:%lu", @@ -151,7 +156,7 @@ static struct writer_node_group *check_args(void) conf.writer_arg[i], &writer_num); if (!g->writer_nodes[i].conf) goto out; - g->writer_nodes[i].writer = &writers[writer_num]; + g->writer_nodes[i].writer_num = writer_num; } ret = 1; out: @@ -176,6 +181,37 @@ __noreturn static void print_help_and_die(void) exit(0); } +/* + TODO: check wav, initial delay, multiple writers, non-default writers + */ +static int main_btr(struct sched *s) +{ + struct writer_node *wn = para_malloc(sizeof(*wn)); + struct writer *w = writers + DEFAULT_WRITER; + int ret; + + sit.btrn = btr_new_node("stdin", NULL /* stdin has no parent */, NULL); + stdin_set_defaults(&sit); + register_task(&sit.task); + + wn->writer_num = DEFAULT_WRITER; + wn->conf = writers[DEFAULT_WRITER].parse_config("-B"); + wn->btrn = btr_new_node("writer", sit.btrn, NULL); + sprintf(wn->task.status, "some writer"); + w->open(wn); + wn->task.post_select = w->post_select_btr; + wn->task.pre_select = w->pre_select_btr; + register_task(&wn->task); + + + + s->default_timeout.tv_sec = 10; + s->default_timeout.tv_usec = 50000; + ret = schedule(s); + w->close(wn); + return ret; +} + /** * Para_write's main function. * @@ -194,12 +230,16 @@ int main(int argc, char *argv[]) struct check_wav_task *cwt = &the_check_wav_task; struct initial_delay_task *idt = &the_initial_delay_task; - init_supported_writers(); + writer_init(); write_cmdline_parser(argc, argv, &conf); HANDLE_VERSION_FLAG("write", conf); if (conf.help_given || conf.detailed_help_given) print_help_and_die(); + if (conf.buffer_tree_given) { + ret = main_btr(&s); + goto out; + } wng = check_args(); if (!wng) goto out; @@ -212,7 +252,7 @@ int main(int argc, char *argv[]) sit.bufsize = conf.bufsize_arg * 1024; sit.buf = para_malloc(sit.bufsize); - wng->buf = sit.buf; + wng->bufp = &sit.buf; wng->loaded = &sit.loaded; wng->input_error = &sit.task.error;