X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=prebuffer_filter.c;h=ad2373767a8b8df5793472b795ac3d5b85327b55;hp=8ca1630d8112242ee65b3feb63e2883ffdac7f86;hb=HEAD;hpb=1f12ea375358a0b30689e01efe82796ea4fcb14f diff --git a/prebuffer_filter.c b/prebuffer_filter.c index 8ca1630d..28b71010 100644 --- a/prebuffer_filter.c +++ b/prebuffer_filter.c @@ -1,8 +1,4 @@ -/* - * Copyright (C) 2009 Andre Noll - * - * Licensed under the GPL v2. For licencing details see COPYING. - */ +/* Copyright (C) 2009 Andre Noll , see file COPYING. */ /** \file prebuffer_filter.c Paraslash's prebuffering filter. */ @@ -26,7 +22,7 @@ struct private_prebuffer_data { struct timeval barrier; }; -static void prebuffer_pre_select(struct sched *s, void *context) +static void prebuffer_pre_monitor(struct sched *s, void *context) { struct filter_node *fn = context; struct btr_node *btrn = fn->btrn; @@ -54,14 +50,21 @@ static void prebuffer_close(struct filter_node *fn) free(fn->private_data); } -static int prebuffer_post_select(__a_unused struct sched *s, void *context) +static int prebuffer_post_monitor(__a_unused struct sched *s, void *context) { struct filter_node *fn = context; struct btr_node *btrn = fn->btrn; size_t iqs = btr_get_input_queue_size(btrn); struct private_prebuffer_data *ppd = fn->private_data; uint32_t size = FILTER_CMD_OPT_UINT32_VAL(PREBUFFER, SIZE, fn->lpr); + int ret; + ret = task_get_notification(fn->task); + if (ret < 0) + goto fail; + ret = btr_node_status(btrn, size, BTR_NT_INTERNAL); + if (ret < 0) + goto fail; if (ppd->barrier.tv_sec == 0) return 0; if (tv_diff(now, &ppd->barrier, NULL) < 0) @@ -70,17 +73,20 @@ static int prebuffer_post_select(__a_unused struct sched *s, void *context) return 0; btr_splice_out_node(&fn->btrn); return -E_PREBUFFER_SUCCESS; +fail: + btr_remove_node(&fn->btrn); + return ret; } static void prebuffer_open(struct filter_node *fn) { - struct private_prebuffer_data *ppd = para_calloc(sizeof(*ppd)); + struct private_prebuffer_data *ppd = zalloc(sizeof(*ppd)); fn->private_data = ppd; } const struct filter lsg_filter_cmd_com_prebuffer_user_data = { .open = prebuffer_open, .close = prebuffer_close, - .pre_select = prebuffer_pre_select, - .post_select = prebuffer_post_select, + .pre_monitor = prebuffer_pre_monitor, + .post_monitor = prebuffer_post_monitor, };