filter.c: Register tasks in proper order
authorAndre Noll <maan@systemlinux.org>
Thu, 1 Mar 2007 19:42:32 +0000 (20:42 +0100)
committerAndre Noll <maan@systemlinux.org>
Thu, 1 Mar 2007 19:42:32 +0000 (20:42 +0100)
The order is important as it determines the order in which
the pre_select functions are going to be called by the scheduler.

In the previous code, the scheduler called stdin->pre_select _before_
filter_chain->pre_select() which gave rise to the following scenario
(note that there's no filter_chain->post_select()):

stdin->pre_select(): set stdin for reading
filter_chain->pre_select(): nothing to do
stdin->post_select(): read buffer
stdin->pre_select(): do _not_ set stdin for reading as stdin buffer is full

For para_filter, after the last there are no fds set which causes the
scheduler to use the default timeout of 1s. This had the effect that
decoding of aac files started only after a few seconds.

With the roles of interchanged tasks the scenario is as follows:

filter_chain->pre_select(): nothing to do
stdin->pre_select(): set stdin for reading
stdin->post_select(): read buffer
filter_chain->pre_select(): convert buffer
stdin->pre_select(): set stdin _again_ as stdin buffer is not full

Alternative fix might be to use filter_pre_select() also for post_select.

filter.c

index d1f8853..ee08f28 100644 (file)
--- a/filter.c
+++ b/filter.c
@@ -168,9 +168,9 @@ int main(int argc, char *argv[])
        sot->loaded = fc->out_loaded;
        sot->input_eof = &fc->eof;
 
-       register_task(&sot->task);
-       register_task(&fc->task);
        register_task(&sit->task);
+       register_task(&fc->task);
+       register_task(&sot->task);
        s.default_timeout.tv_sec = 1;
        s.default_timeout.tv_usec = 0;
        ret = sched(&s);