mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
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:
parent
36d78c41a0
commit
92198e4d0d
11 changed files with 44 additions and 17 deletions
|
|
@ -48,6 +48,7 @@ static struct spa_log_topic *log_topic = &SPA_LOG_TOPIC(0, "spa.audiomixer");
|
|||
#define MAX_BUFFERS 64
|
||||
#define MAX_PORTS 128
|
||||
#define MAX_CHANNELS 64
|
||||
#define MAX_ALIGN MIX_OPS_MAX_ALIGN
|
||||
|
||||
#define PORT_DEFAULT_VOLUME 1.0
|
||||
#define PORT_DEFAULT_MUTE false
|
||||
|
|
@ -103,6 +104,7 @@ struct impl {
|
|||
struct spa_log *log;
|
||||
struct spa_cpu *cpu;
|
||||
uint32_t cpu_flags;
|
||||
uint32_t max_align;
|
||||
uint32_t quantum_limit;
|
||||
|
||||
struct mix_ops ops;
|
||||
|
|
@ -658,7 +660,7 @@ impl_node_port_use_buffers(void *object,
|
|||
buffers[i]);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!SPA_IS_ALIGNED(d[0].data, 16)) {
|
||||
if (!SPA_IS_ALIGNED(d[0].data, this->max_align)) {
|
||||
spa_log_warn(this->log, "%p: memory on buffer %d not aligned", this, i);
|
||||
}
|
||||
if (direction == SPA_DIRECTION_OUTPUT)
|
||||
|
|
@ -888,8 +890,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;
|
||||
|
|
|
|||
|
|
@ -125,6 +125,8 @@ void mix_##name##_##arch(struct mix_ops *ops, void * SPA_RESTRICT dst, \
|
|||
const void * SPA_RESTRICT src[], uint32_t n_src, \
|
||||
uint32_t n_samples) \
|
||||
|
||||
#define MIX_OPS_MAX_ALIGN 32
|
||||
|
||||
DEFINE_FUNCTION(s8, c);
|
||||
DEFINE_FUNCTION(u8, c);
|
||||
DEFINE_FUNCTION(s16, c);
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ static struct spa_log_topic *log_topic = &SPA_LOG_TOPIC(0, "spa.mixer-dsp");
|
|||
|
||||
#define MAX_BUFFERS 64
|
||||
#define MAX_PORTS 128
|
||||
#define MAX_ALIGN 64
|
||||
#define MAX_ALIGN MIX_OPS_MAX_ALIGN
|
||||
|
||||
#define PORT_DEFAULT_VOLUME 1.0
|
||||
#define PORT_DEFAULT_MUTE false
|
||||
|
|
@ -103,6 +103,7 @@ struct impl {
|
|||
struct spa_log *log;
|
||||
struct spa_cpu *cpu;
|
||||
uint32_t cpu_flags;
|
||||
uint32_t max_align;
|
||||
|
||||
uint32_t quantum_limit;
|
||||
|
||||
|
|
@ -604,7 +605,7 @@ impl_node_port_use_buffers(void *object,
|
|||
spa_log_error(this->log, "%p: invalid memory on buffer %d", this, i);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!SPA_IS_ALIGNED(d[0].data, 32)) {
|
||||
if (!SPA_IS_ALIGNED(d[0].data, this->max_align)) {
|
||||
spa_log_warn(this->log, "%p: memory on buffer %d not aligned", this, i);
|
||||
}
|
||||
if (direction == SPA_DIRECTION_OUTPUT)
|
||||
|
|
@ -831,8 +832,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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue