mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-16 08:56:45 -05:00
Add PortConfig parameter
Add a new PortConfig parameter to configure ports of elements that are marked with the SPA_NODE_FLAG_*_PORT_CONFIG. This is used to configure the operation of the audioconver/audioadapter nodes and how it should convert the internal format. We want to use the Profile parameter only for cases where there is an enumeration of values, like with device configuration. Add unit tests for audioconvert and adapter to check if they handle PortConfig correctly. Make the media session use the PortConfig to dynamically configure the device nodes. Remove audio-dsp, it is not used anymore and can/should be implemented with a simple audioconvert spa node now and some PortConfig.
This commit is contained in:
parent
acdfed0d04
commit
f41720e7db
29 changed files with 1693 additions and 1300 deletions
|
|
@ -132,9 +132,9 @@ static int can_convert(const struct spa_audio_info *info1, const struct spa_audi
|
|||
{
|
||||
if (info1->info.raw.channels != info2->info.raw.channels ||
|
||||
info1->info.raw.rate != info2->info.raw.rate) {
|
||||
return -EINVAL;
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int setup_convert(struct impl *this)
|
||||
|
|
@ -165,7 +165,7 @@ static int setup_convert(struct impl *this)
|
|||
outformat.info.raw.channels,
|
||||
outformat.info.raw.rate);
|
||||
|
||||
if (can_convert(&informat, &outformat) < 0)
|
||||
if (!can_convert(&informat, &outformat))
|
||||
return -EINVAL;
|
||||
|
||||
for (i = 0; i < informat.info.raw.channels; i++) {
|
||||
|
|
@ -555,7 +555,7 @@ static int port_set_format(void *object,
|
|||
{
|
||||
struct impl *this = object;
|
||||
struct port *port, *other;
|
||||
int res = 0;
|
||||
int res;
|
||||
|
||||
port = GET_PORT(this, direction, port_id);
|
||||
other = GET_PORT(this, SPA_DIRECTION_REVERSE(direction), port_id);
|
||||
|
|
@ -584,7 +584,7 @@ static int port_set_format(void *object,
|
|||
spa_log_info(this->log, NAME "%p: %d %d %d %d", this,
|
||||
info.info.raw.channels, other->format.info.raw.channels,
|
||||
info.info.raw.rate, other->format.info.raw.rate);
|
||||
if (can_convert(&info, &other->format) < 0)
|
||||
if (!can_convert(&info, &other->format))
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
|
|
@ -602,10 +602,11 @@ static int port_set_format(void *object,
|
|||
port->format = info;
|
||||
|
||||
if (other->have_format && port->have_format)
|
||||
res = setup_convert(this);
|
||||
if ((res = setup_convert(this)) < 0)
|
||||
return res;
|
||||
|
||||
spa_log_debug(this->log, NAME " %p: set format on port %d %d %d",
|
||||
this, port_id, res, port->stride);
|
||||
spa_log_debug(this->log, NAME " %p: set format on port %d:%d res:%d stride:%d",
|
||||
this, direction, port_id, res, port->stride);
|
||||
}
|
||||
if (port->have_format) {
|
||||
port->params[3] = SPA_PARAM_INFO(SPA_PARAM_Format, SPA_PARAM_INFO_READWRITE);
|
||||
|
|
@ -614,7 +615,7 @@ static int port_set_format(void *object,
|
|||
port->params[3] = SPA_PARAM_INFO(SPA_PARAM_Format, SPA_PARAM_INFO_WRITE);
|
||||
port->params[4] = SPA_PARAM_INFO(SPA_PARAM_Buffers, 0);
|
||||
}
|
||||
return res;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -623,10 +624,14 @@ impl_node_port_set_param(void *object,
|
|||
uint32_t id, uint32_t flags,
|
||||
const struct spa_pod *param)
|
||||
{
|
||||
spa_return_val_if_fail(object != NULL, -EINVAL);
|
||||
struct impl *this = object;
|
||||
|
||||
spa_return_val_if_fail(object != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(CHECK_PORT(object, direction, port_id), -EINVAL);
|
||||
|
||||
spa_log_debug(this->log, NAME " %p: set param %u on port %d:%d %p",
|
||||
this, id, direction, port_id, param);
|
||||
|
||||
switch (id) {
|
||||
case SPA_PARAM_Format:
|
||||
return port_set_format(object, direction, port_id, flags, param);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue