From 0154e6eaacc45e4849e7a7929b064dc55b4f2a55 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 8 Jul 2019 18:23:22 +0200 Subject: [PATCH] small cleanups resample: remove unused index variable --- spa/plugins/alsa/alsa-source.c | 2 ++ spa/plugins/audioconvert/resample-native-impl.h | 10 +++------- spa/plugins/audioconvert/resample-native.h | 9 +++------ spa/plugins/audioconvert/resample-peaks.h | 2 +- src/daemon/command.c | 4 ++-- src/modules/module-adapter/adapter.c | 1 + 6 files changed, 12 insertions(+), 16 deletions(-) diff --git a/spa/plugins/alsa/alsa-source.c b/spa/plugins/alsa/alsa-source.c index 7d2778392..f085e10f2 100644 --- a/spa/plugins/alsa/alsa-source.c +++ b/spa/plugins/alsa/alsa-source.c @@ -592,6 +592,8 @@ impl_node_port_set_io(void *object, spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL); + spa_log_debug(this->log, NAME " %p: io %d %p %zd", this, id, data, size); + switch (id) { case SPA_IO_Buffers: this->io = data; diff --git a/spa/plugins/audioconvert/resample-native-impl.h b/spa/plugins/audioconvert/resample-native-impl.h index 3cb278e2e..422905ab6 100644 --- a/spa/plugins/audioconvert/resample-native-impl.h +++ b/spa/plugins/audioconvert/resample-native-impl.h @@ -38,7 +38,6 @@ struct native_data { uint32_t n_phases; uint32_t in_rate; uint32_t out_rate; - uint32_t index; uint32_t phase; uint32_t inc; uint32_t frac; @@ -66,7 +65,7 @@ DEFINE_RESAMPLER(copy,arch) \ if (r->channels == 0) \ return; \ \ - index = data->index; \ + index = 0; \ if (offs < olen && index + n_taps <= ilen) { \ uint32_t to_copy = SPA_MIN(olen - offs, \ ilen - (index + n_taps) + 1); \ @@ -80,7 +79,6 @@ DEFINE_RESAMPLER(copy,arch) \ } \ *in_len = index; \ *out_len = offs; \ - data->index = index; \ } #define MAKE_RESAMPLER_FULL(arch) \ @@ -99,7 +97,7 @@ DEFINE_RESAMPLER(full,arch) \ const float *s = src[c]; \ float *d = dst[c]; \ \ - index = data->index; \ + index = 0; \ phase = data->phase; \ \ for (o = offs; o < olen && index + n_taps <= ilen; o++) { \ @@ -118,7 +116,6 @@ DEFINE_RESAMPLER(full,arch) \ } \ *in_len = index; \ *out_len = o; \ - data->index = index; \ data->phase = phase; \ } @@ -139,7 +136,7 @@ DEFINE_RESAMPLER(inter,arch) \ const float *s = src[c]; \ float *d = dst[c]; \ \ - index = data->index; \ + index = 0; \ phase = data->phase; \ \ for (o = offs; o < olen && index + n_taps <= ilen; o++) { \ @@ -165,7 +162,6 @@ DEFINE_RESAMPLER(inter,arch) \ } \ *in_len = index; \ *out_len = o; \ - data->index = index; \ data->phase = phase; \ } diff --git a/spa/plugins/audioconvert/resample-native.h b/spa/plugins/audioconvert/resample-native.h index c8f15d6a7..c13332b6b 100644 --- a/spa/plugins/audioconvert/resample-native.h +++ b/spa/plugins/audioconvert/resample-native.h @@ -171,8 +171,8 @@ static void impl_native_process(struct resample *r, in = hist + refill; out = *out_len; data->func(r, (const void**)history, &in, dst, 0, &out); - spa_log_trace_fp(r->log, "native %p: in:%d/%d out %d/%d idx:%d hist:%d", - r, hist + refill, in, *out_len, out, data->index, hist); + spa_log_trace_fp(r->log, "native %p: in:%d/%d out %d/%d hist:%d", + r, hist + refill, in, *out_len, out, hist); } else { out = in = 0; } @@ -180,7 +180,6 @@ static void impl_native_process(struct resample *r, if (in >= hist) { /* we are past the history and can now work on the new * input data */ - data->index -= hist; in = *in_len; data->func(r, src, &in, dst, out, out_len); spa_log_trace_fp(r->log, "native %p: in:%d/%d out %d/%d", @@ -219,7 +218,6 @@ static void impl_native_process(struct resample *r, } } data->hist = remain; - data->index = 0; return; } @@ -228,7 +226,6 @@ static void impl_native_reset (struct resample *r) struct native_data *d = r->data; memset(d->hist_mem, 0, r->channels * sizeof(float) * d->n_taps * 2); d->hist = d->n_taps / 2; - d->index = 0; d->phase = 0; } @@ -279,7 +276,7 @@ static int impl_native_init(struct resample *r) 64); if (d == NULL) - return -ENOMEM; + return -errno; r->data = d; d->n_taps = n_taps; diff --git a/spa/plugins/audioconvert/resample-peaks.h b/spa/plugins/audioconvert/resample-peaks.h index f9ced5a95..28e3d87d5 100644 --- a/spa/plugins/audioconvert/resample-peaks.h +++ b/spa/plugins/audioconvert/resample-peaks.h @@ -112,7 +112,7 @@ static int impl_peaks_init(struct resample *r) r->reset = impl_peaks_reset; d = r->data = calloc(1, sizeof(struct peaks_data) * sizeof(float) * r->channels); if (r->data == NULL) - return -ENOMEM; + return -errno; d->i_count = d->o_count = 0; return 0; diff --git a/src/daemon/command.c b/src/daemon/command.c index 8f27a84e9..9081c9a9d 100644 --- a/src/daemon/command.c +++ b/src/daemon/command.c @@ -182,8 +182,8 @@ execute_command_module_load(struct pw_command *command, struct pw_core *core, ch module = pw_module_load(core, command->args[1], command->args[2], NULL, NULL, NULL); if (module == NULL) { - asprintf(err, "could not load module \"%s\"", command->args[1]); - return -ENOMEM; + asprintf(err, "could not load module \"%s\": %m", command->args[1]); + return -errno; } return 0; } diff --git a/src/modules/module-adapter/adapter.c b/src/modules/module-adapter/adapter.c index 50029e06f..a084b04e8 100644 --- a/src/modules/module-adapter/adapter.c +++ b/src/modules/module-adapter/adapter.c @@ -211,6 +211,7 @@ static void try_link_controls(struct impl *impl) if (!impl->use_converter) return; + pw_log_warn(NAME " %p: controls", impl); if ((res = spa_node_port_set_io(impl->slave_node, impl->direction, 0,