struct check_wav_task {
char *buf;
size_t *loaded;
+ int *eof;
unsigned channels;
unsigned sample_rate;
struct task task;
/**
* 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)
{
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;
ret = 1;
out:
if (ret > 0) {
- wng->eof = &sit.eof;
return wng;
}
free(wng);
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));
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);