Add btr support to the oggdec filter.
[paraslash.git] / mp3dec_filter.c
index 7574504..9eed639 100644 (file)
@@ -216,7 +216,7 @@ static void mp3dec_post_select(__a_unused struct sched *s, struct task *t)
                return;
        if (need_bad_data_delay(pmd, len))
                return;
-       if (pmd->input_len_barrier != 0 && btr_no_parent(btrn)) {
+       if (len <= pmd->input_len_barrier && btr_no_parent(btrn)) {
                ret = -E_MP3DEC_EOF;
                goto err;
        }
@@ -316,6 +316,25 @@ err:
        return ret;
 }
 
+static int mp3dec_execute(struct btr_node *btrn, const char *cmd, char **result)
+{
+       struct filter_node *fn = btr_context(btrn);
+       struct private_mp3dec_data *pmd = fn->private_data;
+
+       if (!strcmp(cmd, "samplerate")) {
+               if (pmd->samplerate == 0)
+                       return -ERRNO_TO_PARA_ERROR(ENAVAIL);
+               *result = make_message("%u", pmd->samplerate);
+               return 1;
+       }
+       if (!strcmp(cmd, "channels")) {
+               if (pmd->channels == 0)
+                       return -ERRNO_TO_PARA_ERROR(ENAVAIL);
+               *result = make_message("%u", pmd->channels);
+               return 1;
+       }
+       return -ERRNO_TO_PARA_ERROR(ENOTSUP);
+}
 /**
  * The init function of the mp3dec filter.
  *
@@ -334,6 +353,7 @@ void mp3dec_filter_init(struct filter *f)
        f->parse_config = mp3dec_parse_config;
        f->pre_select = mp3dec_pre_select;
        f->post_select = mp3dec_post_select;
+       f->execute = mp3dec_execute;
        f->help = (struct ggo_help) {
                .short_help = mp3dec_filter_args_info_help,
                .detailed_help = mp3dec_filter_args_info_detailed_help