introduce input_eof and ouput_eof
[paraslash.git] / alsa_writer.c
index 3a2226cfad1dedd05b4e822f49c75b389fac76c3..f05dbbd0e3fdf3002de52e96c5ec63e95e1f41eb 100644 (file)
@@ -140,13 +140,13 @@ static void alsa_write_pre_select(struct sched *s, struct task *t)
        struct timeval diff;
 
        t->ret = 0;
-       if (wng->eof && *wng->loaded < pad->bytes_per_frame)
+       if (*wng->input_eof && *wng->loaded < pad->bytes_per_frame)
                return;
        t->ret = 1;
        if (*wng->loaded < pad->bytes_per_frame)
                return;
        if (tv_diff(&s->now, &pad->next_chunk, &diff) < 0) {
-               if (tv_diff(&s->timeout, &diff, NULL) < 0)
+               if (tv_diff(&s->timeout, &diff, NULL) > 0)
                        s->timeout = diff;
        } else {
                s->timeout.tv_sec = 0;
@@ -164,8 +164,11 @@ static void alsa_write_post_select(struct sched *s, struct task *t)
        unsigned char *data = (unsigned char*)wng->buf;
 
        t->ret = 0;
-       if (!frames)
+       if (!frames) {
+               if (*wng->input_eof)
+                       t->ret = *wng->loaded;
                return;
+       }
        if (tv_diff(&s->now, &pad->next_chunk, NULL) < 0)
                return;
 //     PARA_INFO_LOG("%zd frames\n", frames);