spa: clamp required alignment to cpu alignment

pipewire will allocate buffers aligned to the max alignment required for
the CPU. Take this into account and don't expect larger alignment.

Fixes a warning in mixer-dsp when the CPU max alignment is 16 but the
plugin requires 32 bytes alignment for the AVX2 path (that would never
be chosen on the CPU).

See #2074
This commit is contained in:
Wim Taymans 2022-01-28 11:49:06 +01:00
parent 36d78c41a0
commit 92198e4d0d
11 changed files with 44 additions and 17 deletions

View file

@ -55,7 +55,7 @@ static struct spa_log_topic *log_topic = &SPA_LOG_TOPIC(0, "spa.merger");
#define DEFAULT_RATE 48000
#define DEFAULT_CHANNELS 2
#define MAX_ALIGN 16
#define MAX_ALIGN FMT_OPS_MAX_ALIGN
#define MAX_BUFFERS 32
#define MAX_DATAS SPA_AUDIO_MAX_CHANNELS
#define MAX_PORTS SPA_AUDIO_MAX_CHANNELS
@ -146,6 +146,7 @@ struct impl {
struct spa_cpu *cpu;
uint32_t cpu_flags;
uint32_t max_align;
uint32_t quantum_limit;
struct spa_io_position *io_position;
@ -1265,7 +1266,7 @@ impl_node_port_use_buffers(void *object,
this, j, i, d[j].type, d[j].data);
return -EINVAL;
}
if (!SPA_IS_ALIGNED(d[j].data, MAX_ALIGN)) {
if (!SPA_IS_ALIGNED(d[j].data, this->max_align)) {
spa_log_warn(this->log, "%p: memory %d on buffer %d not aligned",
this, j, i);
}
@ -1576,8 +1577,10 @@ impl_init(const struct spa_handle_factory *factory,
spa_log_topic_init(this->log, log_topic);
this->cpu = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_CPU);
if (this->cpu)
if (this->cpu) {
this->cpu_flags = spa_cpu_get_flags(this->cpu);
this->max_align = SPA_MIN(MAX_ALIGN, spa_cpu_get_max_align(this->cpu));
}
for (i = 0; info && i < info->n_items; i++) {
const char *k = info->items[i].key;