#define STDIN_ERRORS \
PARA_ERROR(STDIN_READ, "failed to read from stdin"), \
+ PARA_ERROR(STDIN_EOF, "end of file"), \
#define SCHED_ERRORS \
PARA_ERROR(WRITE_OVERRUN, "buffer overrun"), \
PARA_ERROR(PREMATURE_END, "premature end of audio file"), \
PARA_ERROR(NO_WAV_HEADER, "wave header not found"), \
+ PARA_ERROR(WAV_HEADER_SUCCESS, "successfully read wave header"), \
PARA_ERROR(NO_DELAY, "no initial delay"), \
+ PARA_ERROR(DELAY_TIMEOUT, "initial delay timeout"), \
#define ALSA_WRITER_ERRORS \
#define WRITE_COMMON_ERRORS \
PARA_ERROR(WRITE_COMMON_SYNTAX, "syntax error in write option"), \
+ PARA_ERROR(WNG_EOF, "wng: end of file"), \
#define AACDEC_ERRORS \
t->pre_select(s, t);
if (t->ret > 0 || !t->error_handler)
continue;
- if (t->ret < 0) {
- t->error_handler(t);
- goto again;
- }
- if (!(t->flags & PRE_EOF_IS_ERROR))
- continue;
- t->ret = -E_PRE_EOF;
t->error_handler(t);
goto again;
}
t->post_select(s, t);
if (t->ret > 0 || !t->error_handler)
continue;
- if (t->ret < 0) {
- t->error_handler(t);
- continue;
- }
- if (!(t->flags & POST_EOF_IS_ERROR))
- continue;
- t->ret = -E_POST_EOF;
t->error_handler(t);
}
}
void *register_task(struct task *t)
{
- PARA_INFO_LOG("registering task %p\n", t);
+ PARA_INFO_LOG("registering %s (%p)\n", t->status, t);
if (t->pre_select) {
PARA_DEBUG_LOG("pre_select: %p\n", &t->pre_select);
if (t->flags & PRE_ADD_TAIL)
void unregister_task(struct task *t)
{
- PARA_INFO_LOG("unregistering task %p\n", t);
+ PARA_INFO_LOG("unregistering %s (%p)\n", t->status, t);
if (t->pre_select)
list_del(&t->pre_select_node);
if (t->post_select)
cwt->sample_rate = a[24] + (a[25] << 8) + (a[26] << 16) + (a[27] << 24);
*cwt->loaded -= WAV_HEADER_LEN;
memmove(cwt->buf, cwt->buf + WAV_HEADER_LEN, *cwt->loaded);
- t->ret = 0;
+ t->ret = -E_WAV_HEADER_SUCCESS;
PARA_INFO_LOG("channels: %d, sample_rate: %d\n", cwt->channels, cwt->sample_rate);
}
struct initial_delay_task *idt = t->private_data;
struct timeval diff;
- PARA_ERROR_LOG("task %p, ret: %d\n", t, t->ret);
t->ret = -E_NO_DELAY;
if (!idt->start_time.tv_sec && !idt->start_time.tv_usec)
return;
- t->ret = 0; /* timeout */
+ t->ret = -E_DELAY_TIMEOUT;
if (tv_diff(&s->now, &idt->start_time, &diff) > 0)
return;
t->ret = 1;
if (ret < 0)
goto out;
wng->writer_nodes[i].writer = &writers[ret];
+ sprintf(wng->writer_nodes[i].task.status, "%s",
+ writer_names[ret]);
}
ret = 1;
out:
static void idt_error_handler(struct task *t)
{
- PARA_ERROR_LOG("task %p, ret: %d\n", t, t->ret);
int ret;
+
+ PARA_INFO_LOG("%s\n", PARA_STRERROR(-t->ret));
unregister_task(t);
wng->buf = sit.buf;
wng->loaded = &sit.loaded;
wng->eof = &sit.eof;
+ sprintf(wng->task.status, "%s", "writer node group");
ret = wng_open(wng);
if (ret < 0) {
PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
static void cwt_error_handler(struct task *t)
{
- PARA_ERROR_LOG("task %p, ret: %d\n", t, t->ret);
- if (t->ret < 0) {
+ if (t->ret != -E_NO_WAV_HEADER && t->ret != -E_WAV_HEADER_SUCCESS) {
PARA_ERROR_LOG("%s\n", PARA_STRERROR(-t->ret));
- if (t->ret != -E_NO_WAV_HEADER && t->ret != -E_PRE_EOF)
- exit(EXIT_FAILURE);
- if (t->ret == -E_PRE_EOF) {
- conf.channels_arg = cwt.channels;
- conf.sample_rate_arg = cwt.sample_rate;
- }
+ exit(EXIT_FAILURE);
}
+ PARA_INFO_LOG("%s\n", PARA_STRERROR(-t->ret));
unregister_task(t);
+ if (t->ret == -E_WAV_HEADER_SUCCESS) {
+ conf.channels_arg = cwt.channels;
+ conf.sample_rate_arg = cwt.sample_rate;
+ }
idt.task.pre_select = initial_delay_pre_select;
idt.task.private_data = &idt;
idt.task.error_handler = idt_error_handler;
- idt.task.flags = PRE_EOF_IS_ERROR;
+ sprintf(idt.task.status, "initial_delay");
register_task(&idt.task);
}
static void stdin_error_handler(struct task *t)
{
unregister_task(t);
- PARA_INFO_LOG("task %p, ret: %d\n", t, t->ret);
- if (t->ret < 0)
+ if (t->ret != -E_STDIN_EOF)
+ PARA_ERROR_LOG("%s\n", PARA_STRERROR(-t->ret));
+ else
PARA_ERROR_LOG("%s\n", PARA_STRERROR(-t->ret));
}
sit.task.pre_select = stdin_pre_select;
sit.task.post_select = stdin_post_select;
sit.task.error_handler = stdin_error_handler;
- sit.task.flags = POST_EOF_IS_ERROR;
sit.task.private_data = &sit;
+ sprintf(sit.task.status, "stdin reader");
register_task(&sit.task);
cwt.task.pre_select = check_wav_pre_select;
cwt.buf = sit.buf;
cwt.loaded = &sit.loaded;
cwt.eof = &sit.eof;
- cwt.task.flags = PRE_EOF_IS_ERROR;
+ sprintf(cwt.task.status, "check wav");
register_task(&cwt.task);
s.default_timeout.tv_sec = 1;
}
*g->loaded -= min_written;
if (!*g->loaded && *g->eof)
- t->ret = 0;
+ t->ret = -E_WNG_EOF;
else
t->ret = 1;
if (*g->loaded && min_written)
wn->task.pre_select = wn->writer->pre_select;
wn->task.post_select = wn->writer->post_select;
wn->task.private_data = wn;
- wn->task.flags = POST_EOF_IS_ERROR;
register_task(&wn->task);
}
register_task(&g->task);
{
struct writer_node_group *g = t->private_data;
- PARA_INFO_LOG("%p: ret = %d\n", t, t->ret);
+ PARA_INFO_LOG("%s\n", PARA_STRERROR(-t->ret));
unregister_task(t);
wng_close(g);
wng_destroy(g);
g->task.private_data = g;
g->task.post_select = wng_post_select;
g->task.error_handler = wng_error_handler;
- g->task.flags = POST_ADD_TAIL | POST_EOF_IS_ERROR;
+ g->task.flags = POST_ADD_TAIL;
return g;
}
else
default_writer = 1;
wng->writer_nodes[0].writer = &writers[default_writer];
+ sprintf(wng->writer_nodes[0].task.status, "%s",
+ writer_names[default_writer]);
PARA_INFO_LOG("using default writer: %s\n",
writer_names[default_writer]);
return wng;