spa: add port config group name

Make a portconfig group name. All ports from the same group have the
same port.group property and can be configured with the corresponding
PortConfig.
This commit is contained in:
Wim Taymans 2024-06-26 10:15:35 +02:00
parent 4eed79ee81
commit cf72a5945b
3 changed files with 25 additions and 5 deletions

View file

@ -39,6 +39,7 @@ static const struct spa_type_info spa_type_param_port_config[] = {
{ SPA_PARAM_PORT_CONFIG_monitor, SPA_TYPE_Bool, SPA_TYPE_INFO_PARAM_PORT_CONFIG_BASE "monitor", NULL }, { SPA_PARAM_PORT_CONFIG_monitor, SPA_TYPE_Bool, SPA_TYPE_INFO_PARAM_PORT_CONFIG_BASE "monitor", NULL },
{ SPA_PARAM_PORT_CONFIG_control, SPA_TYPE_Bool, SPA_TYPE_INFO_PARAM_PORT_CONFIG_BASE "control", NULL }, { SPA_PARAM_PORT_CONFIG_control, SPA_TYPE_Bool, SPA_TYPE_INFO_PARAM_PORT_CONFIG_BASE "control", NULL },
{ SPA_PARAM_PORT_CONFIG_format, SPA_TYPE_OBJECT_Format, SPA_TYPE_INFO_PARAM_PORT_CONFIG_BASE "format", NULL }, { SPA_PARAM_PORT_CONFIG_format, SPA_TYPE_OBJECT_Format, SPA_TYPE_INFO_PARAM_PORT_CONFIG_BASE "format", NULL },
{ SPA_PARAM_PORT_CONFIG_group, SPA_TYPE_String, SPA_TYPE_INFO_PARAM_PORT_CONFIG_BASE "group", NULL },
{ 0, 0, NULL, NULL }, { 0, 0, NULL, NULL },
}; };

View file

