From 634e759f12fed8c6005526bc55a27c1f6562fecb Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Wed, 11 Apr 2012 23:16:00 +0200 Subject: [PATCH] oggdec: Do not decode more than necessary. Currently the ogg vorbis decoder decodes at least one buffer per scheduler iteration and checks only then if its output queue is already full. This is bad for several reasons, increased memory footprint is one of them. This patch adds an additional check at the beginning of ogg_post_select() that causes the function to return early if the output queue is full. --- oggdec_filter.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/oggdec_filter.c b/oggdec_filter.c index 79716a36..77356f32 100644 --- a/oggdec_filter.c +++ b/oggdec_filter.c @@ -212,6 +212,8 @@ static void ogg_post_select(__a_unused struct sched *s, struct task *t) goto out; if (ret <= 0 && !pod->have_more) /* nothing to do */ goto out; + if (btr_get_output_queue_size(btrn) > OGGDEC_MAX_OUTPUT_SIZE) + return; if (!pod->vf) { if (ret <= 0) goto out; -- 2.30.2