+
+static int wav_post_select(__a_unused struct sched *s, void *context)
+{
+ struct filter_node *fn = context;
+ struct btr_node *btrn = fn->btrn;
+ size_t iqs = btr_get_input_queue_size(btrn);
+ int ret;
+ char *header, *buf;
+ int32_t rate, ch;
+
+ if (iqs == 0) {
+ ret = -E_WAV_EOF;
+ if (btr_no_parent(btrn))
+ goto err;
+ return 0;
+ }
+ ret = btr_exec_up(btrn, "sample_rate", &buf);
+ if (ret < 0) {
+ ret = -E_WAV_BAD_FC;
+ goto err;
+ }
+ ret = para_atoi32(buf, &rate);
+ free(buf);
+ if (ret < 0)
+ goto err;
+ ret = btr_exec_up(btrn, "channels", &buf);
+ if (ret < 0) {
+ ret = -E_WAV_BAD_FC;
+ goto err;
+ }
+ ret = para_atoi32(buf, &ch);
+ free(buf);
+ if (ret < 0)
+ goto err;
+ header = para_malloc(WAV_HEADER_LEN);
+ make_wav_header(ch, rate, header);
+ btr_add_output(header, WAV_HEADER_LEN, btrn);
+ ret = -E_WAV_SUCCESS;
+err:
+ if (ret == -E_WAV_SUCCESS)
+ btr_splice_out_node(&fn->btrn);
+ else {
+ btr_remove_node(&fn->btrn);
+ PARA_ERROR_LOG("%s\n", para_strerror(-ret));
+ }
+ return ret;
+}
+
+const struct filter lsg_filter_cmd_com_wav_user_data = {
+ .close = wav_close,
+ .open = wav_open,
+ .pre_select = wav_pre_select,
+ .post_select = wav_post_select,
+};