Simplify ggo makefile.
[paraslash.git] / prebuffer_filter.c
index a83eacc9d7e53f627985f6cfdfc86eccb588fa47..76ec7c73a411c292ebc62b2b9f857bd212562e60 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2009-2012 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
@@ -7,7 +7,6 @@
 /** \file prebuffer_filter.c Paraslash's prebuffering filter. */
 
 #include <regex.h>
-#include <stdbool.h>
 
 #include "para.h"
 #include "prebuffer_filter.cmdline.h"
@@ -49,19 +48,13 @@ static void prebuffer_pre_select(struct sched *s, struct task *t)
                tv_add(&tv, now, &ppd->barrier);
        }
        if (tv_diff(&ppd->barrier, now, &diff) < 0)
-               goto min_delay;
-       if (tv_diff(&diff, &s->timeout, NULL) < 0)
-               s->timeout = diff;
-       return;
-min_delay:
-       s->timeout.tv_sec = 0;
-       s->timeout.tv_usec = 1;
+               return sched_min_delay(s);
+       sched_request_timeout(&diff, s);
 }
 
 static void prebuffer_close(struct filter_node *fn)
 {
        free(fn->private_data);
-       free(fn->buf);
 }
 
 static void prebuffer_post_select(__a_unused struct sched *s, struct task *t)
@@ -80,7 +73,6 @@ static void prebuffer_post_select(__a_unused struct sched *s, struct task *t)
        if (iqs < conf->size_arg)
                return;
        btr_splice_out_node(btrn);
-       prebuffer_close(fn);
        t->error = -E_PREBUFFER_SUCCESS;
 }
 
@@ -90,7 +82,7 @@ static int prebuffer_parse_config(int argc, char **argv, void **config)
                = para_calloc(sizeof(*prebuffer_conf));
        int ret = -E_PREBUFFER_SYNTAX;
 
-       if (prebuffer_cmdline_parser(argc, argv, prebuffer_conf))
+       if (prebuffer_filter_cmdline_parser(argc, argv, prebuffer_conf))
                goto err;
        ret = -ERRNO_TO_PARA_ERROR(EINVAL);
        if (prebuffer_conf->duration_arg < 0)
@@ -112,13 +104,11 @@ static void prebuffer_open(struct filter_node *fn)
 
        ppd->conf = fn->conf;
        fn->private_data = ppd;
-       fn->bufsize = 8192; /* gets increased on demand */
-       fn->buf = para_malloc(fn->bufsize);
 }
 
 static void prebuffer_free_config(void *conf)
 {
-       prebuffer_cmdline_parser_free(conf);
+       prebuffer_filter_cmdline_parser_free(conf);
 }
 
 /**
@@ -130,7 +120,7 @@ void prebuffer_filter_init(struct filter *f)
 {
        struct prebuffer_filter_args_info dummy;
 
-       prebuffer_cmdline_parser_init(&dummy);
+       prebuffer_filter_cmdline_parser_init(&dummy);
        f->open = prebuffer_open;
        f->close = prebuffer_close;
        f->parse_config = prebuffer_parse_config;