mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
convert: refactor node_set_param functions
Move them to their own function to make the main function shorter. Also make sure we emit the new ports first and then the node info.
This commit is contained in:
parent
8dfa086c3c
commit
2420c3a8c8
2 changed files with 130 additions and 102 deletions
|
|
@ -472,10 +472,10 @@ static int init_port(struct impl *this, enum spa_direction direction, uint32_t p
|
|||
port->latency[SPA_DIRECTION_INPUT] = SPA_LATENCY_INFO(SPA_DIRECTION_INPUT);
|
||||
port->latency[SPA_DIRECTION_OUTPUT] = SPA_LATENCY_INFO(SPA_DIRECTION_OUTPUT);
|
||||
|
||||
port->info = SPA_PORT_INFO_INIT();
|
||||
port->info.change_mask = port->info_all = SPA_PORT_CHANGE_MASK_FLAGS |
|
||||
SPA_PORT_CHANGE_MASK_PROPS |
|
||||
SPA_PORT_CHANGE_MASK_PARAMS;
|
||||
port->info = SPA_PORT_INFO_INIT();
|
||||
port->info.flags = SPA_PORT_FLAG_NO_REF |
|
||||
SPA_PORT_FLAG_DYNAMIC_DATA;
|
||||
port->params[IDX_EnumFormat] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ);
|
||||
|
|
@ -788,6 +788,9 @@ static int reconfigure_mode(struct impl *this, enum spa_param_port_config_mode m
|
|||
init_port(this, direction, i, false, false, true);
|
||||
}
|
||||
|
||||
/* emit all port info first, then the node props and flags */
|
||||
emit_info(this, false);
|
||||
|
||||
this->info.change_mask |= SPA_NODE_CHANGE_MASK_FLAGS | SPA_NODE_CHANGE_MASK_PARAMS;
|
||||
this->info.flags &= ~SPA_NODE_FLAG_NEED_CONFIGURE;
|
||||
this->params[IDX_PortConfig].user++;
|
||||
|
|
@ -795,57 +798,69 @@ static int reconfigure_mode(struct impl *this, enum spa_param_port_config_mode m
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int impl_node_set_param(void *object, uint32_t id, uint32_t flags,
|
||||
const struct spa_pod *param)
|
||||
static int node_set_param_port_config(struct impl *this, uint32_t flags,
|
||||
const struct spa_pod *param)
|
||||
{
|
||||
struct impl *this = object;
|
||||
|
||||
spa_return_val_if_fail(this != NULL, -EINVAL);
|
||||
struct spa_video_info info = { 0, }, *infop = NULL;
|
||||
struct spa_pod *format = NULL;
|
||||
enum spa_direction direction;
|
||||
enum spa_param_port_config_mode mode;
|
||||
bool monitor = false, control = false;
|
||||
int res;
|
||||
|
||||
if (param == NULL)
|
||||
return 0;
|
||||
|
||||
switch (id) {
|
||||
case SPA_PARAM_PortConfig:
|
||||
{
|
||||
struct spa_video_info info = { 0, }, *infop = NULL;
|
||||
struct spa_pod *format = NULL;
|
||||
enum spa_direction direction;
|
||||
enum spa_param_port_config_mode mode;
|
||||
bool monitor = false, control = false;
|
||||
int res;
|
||||
if (spa_pod_parse_object(param,
|
||||
SPA_TYPE_OBJECT_ParamPortConfig, NULL,
|
||||
SPA_PARAM_PORT_CONFIG_direction, SPA_POD_Id(&direction),
|
||||
SPA_PARAM_PORT_CONFIG_mode, SPA_POD_Id(&mode),
|
||||
SPA_PARAM_PORT_CONFIG_monitor, SPA_POD_OPT_Bool(&monitor),
|
||||
SPA_PARAM_PORT_CONFIG_control, SPA_POD_OPT_Bool(&control),
|
||||
SPA_PARAM_PORT_CONFIG_format, SPA_POD_OPT_Pod(&format)) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
if (spa_pod_parse_object(param,
|
||||
SPA_TYPE_OBJECT_ParamPortConfig, NULL,
|
||||
SPA_PARAM_PORT_CONFIG_direction, SPA_POD_Id(&direction),
|
||||
SPA_PARAM_PORT_CONFIG_mode, SPA_POD_Id(&mode),
|
||||
SPA_PARAM_PORT_CONFIG_monitor, SPA_POD_OPT_Bool(&monitor),
|
||||
SPA_PARAM_PORT_CONFIG_control, SPA_POD_OPT_Bool(&control),
|
||||
SPA_PARAM_PORT_CONFIG_format, SPA_POD_OPT_Pod(&format)) < 0)
|
||||
if (format) {
|
||||
if (!spa_pod_is_object_type(format, SPA_TYPE_OBJECT_Format))
|
||||
return -EINVAL;
|
||||
|
||||
if (format) {
|
||||
if (!spa_pod_is_object_type(format, SPA_TYPE_OBJECT_Format))
|
||||
return -EINVAL;
|
||||
|
||||
if ((res = spa_format_video_parse(format, &info)) < 0)
|
||||
return res;
|
||||
|
||||
infop = &info;
|
||||
}
|
||||
|
||||
if ((res = reconfigure_mode(this, mode, direction, monitor, control, infop)) < 0)
|
||||
if ((res = spa_format_video_parse(format, &info)) < 0)
|
||||
return res;
|
||||
break;
|
||||
|
||||
infop = &info;
|
||||
}
|
||||
return reconfigure_mode(this, mode, direction, monitor, control, infop);
|
||||
}
|
||||
|
||||
static int node_set_param_props(struct impl *this, uint32_t flags,
|
||||
const struct spa_pod *param)
|
||||
{
|
||||
if (param == NULL)
|
||||
return 0;
|
||||
|
||||
apply_props(this, param);
|
||||
return 0;
|
||||
}
|
||||
static int impl_node_set_param(void *object, uint32_t id, uint32_t flags,
|
||||
const struct spa_pod *param)
|
||||
{
|
||||
struct impl *this = object;
|
||||
int res;
|
||||
|
||||
spa_return_val_if_fail(this != NULL, -EINVAL);
|
||||
|
||||
switch (id) {
|
||||
case SPA_PARAM_PortConfig:
|
||||
res = node_set_param_port_config(this, flags, param);
|
||||
break;
|
||||
case SPA_PARAM_Props:
|
||||
apply_props(this, param);
|
||||
res = node_set_param_props(this, flags, param);
|
||||
break;
|
||||
default:
|
||||
return -ENOENT;
|
||||
}
|
||||
emit_info(this, false);
|
||||
return 0;
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline void free_decoder(struct impl *this)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue