- struct filter_chain *fc = container_of(t, struct filter_chain, task);
- struct filter_node *fn;
- char *ib;
- size_t *loaded;
- int i, conv, conv_total = 0;
-
- if (fc->output_error && *fc->output_error < 0) {
- t->error = *fc->output_error;
- return;
- }
-again:
- ib = *fc->inbufp;
- loaded = fc->in_loaded;
- conv = 0;
- FOR_EACH_FILTER_NODE(fn, fc, i) {
- struct filter *f = filters + fn->filter_num;
- if (fn->loaded < fn->bufsize) {
- size_t size, old_fn_loaded = fn->loaded;
-// PARA_DEBUG_LOG("fc %p loaded: %zd, calling %s convert\n",
-// fc, *loaded, fn->filter->name);
- t->error = f->convert(ib, *loaded, fn);
- if (t->error < 0)
- return;
- size = t->error;
- call_callbacks(fn, ib, size, fn->buf + old_fn_loaded,
- fn->loaded - old_fn_loaded);
- *loaded -= size;
- conv += size;
- if (*loaded && size) {
-// PARA_DEBUG_LOG("moving %zd bytes in input "
-// "buffer for %s filter\n",
-// *loaded, fn->filter->name);
- memmove(ib, ib + size, *loaded);
- }
- }
- ib = fn->buf;
- loaded = &fn->loaded;
- }
- conv_total += conv;
-// PARA_DEBUG_LOG("eof (in/out/fc): %d/%d/%d out_loaded: %zd, "
-// "conv: %d, conv_total: %d\n", *fc->input_eof,
-// fc->output_eof? *fc->output_eof : -42,
-// fc->eof, *fc->out_loaded, conv, conv_total);
- if (conv)
- goto again;
- if (*fc->input_error >= 0)
- return;
- if (*fc->out_loaded)
- return;
- if (*fc->in_loaded && conv_total)
- return;
- t->error = -E_FC_EOF;