X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=resample_filter.c;h=bf28e975de2720f001be95ee06b269a1a8ecdd2c;hb=be5daec66f163725489f42d512659a8af5c3fd59;hp=72a1864eeafb69982cc1f0e49a1013eb81872341;hpb=1f12ea375358a0b30689e01efe82796ea4fcb14f;p=paraslash.git diff --git a/resample_filter.c b/resample_filter.c index 72a1864e..bf28e975 100644 --- a/resample_filter.c +++ b/resample_filter.c @@ -1,8 +1,4 @@ -/* - * Copyright (C) 2012 Andre Noll - * - * Licensed under the GPL v2. For licencing details see COPYING. - */ +/* Copyright (C) 2012 Andre Noll , see file COPYING. */ /** \file resample_filter.c A sample rate converter based on libsamplerate. */ @@ -55,7 +51,7 @@ static void resample_close(struct filter_node *fn) static void resample_open(struct filter_node *fn) { - struct resample_context *ctx = para_calloc(sizeof(*ctx)); + struct resample_context *ctx = zalloc(sizeof(*ctx)); struct btr_node *btrn = fn->btrn; struct wav_params wp; @@ -66,7 +62,7 @@ static void resample_open(struct filter_node *fn) btr_log_tree(btr_parent(btr_parent(btrn)), LL_INFO); } -static void resample_pre_select(struct sched *s, void *context) +static void resample_pre_monitor(struct sched *s, void *context) { struct filter_node *fn = context; struct resample_context *ctx = fn->private_data; @@ -74,7 +70,7 @@ static void resample_pre_select(struct sched *s, void *context) if (ret != 0) return sched_min_delay(s); - check_wav_pre_select(s, ctx->cwc); + check_wav_pre_monitor(s, ctx->cwc); } static int get_btr_val(const char *what, struct btr_node *btrn) @@ -159,6 +155,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; @@ -170,18 +167,19 @@ 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); - data.data_out = para_malloc(out_samples * sizeof(float)); + in_float = arr_alloc(num_samples, sizeof(float)); + src_short_to_float_array(in, in_float, num_samples); + data.data_in = in_float; + data.data_out = arr_alloc(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); return -E_LIBSAMPLERATE; } out_samples = data.output_frames_gen * ctx->channels; - out = para_malloc(out_samples * sizeof(short)); + out = arr_alloc(out_samples, sizeof(short)); src_float_to_short_array(data.data_out, out, out_samples); free(data.data_out); *result = out; @@ -189,7 +187,7 @@ static int resample_frames(int16_t *in, size_t num_frames, bool have_more, return data.input_frames_used; } -static int resample_post_select(__a_unused struct sched *s, void *context) +static int resample_post_monitor(__a_unused struct sched *s, void *context) { int ret; struct filter_node *fn = context; @@ -199,7 +197,7 @@ static int resample_post_select(__a_unused struct sched *s, void *context) size_t in_bytes, num_frames; bool have_more; - ret = check_wav_post_select(ctx->cwc); + ret = check_wav_post_monitor(ctx->cwc); if (ret < 0) goto out; ret = btr_node_status(btrn, fn->min_iqs, BTR_NT_INTERNAL); @@ -238,7 +236,7 @@ out: if (ret < 0) { btr_remove_node(&fn->btrn); /* This releases the check_wav btr node */ - check_wav_post_select(ctx->cwc); + check_wav_post_monitor(ctx->cwc); } return ret; } @@ -279,8 +277,8 @@ static void resample_teardown(__a_unused const struct lls_parse_result *lpr, const struct filter lsg_filter_cmd_com_resample_user_data = { .setup = resample_setup, .open = resample_open, - .pre_select = resample_pre_select, - .post_select = resample_post_select, + .pre_monitor = resample_pre_monitor, + .post_monitor = resample_post_monitor, .close = resample_close, .teardown = resample_teardown, .execute = resample_execute