+ result->matches = i9e_complete_commands(ci->word, audiod_completers);
+}
+
+static void stat_completer(struct i9e_completion_info *ci,
+ struct i9e_completion_result *cr)
+{
+ char *sia[] = {STATUS_ITEM_ARRAY NULL};
+ char *opts[] = {"-p", NULL};
+
+ if (ci->word_num <= 2 && ci->word && ci->word[0] == '-')
+ i9e_complete_option(opts, ci, cr);
+ else
+ i9e_extract_completions(ci->word, sia, &cr->matches);
+}
+
+static void grab_completer(struct i9e_completion_info *ci,
+ struct i9e_completion_result *cr)
+{
+ char *opts[] = {"-ms", "-ms", "-ma", "-p=", "-n=", "-o", NULL};
+ i9e_complete_option(opts, ci, cr);
+}
+
+static struct i9e_completer audiod_completers[] = {
+ AUDIOD_COMPLETERS
+ {.name = NULL}
+};
+
+static void audioc_pre_select(struct sched *s, struct task *t)
+{
+ struct audioc_task *at = container_of(t, struct audioc_task, task);
+ int ret = btr_node_status(at->btrn, 0, BTR_NT_ROOT);
+
+ if (ret < 0)
+ sched_min_delay(s);
+ para_fd_set(at->fd, &s->rfds, &s->max_fileno);
+}
+
+static void audioc_post_select(struct sched *s, struct task *t)
+{
+ char *buf = NULL;
+ struct audioc_task *at = container_of(t, struct audioc_task, task);
+ int ret = btr_node_status(at->btrn, 0, BTR_NT_ROOT);
+
+ if (ret < 0)
+ goto out;
+ if (!FD_ISSET(at->fd, &s->rfds))
+ return;
+ buf = para_malloc(conf.bufsize_arg);
+ ret = recv_bin_buffer(at->fd, buf, conf.bufsize_arg);
+ PARA_DEBUG_LOG("recv: %d\n", ret);
+ if (ret == 0)
+ ret = -E_AUDIOC_EOF;
+ if (ret < 0)
+ goto out;
+ btr_add_output(buf, ret, at->btrn);
+ return;
+out:
+ if (ret < 0) {
+ free(buf);
+ btr_remove_node(at->btrn);
+ btr_free_node(at->btrn);
+ at->btrn = NULL;
+ close(at->fd);
+ }
+ t->error = ret;
+}