X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=write.c;h=7b95d6b37eb3865d475a3bda4f822ec3e9b60893;hp=7f29665de46f0844589e36a144e4b61848dda79b;hb=045273c289eb3d972eea99df99967f680b06940f;hpb=8a8cd0f5bb40dcfad68608193e8c57decd90b25e diff --git a/write.c b/write.c index 7f29665d..7b95d6b3 100644 --- a/write.c +++ b/write.c @@ -1,21 +1,14 @@ /* - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + * Licensed under the GPL v2. For licencing details see COPYING. */ +/** \file write.c Paraslash's standalone wav/raw player. */ + +#include +#include + #include "para.h" #include "string.h" #include "write.cmdline.h" @@ -29,30 +22,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 /** - * test if audio buffer contains a valid wave header + * Test if audio buffer contains a valid wave header. * * \return If not, return -E_NO_WAV_HEADER, otherwise, return zero. If * there is less than WAV_HEADER_LEN bytes awailable, return one. @@ -96,16 +100,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 +200,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();