audiod: Fix a bug in try_to_close_slot() for default config.
authorAndre Noll <maan@systemlinux.org>
Tue, 12 Jan 2010 00:01:34 +0000 (01:01 +0100)
committerAndre Noll <maan@systemlinux.org>
Tue, 12 Jan 2010 00:01:34 +0000 (01:01 +0100)
If the default writer is used because no --writer option was given,
a->num_writers is zero although we have one (the default) writer.
Handle this case correctly to avoid starting the receiver too early.

audiod.c

index d12b65e..a11835f 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -1061,9 +1061,14 @@ static bool try_to_close_slot(int slot_num)
        for (i = 0; i < a->num_filters; i++)
                if (s->fns && s->fns[i].task.error != -E_TASK_UNREGISTERED)
                        return false;
-       for (i = 0; i < a->num_writers; i++)
-               if (s->wns && s->wns[i].task.error != -E_TASK_UNREGISTERED)
+       if (a->num_writers > 0) {
+               for (i = 0; i < a->num_writers; i++)
+                       if (s->wns && s->wns[i].task.error != -E_TASK_UNREGISTERED)
+                               return false;
+       } else {
+               if (s->wns && s->wns[0].task.error != -E_TASK_UNREGISTERED)
                        return false;
+       }
        PARA_INFO_LOG("closing slot %d\n", slot_num);
        close_writers(s);
        _close_filters(s);