X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=audiod.c;h=2bda0f69b4fc047e81f191f690682ecdb3b52db5;hb=5ec0d9ef2189e22b3ee80f661196b6ae0593a525;hp=9bb40e073b885c88216054d322c5cf4dd950e23e;hpb=810761a3cdf3f75dd8e07a5d903793048c36df1d;p=paraslash.git diff --git a/audiod.c b/audiod.c index 9bb40e07..2bda0f69 100644 --- a/audiod.c +++ b/audiod.c @@ -381,13 +381,28 @@ static void close_filters(struct slot_info *s) if (!fn) continue; f = filters + fn->filter_num; - f->close(fn); + if (f->close) + f->close(fn); btr_free_node(fn->btrn); } free(s->fns); s->fns = NULL; } +/* + * Whenever a task commits suicide by returning from post_select with t->error + * < 0, it also removes its btr node. We do exactly that to kill a running + * task. Note that the scheduler checks t->error also _before_ each pre/post + * select call, so the victim will never be scheduled again. + */ +static void kill_btrn(struct btr_node *btrn, struct task *t, int error) +{ + if (t->error < 0) + return; + t->error = error; + btr_remove_node(btrn); +} + static void kill_all_decoders(int error) { int i, j; @@ -400,12 +415,13 @@ static void kill_all_decoders(int error) a = afi + s->format; if (s->wns) for (j = 0; j < a->num_writers; j++) - s->wns[j].task.error = error; + kill_btrn(s->wns[j].btrn, &s->wns[j].task, error); if (s->fns) for (j = 0; j < a->num_writers; j++) - s->fns[j].task.error = error; + kill_btrn(s->fns[j].btrn, &s->wns[j].task, error); if (s->receiver_node) - s->receiver_node->task.error = error; + kill_btrn(s->receiver_node->btrn, &s->receiver_node->task, + error); } } @@ -463,7 +479,11 @@ static void open_filters(struct slot_info *s) fn->conf = a->filter_conf[i]; fn->task.pre_select = f->pre_select; fn->task.post_select = f->post_select; - fn->btrn = btr_new_node(f->name, parent, f->execute, fn); + + fn->btrn = btr_new_node(&(struct btr_node_description) + EMBRACE(.name = f->name, .parent = parent, + .handler = f->execute, .context = fn)); + f->open(fn); register_task(&fn->task); parent = fn->btrn; @@ -516,7 +536,8 @@ static int open_receiver(int format) rn = s->receiver_node; rn->receiver = r; rn->conf = a->receiver_conf; - rn->btrn = btr_new_node(r->name, NULL, NULL, rn); + rn->btrn = btr_new_node(&(struct btr_node_description) + EMBRACE(.name = r->name, .context = rn)); ret = r->open(rn); if (ret < 0) { btr_free_node(rn->btrn); @@ -1090,9 +1111,9 @@ static void start_stop_decoders(struct sched *s) FOR_EACH_SLOT(i) if (try_to_close_slot(i)) sched_min_delay(s); -// if (audiod_status != AUDIOD_ON || -// !(stat_task->vss_status & VSS_STATUS_FLAG_PLAYING)) -// return kill_all_decoders(-E_NOT_PLAYING); + if (audiod_status != AUDIOD_ON || + !(stat_task->vss_status & VSS_STATUS_FLAG_PLAYING)) + return kill_all_decoders(-E_NOT_PLAYING); ret = open_current_receiver(s); if (ret < 0) return;