diff --git a/meson.build b/meson.build index 1db426215..744553781 100644 --- a/meson.build +++ b/meson.build @@ -47,6 +47,7 @@ if cc.get_id() == 'gcc' '-Wimplicit-fallthrough', '-Wpointer-arith', '-Wformat-security', +# '-DSPA_DEBUG_MEMCPY', # '-DFASTPATH', language : 'c') endif diff --git a/spa/include/spa/debug/node.h b/spa/include/spa/debug/node.h index e83fff6f9..a4e5c2ac9 100644 --- a/spa/include/spa/debug/node.h +++ b/spa/include/spa/debug/node.h @@ -36,7 +36,7 @@ extern "C" { #define spa_debug(...) ({ fprintf(stderr, __VA_ARGS__);fputc('\n', stderr); }) #endif -int spa_debug_port_info(int indent, const struct spa_port_info *info) +static inline int spa_debug_port_info(int indent, const struct spa_port_info *info) { spa_debug("%*s" "struct spa_port_info %p:", indent, "", info); spa_debug("%*s" " flags: \t%08" PRIx64, indent, "", info->flags); diff --git a/spa/include/spa/utils/defs.h b/spa/include/spa/utils/defs.h index 2642ca97e..f445ffdf3 100644 --- a/spa/include/spa/utils/defs.h +++ b/spa/include/spa/utils/defs.h @@ -251,8 +251,15 @@ struct spa_param_info { __FILE__, __LINE__, __func__, (d), (s), (size_t)(n)); \ memcpy(d,s,n); \ }) +#define spa_memmove(d,s,n) \ +({ \ + fprintf(stderr, "%s:%u %s() memmove(%p, %p, %zd)\n", \ + __FILE__, __LINE__, __func__, (d), (s), (size_t)(n)); \ + memmove(d,s,n); \ +}) #else #define spa_memcpy(d,s,n) memcpy(d,s,n) +#define spa_memmove(d,s,n) memmove(d,s,n) #endif #ifdef __cplusplus diff --git a/spa/plugins/audioconvert/audioadapter.c b/spa/plugins/audioconvert/audioadapter.c index 2d775381e..213afe9e3 100644 --- a/spa/plugins/audioconvert/audioadapter.c +++ b/spa/plugins/audioconvert/audioadapter.c @@ -804,14 +804,13 @@ impl_node_port_use_buffers(void *object, if (direction != this->direction) port_id++; + spa_log_debug(this->log, NAME" %p: %d %d:%d", this, + n_buffers, direction, port_id); + if ((res = spa_node_port_use_buffers(this->target, direction, port_id, flags, buffers, n_buffers)) < 0) return res; - - spa_log_debug(this->log, NAME" %p: %d %d:%d", this, - n_buffers, direction, port_id); - if (n_buffers > 0 && this->use_converter) { if (port_id == 0) res = negotiate_buffers(this); diff --git a/spa/plugins/audioconvert/merger.c b/spa/plugins/audioconvert/merger.c index bcfe355bc..e706f9149 100644 --- a/spa/plugins/audioconvert/merger.c +++ b/spa/plugins/audioconvert/merger.c @@ -918,7 +918,7 @@ static inline int handle_monitor(struct impl *this, const void *data, int n_samp if (SPA_FLAG_IS_SET(dd->flags, SPA_DATA_FLAG_DYNAMIC)) dd->data = (void*)data; else - memcpy(dd->data, data, size); + spa_memcpy(dd->data, data, size); return res; } diff --git a/spa/plugins/audioconvert/resample-native-impl.h b/spa/plugins/audioconvert/resample-native-impl.h index 4654d1ea6..b856f9059 100644 --- a/spa/plugins/audioconvert/resample-native-impl.h +++ b/spa/plugins/audioconvert/resample-native-impl.h @@ -72,7 +72,7 @@ DEFINE_RESAMPLER(copy,arch) \ for (c = 0; c < r->channels; c++) { \ const float *s = src[c]; \ float *d = dst[c]; \ - memcpy(&d[offs], &s[index + n_taps2], \ + spa_memcpy(&d[offs], &s[index + n_taps2], \ to_copy * sizeof(float)); \ } \ index += to_copy; \ diff --git a/spa/plugins/audioconvert/resample-native.h b/spa/plugins/audioconvert/resample-native.h index b92bd55d3..02a8d41be 100644 --- a/spa/plugins/audioconvert/resample-native.h +++ b/spa/plugins/audioconvert/resample-native.h @@ -171,7 +171,7 @@ static void impl_native_process(struct resample *r, * we have less, refill the history. */ refill = SPA_MIN(*in_len, n_taps-1); for (c = 0; c < r->channels; c++) - memcpy(&history[c][hist], s[c], refill * sizeof(float)); + spa_memcpy(&history[c][hist], s[c], refill * sizeof(float)); if (hist + refill < n_taps) { /* not enough in the history, keep the input in @@ -206,7 +206,7 @@ static void impl_native_process(struct resample *r, /* not enough input data remaining for more output, * copy to history */ for (c = 0; c < r->channels; c++) - memcpy(history[c], &s[c][in], remain * sizeof(float)); + spa_memcpy(history[c], &s[c][in], remain * sizeof(float)); } else { /* we have enough input data remaining to produce * more output ask to resubmit. */ @@ -230,7 +230,7 @@ static void impl_native_process(struct resample *r, if (remain) { /* move history */ for (c = 0; c < r->channels; c++) - memmove(history[c], &history[c][in], remain * sizeof(float)); + spa_memmove(history[c], &history[c][in], remain * sizeof(float)); } spa_log_trace_fp(r->log, "native %p: in:%d remain:%d", r, in, remain); diff --git a/spa/plugins/jack/jack-sink.c b/spa/plugins/jack/jack-sink.c index 2a0d70471..773b34560 100644 --- a/spa/plugins/jack/jack-sink.c +++ b/spa/plugins/jack/jack-sink.c @@ -740,7 +740,7 @@ static int impl_node_process(void *object) b = &port->buffers[io->buffer_id]; src = &b->outbuf->datas[0]; - memcpy(dst, src->data, n_frames * port->stride); + spa_memcpy(dst, src->data, n_frames * port->stride); io->status = SPA_STATUS_NEED_DATA; diff --git a/spa/plugins/jack/jack-source.c b/spa/plugins/jack/jack-source.c index 1a427a9e2..529d436b7 100644 --- a/spa/plugins/jack/jack-source.c +++ b/spa/plugins/jack/jack-source.c @@ -758,7 +758,7 @@ static int impl_node_process(void *object) src = jack_port_get_buffer(port->jack_port, n_frames); d = &b->outbuf->datas[0]; - memcpy(d->data, src, n_frames * port->stride); + spa_memcpy(d->data, src, n_frames * port->stride); d->chunk->offset = 0; d->chunk->size = n_frames * port->stride; d->chunk->stride = port->stride; diff --git a/src/pipewire/link.c b/src/pipewire/link.c index 4709996ed..1526a8974 100644 --- a/src/pipewire/link.c +++ b/src/pipewire/link.c @@ -1100,7 +1100,7 @@ static void input_node_result(void *data, int seq, int res, uint32_t type, const { struct impl *impl = data; struct pw_port *port = impl->this.input; - pw_log_debug(NAME" %p: input port %p result seq:%d res:%d type:%u", + pw_log_trace(NAME" %p: input port %p result seq:%d res:%d type:%u", impl, port, seq, res, type); node_result(impl, port, seq, res, type, result); } @@ -1109,7 +1109,7 @@ static void output_node_result(void *data, int seq, int res, uint32_t type, cons { struct impl *impl = data; struct pw_port *port = impl->this.output; - pw_log_debug(NAME" %p: output port %p result seq:%d res:%d type:%u", + pw_log_trace(NAME" %p: output port %p result seq:%d res:%d type:%u", impl, port, seq, res, type); node_result(impl, port, seq, res, type, result); diff --git a/src/pipewire/node.c b/src/pipewire/node.c index 8b1366a86..24aab360b 100644 --- a/src/pipewire/node.c +++ b/src/pipewire/node.c @@ -1252,11 +1252,6 @@ static void do_reposition(struct pw_node *driver, struct pw_node *node) pw_log_debug(NAME" %p: update position:%lu", node, src->position); memcpy(dst, src, sizeof(struct spa_io_segment)); - dst->flags = src->flags; - dst->start = src->start; - dst->duration = src->duration; - dst->rate = src->rate; - dst->position = src->position; if (dst->start == 0) dst->start = a->position.clock.position - a->position.offset; diff --git a/src/pipewire/port.c b/src/pipewire/port.c index 0e10d60d2..bced75aea 100644 --- a/src/pipewire/port.c +++ b/src/pipewire/port.c @@ -225,8 +225,9 @@ int pw_port_init_mix(struct pw_port *port, struct pw_port_mix *mix) } } - pw_log_debug(NAME" %p: init mix %d %d.%d io %p: (%s)", port, - port->n_mix, port->port_id, mix->port.port_id, mix->io, spa_strerror(res)); + pw_log_debug(NAME" %p: init mix n_mix:%d %d.%d io:%p: (%s)", port, + port->n_mix, port->port_id, mix->port.port_id, + mix->io, spa_strerror(res)); return res; }