audiod: Kill noisy debug message.
[paraslash.git] / stdout.c
index d167cd1..16e1646 100644 (file)
--- a/stdout.c
+++ b/stdout.c
@@ -48,19 +48,17 @@ static void stdout_pre_select(struct sched *s, struct task *t)
 static void stdout_pre_select_btr(struct sched *s, struct task *t)
 {
        struct stdout_task *sot = container_of(t, struct stdout_task, task);
-       size_t sz = btr_get_input_queue_size(sot->btrn);
+       int ret;
 
        t->error = 0;
        sot->check_fd = 0;
-       if (sz == 0) {
-               if (btr_no_parent(sot->btrn)) {
-                       s->timeout.tv_sec = 0;
-                       s->timeout.tv_usec = 1;
-               }
-               return;
+       ret = btr_node_status(sot->btrn, 0, BTR_NT_LEAF);
+       if (ret > 0)
+               para_fd_set(STDOUT_FILENO, &s->wfds, &s->max_fileno);
+       else if (ret < 0) {
+               s->timeout.tv_sec = 0;
+               s->timeout.tv_usec = 1;
        }
-       sot->check_fd = 1;
-       para_fd_set(STDOUT_FILENO, &s->wfds, &s->max_fileno);
 }
 
 /**
@@ -100,32 +98,29 @@ static void stdout_post_select(struct sched *s, struct task *t)
 static void stdout_post_select_btr(struct sched *s, struct task *t)
 {
        struct stdout_task *sot = container_of(t, struct stdout_task, task);
-       ssize_t ret;
-       size_t sz = btr_get_input_queue_size(sot->btrn);
+       struct btr_node *btrn = sot->btrn;
+       int ret;
        char *buf;
+       size_t sz;
 
        t->error = 0;
-       if (!sot->check_fd) {
-               if (sz == 0 && btr_no_parent(sot->btrn)) {
-                       t->error = -E_ORPHAN;
-                       goto err;
-               }
+       ret = btr_node_status(btrn, 0, BTR_NT_LEAF);
+       if (ret < 0)
+               goto err;
+       if (ret == 0)
                return;
-       }
        if (!FD_ISSET(STDOUT_FILENO, &s->wfds))
                return;
-       sz = btr_next_buffer(sot->btrn, &buf);
-       if (sz == 0)
-               return;
+       sz = btr_next_buffer(btrn, &buf);
+       assert(sz > 0);
        ret = write_nonblock(STDOUT_FILENO, buf, sz, 0);
-       if (ret < 0) {
-               t->error = -ERRNO_TO_PARA_ERROR(errno);
+       if (ret < 0)
                goto err;
-       }
-       btr_consume(sot->btrn, ret);
+       btr_consume(btrn, ret);
        return;
 err:
-       btr_del_node(sot->btrn);
+       btr_remove_node(btrn);
+       t->error = ret;
 }
 /**
  * Initialize a stdout task structure with default values.