]> git.tue.mpg.de Git - paraslash.git/commitdiff
audiod: clean up wng_event_handler()
authorAndre <maan@p133.(none)>
Mon, 29 May 2006 00:52:22 +0000 (02:52 +0200)
committerAndre <maan@p133.(none)>
Mon, 29 May 2006 00:52:22 +0000 (02:52 +0200)
It should only unregister the wng task. closing is done from
close_decoder_if_idle(), an ugly name. Rename this function to
try_to_close_slot().

audiod.c

index 36e826c02f5740b1294f4296eee43a6b2b110148..df7c1e1b4969d84591b8e24993cfb55cfcd999c7 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -654,21 +654,11 @@ static struct filter_node *find_filter_node(int slot_num, int format, int filter
 
 static void wng_event_handler(struct task *t)
 {
-       struct writer_node_group *g = t->private_data;
-       int i;
-
        PARA_INFO_LOG("%s\n", PARA_STRERROR(-t->ret));
        unregister_task(t);
-       FOR_EACH_SLOT(i) {
-               if (slot[i].wng != g)
-                       continue;
-               wng_close(g);
-               wng_destroy(g);
-               slot[i].wng = NULL;
-       }
 }
 
-static void open_writer(int slot_num)
+static void open_writers(int slot_num)
 {
        int ret, i;
        struct slot_info *s = &slot[slot_num];
@@ -891,18 +881,21 @@ static void check_timeouts(void)
        }
 }
 
-static void close_decoder_if_idle(int slot_num)
+static void try_to_close_slot(int slot_num)
 {
        struct slot_info *s = &slot[slot_num];
 
        if (s->format < 0)
                return;
-       if (!s->fc)
+       if (s->receiver_node && !s->receiver_node->eof)
+               return;
+       if (s->fc && !s->fc->eof)
                return;
-       if (s->wng)
+       if (s->wng && !s->wng->eof)
                return;
-       PARA_INFO_LOG("closing all filters in slot %d (filter_chain %p)\n",
-               slot_num, s->fc);
+       PARA_INFO_LOG("closing slot %d \n", slot_num);
+       wng_close(s->wng);
+       wng_destroy(s->wng);
        close_filters(s->fc);
        free(s->fc);
        close_receiver(slot_num);
@@ -922,13 +915,13 @@ static void audiod_pre_select(struct sched *s, __a_unused struct task *t)
        FOR_EACH_SLOT(i) {
                struct receiver_node *rn;
 
-               close_decoder_if_idle(i);
+               try_to_close_slot(i);
                if (slot[i].format < 0)
                        continue;
                rn = slot[i].receiver_node;
                if (rn && rn->loaded && !slot[i].wng) {
                        open_filters(i);
-                       open_writer(i);
+                       open_writers(i);
                }
        }
 }