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;
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);
}
}
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;