+/** Suspend decoding if output queue size is larger than that. */
+#define OGGDEC_MAX_OUTPUT_SIZE (96 * 1024)
+
+/**
+ * Allocate chunks of this size and produce at most one chunk of output per
+ * ->post_select() invocation. If the buffer could only be filled partially
+ * due to insufficient input being available, it is shrunk to the real output
+ * size and the resized buffer is fed into the output queue.
+ */
+#define OGGDEC_OUTPUT_CHUNK_SIZE (32 * 1024)
+
+static void ogg_pre_select(struct sched *s, void *context)
+{
+ struct filter_node *fn = context;
+ struct private_oggdec_data *pod = fn->private_data;
+ struct btr_node *btrn = fn->btrn;
+ int ret;
+
+ ret = btr_node_status(btrn, fn->min_iqs, BTR_NT_INTERNAL);
+ if (ret != 0)
+ return sched_min_delay(s);
+ if (!pod->have_more)
+ return;
+ if (btr_get_output_queue_size(btrn) > OGGDEC_MAX_OUTPUT_SIZE)
+ return;
+ sched_min_delay(s);
+}
+
+static int ogg_post_select(__a_unused struct sched *s, void *context)