X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=write.c;h=7e6d47a56beb5e827ebbaa7d31cf2560f6b8f49f;hp=508aee790b728b169b4ac5b82832d8385a833f10;hb=3c5c2ebfc2d651f2f77d0df89cbb58a2068bcad0;hpb=2290d9be0703d3f83f38c2f100b1b41ec0790bb3 diff --git a/write.c b/write.c index 508aee79..7e6d47a5 100644 --- a/write.c +++ b/write.c @@ -32,6 +32,7 @@ INIT_WRITE_ERRLISTS; struct check_wav_task { char *buf; size_t *loaded; + int *eof; unsigned channels; unsigned sample_rate; struct task task; @@ -53,8 +54,8 @@ static struct writer_node_group *wng; /** * test if audio buffer contains a valid wave header * - * \return If not, return 0, otherwise, store number of channels and sample rate - * in struct conf and return WAV_HEADER_LEN. + * \return If not, return -E_NO_WAV_HEADER, otherwise, return zero. If + * there is less than WAV_HEADER_LEN bytes awailable, return one. */ static void check_wav_pre_select(struct sched *s, struct task *t) { @@ -62,7 +63,7 @@ static void check_wav_pre_select(struct sched *s, struct task *t) unsigned char *a; if (*cwt->loaded < WAV_HEADER_LEN) { - t->ret = 1; + t->ret = *cwt->eof? -E_PREMATURE_END : 1; return; } a = (unsigned char*)cwt->buf; @@ -148,8 +149,9 @@ static struct writer_node_group *check_args(void) } ret = 1; out: - if (ret > 0) + if (ret > 0) { return wng; + } free(wng); return NULL; } @@ -161,6 +163,7 @@ static void idt_error_handler(struct task *t) unregister_task(t); wng->buf = sit.buf; wng->loaded = &sit.loaded; + wng->eof = &sit.eof; ret = wng_open(wng); if (ret < 0) { PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret)); @@ -194,7 +197,6 @@ static void stdin_error_handler(struct task *t) PARA_INFO_LOG("task %p, ret: %d\n", t, t->ret); if (t->ret < 0) PARA_ERROR_LOG("%s\n", PARA_STRERROR(-t->ret)); - wng->eof = 1; } int main(int argc, char *argv[]) @@ -224,6 +226,7 @@ int main(int argc, char *argv[]) cwt.task.error_handler = cwt_error_handler; cwt.buf = sit.buf; cwt.loaded = &sit.loaded; + cwt.eof = &sit.eof; cwt.task.flags = PRE_EOF_IS_ERROR; register_task(&cwt.task);