buffers: make alignment optional

Make the alignment parameter optional when negotiating buffers.
Default to a 16 bytes alignment and adjust for the max cpu
alignment.
Remove the useless align buffer parameter in plugins, we always
set it to 16 anyway.
This commit is contained in:
Wim Taymans 2022-01-03 12:32:26 +01:00
parent 30982775d9
commit 35cbe4e939
48 changed files with 54 additions and 91 deletions

View file

@ -46,6 +46,8 @@
#define SPA_LOG_TOPIC_DEFAULT log_topic
static struct spa_log_topic *log_topic = &SPA_LOG_TOPIC(0, "spa.audioadapter");
#define DEFAULT_ALIGN 16
#define MAX_PORTS SPA_AUDIO_MAX_CHANNELS
/** \cond */
@ -367,13 +369,15 @@ static int negotiate_buffers(struct impl *this)
follower_alloc = false;
}
align = DEFAULT_ALIGN;
if ((res = spa_pod_parse_object(param,
SPA_TYPE_OBJECT_ParamBuffers, NULL,
SPA_PARAM_BUFFERS_buffers, SPA_POD_Int(&buffers),
SPA_PARAM_BUFFERS_blocks, SPA_POD_Int(&blocks),
SPA_PARAM_BUFFERS_size, SPA_POD_Int(&size),
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(&stride),
SPA_PARAM_BUFFERS_align, SPA_POD_Int(&align))) < 0)
SPA_PARAM_BUFFERS_align, SPA_POD_OPT_Int(&align))) < 0)
return res;
spa_log_debug(this->log, "%p: buffers:%d, blocks:%d, size:%d, stride:%d align:%d %d:%d",

View file

@ -47,6 +47,8 @@
#define SPA_LOG_TOPIC_DEFAULT log_topic
static struct spa_log_topic *log_topic = &SPA_LOG_TOPIC(0, "spa.audioconvert");
#define DEFAULT_ALIGN 16
#define MAX_PORTS SPA_AUDIO_MAX_CHANNELS
struct buffer {
@ -361,12 +363,14 @@ static int negotiate_link_buffers(struct impl *this, struct link *link)
in_alloc = false;
}
align = DEFAULT_ALIGN;
if (spa_pod_parse_object(param,
SPA_TYPE_OBJECT_ParamBuffers, NULL,
SPA_PARAM_BUFFERS_buffers, SPA_POD_Int(&buffers),
SPA_PARAM_BUFFERS_blocks, SPA_POD_Int(&blocks),
SPA_PARAM_BUFFERS_size, SPA_POD_Int(&size),
SPA_PARAM_BUFFERS_align, SPA_POD_Int(&align)) < 0)
SPA_PARAM_BUFFERS_align, SPA_POD_OPT_Int(&align)) < 0)
return -EINVAL;
spa_log_debug(this->log, "%p: buffers %d, blocks %d, size %d, align %d %d:%d",

View file

@ -971,8 +971,7 @@ impl_node_port_enum_params(void *object, int seq,
DEFAULT_CONTROL_BUFFER_SIZE,
1024,
INT32_MAX),
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(1),
SPA_PARAM_BUFFERS_align, SPA_POD_Int(16));
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(1));
} else {
if (other->n_buffers > 0) {
buffers = other->n_buffers;
@ -990,8 +989,7 @@ impl_node_port_enum_params(void *object, int seq,
size * port->stride,
16 * port->stride,
INT32_MAX),
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(port->stride),
SPA_PARAM_BUFFERS_align, SPA_POD_Int(16));
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(port->stride));
}
break;
}

View file

@ -533,8 +533,7 @@ impl_node_port_enum_params(void *object, int seq,
SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int(2, 1, MAX_BUFFERS),
SPA_PARAM_BUFFERS_blocks, SPA_POD_Int(port->blocks),
SPA_PARAM_BUFFERS_size, SPA_POD_Int(other->size / other->stride * port->stride),
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(port->stride),
SPA_PARAM_BUFFERS_align, SPA_POD_Int(16));
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(port->stride));
} else {
@ -546,8 +545,7 @@ impl_node_port_enum_params(void *object, int seq,
MAX_SAMPLES * 2 * port->stride,
16 * port->stride,
INT32_MAX),
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(port->stride),
SPA_PARAM_BUFFERS_align, SPA_POD_Int(16));
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(port->stride));
}
break;
}

View file

@ -872,8 +872,7 @@ impl_node_port_enum_params(void *object, int seq,
MAX_SAMPLES * port->stride,
16 * port->stride,
INT32_MAX),
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(port->stride),
SPA_PARAM_BUFFERS_align, SPA_POD_Int(16));
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(port->stride));
break;
case SPA_PARAM_Meta:
switch (result.index) {

View file

@ -509,8 +509,7 @@ impl_node_port_enum_params(void *object, int seq,
size * port->stride,
16 * port->stride,
INT32_MAX),
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(port->stride),
SPA_PARAM_BUFFERS_align, SPA_POD_Int(16));
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(port->stride));
break;
}
case SPA_PARAM_Meta:

View file

@ -553,8 +553,7 @@ impl_node_port_enum_params(void *object, int seq,
MAX_SAMPLES * port->stride,
16 * port->stride,
MAX_SAMPLES * port->stride),
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(port->stride),
SPA_PARAM_BUFFERS_align, SPA_POD_Int(16));
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(port->stride));
break;
case SPA_PARAM_Meta:

View file

@ -461,8 +461,7 @@ impl_node_port_enum_params(void *object, int seq,
MAX_SAMPLES * port->stride,
16 * port->stride,
INT32_MAX),
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(port->stride),
SPA_PARAM_BUFFERS_align, SPA_POD_Int(16));
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(port->stride));
break;
}
case SPA_PARAM_Meta: