X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=write.c;h=3671633b2d3032d5041693f15eaa558df085acdc;hp=7f29665de46f0844589e36a144e4b61848dda79b;hb=c4ecbd8f75be7847f7332dd64f11a0ba54233891;hpb=c839ef92e35d5604748aa4674b400156ff7baced diff --git a/write.c b/write.c index 7f29665d..3671633b 100644 --- a/write.c +++ b/write.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2006 Andre Noll + * Copyright (C) 2005-2007 Andre Noll * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,6 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ +/** \file write.c Paraslash's standalone wav/raw player */ + #include "para.h" #include "string.h" #include "write.cmdline.h" @@ -29,26 +31,41 @@ INIT_WRITE_ERRLISTS; +/** + * check if given buffer contains a valid wave header + */ struct check_wav_task { + /** the buffer to check */ char *buf; + /** number of bytes loaded in \a buf */ size_t *loaded; + /** non-zero if end of file was reached */ int *eof; + /** number of channels specified in wav header given by \a buf */ unsigned channels; + /** samplerate specified in wav header given by \a buf */ unsigned samplerate; + /** the task structure for this task */ struct task task; }; +/** + * delay writing until given time + */ struct initial_delay_task { + /** the time the first data should be written out */ struct timeval start_time; + /** the task structure for this task */ struct task task; }; static struct write_args_info conf; -struct stdin_task sit; -struct check_wav_task cwt; -struct initial_delay_task idt; +static struct stdin_task sit; +static struct check_wav_task cwt; +static struct initial_delay_task idt; static struct writer_node_group *wng; +/** length of a standard wav header */ #define WAV_HEADER_LEN 44 /** @@ -96,16 +113,7 @@ static void initial_delay_pre_select(struct sched *s, struct task *t) s->timeout = diff; } -void para_log(int ll, const char* fmt,...) -{ - va_list argp; - - if (ll < conf.loglevel_arg) - return; - va_start(argp, fmt); - vfprintf(stderr, fmt, argp); - va_end(argp); -} +INIT_STDERR_LOGGING(conf.loglevel_arg) static struct writer_node_group *check_args(void) { @@ -205,12 +213,24 @@ static void cwt_event_handler(struct task *t) register_task(&idt.task); } +/** + * para_write's main function + * + * \param argc the usual argument counter + * \param argv the usual argument vector + * + * It registers the stdin task, the check_wav_task, the task for initial delay + * and all tasks for actually writing out the stream. + * + * \return \p EXIT_SUCCESS or EXIT_FAILURE + */ int main(int argc, char *argv[]) { int ret = -E_WRITE_SYNTAX; struct sched s; write_cmdline_parser(argc, argv, &conf); + HANDLE_VERSION_FLAG("write", conf); init_supported_writers(); wng = check_args();