X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=oggdec_filter.c;h=f41150f2638c62d4dd48fc23f9705f1dcf94ac4d;hp=32ffdef97462a9bf3a3509a25b865f69ed8fe8c5;hb=63abcd1b2f6de6ce53d82962f5a2100c5a57e5d3;hpb=4e5c01fe757de01edfc6aee72697d6765ae0e1a9 diff --git a/oggdec_filter.c b/oggdec_filter.c index 32ffdef9..f41150f2 100644 --- a/oggdec_filter.c +++ b/oggdec_filter.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2011 Andre Noll + * Copyright (C) 2005-2013 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -8,7 +8,6 @@ #include #include -#include #include "para.h" #include "list.h" @@ -175,6 +174,7 @@ out: pod->converted = 0; fn->min_iqs = 0; pod->vf = vf; + pod->have_more = true; } return ret; } @@ -199,7 +199,7 @@ static void ogg_pre_select(struct sched *s, struct task *t) sched_min_delay(s); } -static void ogg_post_select(__a_unused struct sched *s, struct task *t) +static int ogg_post_select(__a_unused struct sched *s, struct task *t) { struct filter_node *fn = container_of(t, struct filter_node, task); struct private_oggdec_data *pod = fn->private_data; @@ -208,10 +208,16 @@ static void ogg_post_select(__a_unused struct sched *s, struct task *t) char *buf; ret = btr_node_status(btrn, fn->min_iqs, BTR_NT_INTERNAL); - if (ret < 0 && ret != -E_BTR_EOF) /* fatal error */ - goto out; - if (ret <= 0 && !pod->have_more) /* nothing to do */ + if (ret < 0) { + if (ret != -E_BTR_EOF) /* fatal error */ + goto out; + if (fn->min_iqs == 0 && !pod->have_more) /* EOF */ + goto out; + /* last ov_read() returned OV_HOLE */ + } else if (ret == 0 && !pod->have_more) /* nothing to do */ goto out; + if (btr_get_output_queue_size(btrn) > OGGDEC_MAX_OUTPUT_SIZE) + return 0; if (!pod->vf) { if (ret <= 0) goto out; @@ -239,19 +245,21 @@ static void ogg_post_select(__a_unused struct sched *s, struct task *t) have = 0; } pod->have_more = (ret > 0); - if (have > 0) + if (have > 0) { + if (have < OGGDEC_OUTPUT_CHUNK_SIZE) + buf = para_realloc(buf, have); btr_add_output(buf, have, btrn); - else + } else free(buf); if (ret == OV_HOLE) /* avoid buffer underruns */ fn->min_iqs = 9000; if (ret >= 0 || ret == OV_HOLE) - return; + return 0; ret = -E_OGGDEC_BADLINK; out: - t->error = ret; if (ret < 0) - btr_remove_node(btrn); + btr_remove_node(&fn->btrn); + return ret; } /**