+static void oss_post_select(__a_unused struct sched *s,
+ struct task *t)
+{
+ struct writer_node *wn = container_of(t, struct writer_node, task);
+ struct oss_write_args_info *conf = wn->conf;
+ struct private_oss_write_data *powd = wn->private_data;
+ struct btr_node *btrn = wn->btrn;
+ size_t frames, bytes;
+ int ret = btr_node_status(btrn, wn->min_iqs, BTR_NT_LEAF);
+ char *data;
+
+ if (ret < 0)
+ goto out;
+ if (ret == 0)
+ return;
+ if (powd->fd < 0) {
+ int32_t rate, ch;
+ ret = -1;
+ if (!conf->samplerate_given) /* config option trumps btr_exec */
+ ret = get_btr_samplerate(wn->btrn, &rate);
+ if (ret < 0)
+ rate = conf->samplerate_arg;
+ ret = -1;
+ if (!conf->channels_given)
+ ret = get_btr_channels(wn->btrn, &ch);
+ if (ret < 0)
+ ch = conf->channels_arg;
+ ret = oss_init(wn, rate, ch);
+ if (ret < 0)
+ goto out;
+ return;
+ }
+ bytes = btr_next_buffer(btrn, &data);
+ frames = bytes / powd->bytes_per_frame;
+ if (!frames) { /* eof and less than a single frame available */
+ ret = -E_OSS_EOF;
+ goto out;
+ }
+ ret = 0;
+ if (!FD_ISSET(powd->fd, &s->wfds))
+ goto out;
+ ret = write_nonblock(powd->fd, data, frames * powd->bytes_per_frame, 0);
+ if (ret < 0)
+ goto out;
+ btr_consume(btrn, ret);
+ ret = 0;
+out:
+ t->error = ret;
+ if (ret < 0)
+ btr_remove_node(btrn);
+}
+
+static int oss_open(struct writer_node *wn)
+{
+ struct private_oss_write_data *powd;
+
+ powd = para_calloc(sizeof(*powd));
+ wn->private_data = powd;
+ powd->fd = -1;
+ return 1;
+}
+