From: Andre Noll Date: Fri, 29 Dec 2017 13:50:28 +0000 (+0100) Subject: resample filter: Don't discard const. X-Git-Tag: v0.6.2~48^2 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=b48bca326fd7fc0484dd807ac1542269b3ab070f resample filter: Don't discard const. Newer versions of libsamplerate made the data_in pointer const. This causes the following warning: In file included from resample_filter.c:6:0: /usr/local/include/samplerate.h:177:6: note: expected 'float *' but argument is of type 'const float *' void src_short_to_float_array (const short *in, float *out, int len) ; ^ resample_filter.c:173:7: warning: passing argument 1 of 'free' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] In file included from para.h:11:0, from resample_filter.c:10: /usr/include/stdlib.h:460:13: note: expected 'void *' but argument is of type 'const float *' extern void free (void *__ptr) __THROW; The problem is that we first convert the input from int16 to float and use the data_in pointer as the target for the conversion. Fix this by introducing a temporary non-const variable for the converted input. --- diff --git a/resample_filter.c b/resample_filter.c index 1699ed2c..84a2ee70 100644 --- a/resample_filter.c +++ b/resample_filter.c @@ -166,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; @@ -177,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);