X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=write.c;h=125df1c1d94440f7cfabad1b56ef55f1ffaa4110;hp=a3b1de1c2ceefac4ac4d152cdf54df9658341d13;hb=73f02f72cb49baebff3e0f6946750a5bc0693321;hpb=2c679eeb8bbc93220f85403eca6e9380dc624a6a diff --git a/write.c b/write.c index a3b1de1c..125df1c1 100644 --- a/write.c +++ b/write.c @@ -4,7 +4,7 @@ * Licensed under the GPL v2. For licencing details see COPYING. */ -/** \file write.c Paraslash's standalone wav/raw player */ +/** \file write.c Paraslash's standalone wav/raw player. */ #include #include @@ -22,31 +22,27 @@ INIT_WRITE_ERRLISTS; -/** - * check if given buffer contains a valid wave header - */ +/** Check if given buffer contains a valid wave header. */ struct check_wav_task { - /** the buffer to check */ + /** The buffer to check. */ char *buf; - /** number of bytes loaded in \a 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 */ + /** Non-zero if an error occurred or end of file was reached. */ + int *error; + /** Number of channels specified in wav header given by \a buf. */ unsigned channels; - /** samplerate specified in wav header given by \a buf */ + /** Sample rate specified in wav header given by \a buf. */ unsigned samplerate; - /** the task structure for this task */ + /** The task structure for this task. */ struct task task; }; -/** - * delay writing until given time - */ +/** Delay writing until given time. */ struct initial_delay_task { - /** the time the first data should be written out */ + /** The time the first data should be written out. */ struct timeval start_time; - /** the task structure for this task */ + /** The task structure for this task. */ struct task task; }; @@ -56,14 +52,14 @@ static struct check_wav_task cwt; static struct initial_delay_task idt; static struct writer_node_group *wng; -/** length of a standard wav header */ +/** 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. + * there is less than WAV_HEADER_LEN bytes available, return one. */ static void check_wav_pre_select(__a_unused struct sched *s, struct task *t) { @@ -71,7 +67,7 @@ static void check_wav_pre_select(__a_unused struct sched *s, struct task *t) unsigned char *a; if (*wt->loaded < WAV_HEADER_LEN) { - t->ret = *wt->eof? -E_PREMATURE_END : 1; + t->ret = *wt->error? -E_PREMATURE_END : 1; return; } wt->channels = 2; @@ -174,7 +170,7 @@ static void idt_event_handler(struct task *t) unregister_task(t); wng->buf = sit.buf; wng->loaded = &sit.loaded; - wng->input_eof = &sit.eof; + wng->input_error = &sit.error; wng->task.event_handler = wng_event_handler; wng->channels = &cwt.channels; wng->samplerate = &cwt.samplerate; @@ -205,10 +201,10 @@ static void cwt_event_handler(struct task *t) } /** - * para_write's main function + * Para_write's main function. * - * \param argc the usual argument counter - * \param argv the usual argument vector + * \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. @@ -238,13 +234,13 @@ int main(int argc, char *argv[]) cwt.task.event_handler = cwt_event_handler; cwt.buf = sit.buf; cwt.loaded = &sit.loaded; - cwt.eof = &sit.eof; + cwt.error = &sit.error; sprintf(cwt.task.status, "check wav"); register_task(&cwt.task); s.default_timeout.tv_sec = 1; s.default_timeout.tv_usec = 0; - ret = sched(&s); + ret = schedule(&s); out: if (ret < 0) {