]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - play.c
task_register() conversion: write task
[paraslash.git] / play.c
diff --git a/play.c b/play.c
index 2dcc37ea2bf0954ccea2776c8dd410b85c9804b2..045f26038b46512f4eebfdf5bf80659c79f4fd87 100644 (file)
--- a/play.c
+++ b/play.c
@@ -247,7 +247,7 @@ static int get_playback_error(struct play_task *pt)
 
        if (err >= 0)
                return 0;
-       if (pt->fn.task.error >= 0)
+       if (pt->fn.task->error >= 0)
                return 0;
        if (pt->rn.task->error >= 0)
                return 0;
@@ -272,6 +272,7 @@ static int eof_cleanup(struct play_task *pt)
        w->free_config(pt->wn.conf);
        memset(&pt->wn, 0, sizeof(struct writer_node));
 
+       task_reap(&pt->fn.task);
        decoder->close(&pt->fn);
        btr_remove_node(&pt->fn.btrn);
        free(pt->fn.conf);
@@ -361,7 +362,7 @@ fail:
 static int load_file(struct play_task *pt)
 {
        const char *af;
-       char *tmp;
+       char *tmp, buf[20];
        int ret;
        struct filter *decoder;
 
@@ -371,7 +372,6 @@ static int load_file(struct play_task *pt)
                if (ret < 0)
                        return ret;
        } else {
-               char buf[20];
                pt->rn.btrn = new_recv_btrn(&pt->rn);
                sprintf(buf, "repos %lu", pt->start_chunk);
                ret = btr_exec_up(pt->rn.btrn, buf, &tmp);
@@ -390,9 +390,6 @@ static int load_file(struct play_task *pt)
                goto fail;
        pt->fn.filter_num = ret;
        decoder = filters + ret;
-       pt->fn.task.pre_select = decoder->pre_select;
-       pt->fn.task.post_select = decoder->post_select;
-       sprintf(pt->fn.task.status, "%s decoder", af);
        pt->fn.btrn = btr_new_node(&(struct btr_node_description)
                EMBRACE(.name = decoder->name, .parent = pt->rn.btrn,
                        .handler = decoder->execute, .context = &pt->fn));
@@ -410,7 +407,14 @@ static int load_file(struct play_task *pt)
                        .post_select = afh_recv->post_select,
                        .context = &pt->rn
                }, &sched);
-       register_task(&sched, &pt->fn.task);
+       sprintf(buf, "%s decoder", af);
+       pt->fn.task = task_register(
+               &(struct task_info) {
+                       .name = buf,
+                       .pre_select = decoder->pre_select,
+                       .post_select = decoder->post_select,
+                       .context = &pt->fn
+               }, &sched);
        register_writer_node(&pt->wn, pt->fn.btrn, &sched);
        return 1;
 fail: