Convert filters to lopsub.
[paraslash.git] / play.c
diff --git a/play.c b/play.c
index 330c8b2..ca584b9 100644 (file)
--- a/play.c
+++ b/play.c
@@ -296,7 +296,7 @@ static int get_playback_error(struct play_task *pt)
 static int eof_cleanup(struct play_task *pt)
 {
        struct writer *w = writers + DEFAULT_WRITER;
-       const struct filter *decoder = filter_get(pt->fn.filter_num);
+       const struct filter *decoder;
        int ret;
 
        ret = get_playback_error(pt);
@@ -309,6 +309,7 @@ static int eof_cleanup(struct play_task *pt)
        w->free_config(pt->wn.conf);
        memset(&pt->wn, 0, sizeof(struct writer_node));
 
+       decoder = filter_get(pt->fn.filter_num);
        task_reap(&pt->fn.task);
        if (decoder->close)
                decoder->close(&pt->fn);
@@ -410,6 +411,7 @@ static int load_file(struct play_task *pt)
        char *tmp, buf[20];
        int ret;
        const struct filter *decoder;
+       static struct lls_parse_result *filter_lpr;
 
        btr_remove_node(&pt->rn.btrn);
        if (!pt->rn.receiver || pt->next_file != pt->current_file) {
@@ -429,16 +431,17 @@ static int load_file(struct play_task *pt)
        /* set up decoding filter */
        af = audio_format_name(pt->audio_format_num);
        tmp = make_message("%sdec", af);
-       PARA_INFO_LOG("decoder: %s\n", tmp);
-       ret = check_filter_arg(tmp, &pt->fn.conf);
+       ret = filter_setup(tmp, &pt->fn.conf, &filter_lpr);
        freep(&tmp);
        if (ret < 0)
                goto fail;
        pt->fn.filter_num = ret;
+       pt->fn.lpr = filter_lpr;
        decoder = filter_get(ret);
        pt->fn.btrn = btr_new_node(&(struct btr_node_description)
-               EMBRACE(.name = decoder->name, .parent = pt->rn.btrn,
-                       .handler = decoder->execute, .context = &pt->fn));
+               EMBRACE(.name = filter_name(pt->fn.filter_num),
+                       .parent = pt->rn.btrn, .handler = decoder->execute,
+                       .context = &pt->fn));
        if (decoder->open)
                decoder->open(&pt->fn);
        PARA_INFO_LOG("buffer tree:\n");
@@ -1313,7 +1316,6 @@ int main(int argc, char *argv[])
 
        /* needed this early to make help work */
        recv_init();
-       filter_init();
        writer_init();
 
        sched.default_timeout.tv_sec = 5;