From: Andre Date: Mon, 29 May 2006 00:52:22 +0000 (+0200) Subject: audiod: clean up wng_event_handler() X-Git-Tag: v0.2.14~101^2~3 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=a9fff73b100933309af4e1b35d7ff5aa320f2c9b audiod: clean up wng_event_handler() 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(). --- diff --git a/audiod.c b/audiod.c index 36e826c0..df7c1e1b 100644 --- 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); } } }