@ -33,6 +33,7 @@ enum spa_param_port_config {
SPA_PARAM_PORT_CONFIG_monitor, /**< (Bool) enable monitor output ports on input ports */ SPA_PARAM_PORT_CONFIG_monitor, /**< (Bool) enable monitor output ports on input ports */
SPA_PARAM_PORT_CONFIG_control, /**< (Bool) enable control ports */ SPA_PARAM_PORT_CONFIG_control, /**< (Bool) enable control ports */
SPA_PARAM_PORT_CONFIG_format, /**< (Object) format filter */ SPA_PARAM_PORT_CONFIG_format, /**< (Object) format filter */
SPA_PARAM_PORT_CONFIG_group, /**< (String) the port group name */
}; };
/** /**

View file

@ -508,8 +508,10 @@ static int node_param_enum_port_config(struct impl *this, uint32_t id, uint32_t
case 0 ... 1: case 0 ... 1:
{ {
struct dir *dir = &this->dir[index]; struct dir *dir = &this->dir[index];
*param = spa_pod_builder_add_object(b, struct spa_pod_frame f[1];
SPA_TYPE_OBJECT_ParamPortConfig, id,
spa_pod_builder_push_object(b, &f[0], SPA_TYPE_OBJECT_ParamPortConfig, id);
spa_pod_builder_add(b,
SPA_PARAM_PORT_CONFIG_direction, SPA_POD_Id(dir->direction), SPA_PARAM_PORT_CONFIG_direction, SPA_POD_Id(dir->direction),
SPA_PARAM_PORT_CONFIG_mode, SPA_POD_CHOICE_ENUM_Id(4, SPA_PARAM_PORT_CONFIG_mode, SPA_POD_CHOICE_ENUM_Id(4,
SPA_PARAM_PORT_CONFIG_MODE_none, SPA_PARAM_PORT_CONFIG_MODE_none,
@ -517,7 +519,14 @@ static int node_param_enum_port_config(struct impl *this, uint32_t id, uint32_t
SPA_PARAM_PORT_CONFIG_MODE_dsp, SPA_PARAM_PORT_CONFIG_MODE_dsp,
SPA_PARAM_PORT_CONFIG_MODE_convert), SPA_PARAM_PORT_CONFIG_MODE_convert),
SPA_PARAM_PORT_CONFIG_monitor, SPA_POD_CHOICE_Bool(false), SPA_PARAM_PORT_CONFIG_monitor, SPA_POD_CHOICE_Bool(false),
SPA_PARAM_PORT_CONFIG_control, SPA_POD_CHOICE_Bool(false)); SPA_PARAM_PORT_CONFIG_control, SPA_POD_CHOICE_Bool(false),
0);
if (this->group_name[0]) {
spa_pod_builder_add(b,
SPA_PARAM_PORT_CONFIG_group, SPA_POD_String(this->group_name),
0);
}
*param = spa_pod_builder_pop(b, &f[0]);
break; break;
} }
default: default:
@ -542,7 +551,11 @@ static int node_param_port_config(struct impl *this, uint32_t id, uint32_t index
SPA_PARAM_PORT_CONFIG_monitor, SPA_POD_Bool(this->monitor), SPA_PARAM_PORT_CONFIG_monitor, SPA_POD_Bool(this->monitor),
SPA_PARAM_PORT_CONFIG_control, SPA_POD_Bool(dir->control), SPA_PARAM_PORT_CONFIG_control, SPA_POD_Bool(dir->control),
0); 0);
if (this->group_name[0]) {
spa_pod_builder_add(b,
SPA_PARAM_PORT_CONFIG_group, SPA_POD_String(this->group_name),
0);
}
if (dir->have_format) { if (dir->have_format) {
spa_pod_builder_prop(b, SPA_PARAM_PORT_CONFIG_format, 0); spa_pod_builder_prop(b, SPA_PARAM_PORT_CONFIG_format, 0);
spa_format_audio_raw_build(b, id, &dir->format.info.raw); spa_format_audio_raw_build(b, id, &dir->format.info.raw);
@ -2037,6 +2050,7 @@ static int node_set_param_port_config(struct impl *this, uint32_t flags,
{ {
struct spa_audio_info info = { 0, }, *infop = NULL; struct spa_audio_info info = { 0, }, *infop = NULL;
struct spa_pod *format = NULL; struct spa_pod *format = NULL;
const char *group = NULL;
enum spa_direction direction; enum spa_direction direction;
enum spa_param_port_config_mode mode; enum spa_param_port_config_mode mode;
bool monitor = false, control = false; bool monitor = false, control = false;
@ -2051,9 +2065,13 @@ static int node_set_param_port_config(struct impl *this, uint32_t flags,
SPA_PARAM_PORT_CONFIG_mode, SPA_POD_Id(&mode), SPA_PARAM_PORT_CONFIG_mode, SPA_POD_Id(&mode),
SPA_PARAM_PORT_CONFIG_monitor, SPA_POD_OPT_Bool(&monitor), SPA_PARAM_PORT_CONFIG_monitor, SPA_POD_OPT_Bool(&monitor),
SPA_PARAM_PORT_CONFIG_control, SPA_POD_OPT_Bool(&control), SPA_PARAM_PORT_CONFIG_control, SPA_POD_OPT_Bool(&control),
SPA_PARAM_PORT_CONFIG_format, SPA_POD_OPT_Pod(&format)) < 0) SPA_PARAM_PORT_CONFIG_format, SPA_POD_OPT_Pod(&format),
SPA_PARAM_PORT_CONFIG_group, SPA_POD_OPT_String(&group)) < 0)
return -EINVAL; return -EINVAL;
if (group != NULL && this->group_name[0] && !spa_streq(group, this->group_name))
return -ENOENT;
if (format) { if (format) {
if (!spa_pod_is_object_type(format, SPA_TYPE_OBJECT_Format)) if (!spa_pod_is_object_type(format, SPA_TYPE_OBJECT_Format))
return -EINVAL; return -EINVAL;