]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - resample_filter.c
resample filter: Don't discard const.
[paraslash.git] / resample_filter.c
index ef8a70116618abf1404735442e761fc0cc74eab3..84a2ee700aae4c2d4dcbe50a186ccbcf54d0cdce 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012-2014 Andre Noll <maan@tuebingen.mpg.de>
+ * Copyright (C) 2012 Andre Noll <maan@tuebingen.mpg.de>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
@@ -128,13 +128,7 @@ static int resample_init(struct filter_node *fn)
        int ret, converter;
        struct resample_context *ctx = fn->private_data;
        struct resample_filter_args_info *conf = fn->conf;
-       struct btr_node *btrn = fn->btrn;
 
-       ret = -E_RESAMPLE_EOF;
-       if (btr_no_parent(btrn))
-               return ret;
-       if (btr_get_input_queue_size(btrn) == 0)
-               return 0;
        ret = resample_set_params(fn);
        if (ret < 0)
                return ret;
@@ -172,6 +166,7 @@ static int resample_frames(int16_t *in, size_t num_frames, bool have_more,
                size_t *result_frames)
 {
        int ret, num_samples, out_samples;
+       float *in_float;
        int16_t *out;
        SRC_DATA data;
 
@@ -183,11 +178,12 @@ static int resample_frames(int16_t *in, size_t num_frames, bool have_more,
        data.output_frames = num_frames * ctx->ratio + 1;
        out_samples = data.output_frames * ctx->channels;
 
-       data.data_in = para_malloc(num_samples * sizeof(float));
-       src_short_to_float_array(in, data.data_in, num_samples);
+       in_float = para_malloc(num_samples * sizeof(float));
+       src_short_to_float_array(in, in_float, num_samples);
+       data.data_in = in_float;
        data.data_out = para_malloc(out_samples * sizeof(float));
        ret = src_process(ctx->src_state, &data);
-       free(data.data_in);
+       free(in_float);
        if (ret != 0) {
                PARA_ERROR_LOG("%s\n", src_strerror(ret));
                free(data.data_out);
@@ -216,14 +212,14 @@ static int resample_post_select(__a_unused struct sched *s, void *context)
        ret = check_wav_post_select(ctx->cwc);
        if (ret < 0)
                goto out;
+       ret = btr_node_status(btrn, fn->min_iqs, BTR_NT_INTERNAL);
+       if (ret <= 0)
+               goto out;
        if (!ctx->src_state) {
                ret = resample_init(fn);
                if (ret <= 0)
                        goto out;
        }
-       ret = btr_node_status(btrn, fn->min_iqs, BTR_NT_INTERNAL);
-       if (ret <= 0)
-               goto out;
        if (ctx->source_sample_rate == conf->dest_sample_rate_arg) {
                /*
                 * No resampling necessary. We do not splice ourselves out