videoadapter: sync with audioadapter

This commit is contained in:
Wim Taymans 2024-09-06 17:35:34 +02:00
parent 4d2cdd6da3
commit 2762b8d98f

View file

@ -140,6 +140,9 @@ static int convert_enum_port_config(struct impl *this,
struct spa_pod *f1, *f2 = NULL; struct spa_pod *f1, *f2 = NULL;
int res; int res;
if (this->convert == NULL)
return 0;
f1 = spa_pod_builder_add_object(builder, f1 = spa_pod_builder_add_object(builder,
SPA_TYPE_OBJECT_ParamPortConfig, id, SPA_TYPE_OBJECT_ParamPortConfig, id,
SPA_PARAM_PORT_CONFIG_direction, SPA_POD_Id(this->direction)); SPA_PARAM_PORT_CONFIG_direction, SPA_POD_Id(this->direction));
@ -183,8 +186,6 @@ next:
switch (id) { switch (id) {
case SPA_PARAM_EnumPortConfig: case SPA_PARAM_EnumPortConfig:
if (this->convert == NULL)
return 0;
return convert_enum_port_config(this, seq, id, start, num, filter, &b.b); return convert_enum_port_config(this, seq, id, start, num, filter, &b.b);
case SPA_PARAM_PortConfig: case SPA_PARAM_PortConfig:
if (this->passthrough) { if (this->passthrough) {
@ -202,8 +203,6 @@ next:
return 0; return 0;
} }
} else { } else {
if (this->convert == NULL)
return 0;
return convert_enum_port_config(this, seq, id, start, num, filter, &b.b); return convert_enum_port_config(this, seq, id, start, num, filter, &b.b);
} }
break; break;
@ -248,9 +247,6 @@ static int link_io(struct impl *this)
struct spa_io_rate_match *rate_match; struct spa_io_rate_match *rate_match;
size_t rate_match_size; size_t rate_match_size;
if (this->convert == NULL)
return 0;
spa_log_debug(this->log, "%p: controls", this); spa_log_debug(this->log, "%p: controls", this);
spa_zero(this->io_rate_match); spa_zero(this->io_rate_match);
@ -612,9 +608,6 @@ static int recalc_latency(struct impl *this, struct spa_node *src, enum spa_dire
if (this->target == this->follower) if (this->target == this->follower)
return 0; return 0;
if (dst == NULL)
return 0;
while (true) { while (true) {
spa_pod_builder_init(&b, buffer, sizeof(buffer)); spa_pod_builder_init(&b, buffer, sizeof(buffer));
if ((res = spa_node_port_enum_params_sync(src, if ((res = spa_node_port_enum_params_sync(src,
@ -652,9 +645,6 @@ static int recalc_tag(struct impl *this, struct spa_node *src, enum spa_directio
if (this->target == this->follower) if (this->target == this->follower)
return 0; return 0;
if (dst == NULL)
return 0;
spa_pod_dynamic_builder_init(&b, buffer, sizeof(buffer), 2048); spa_pod_dynamic_builder_init(&b, buffer, sizeof(buffer), 2048);
spa_pod_builder_get_state(&b.b, &state); spa_pod_builder_get_state(&b.b, &state);
@ -686,6 +676,9 @@ static int reconfigure_mode(struct impl *this, enum spa_param_port_config_mode m
spa_log_debug(this->log, "%p: passthrough mode %d", this, passthrough); spa_log_debug(this->log, "%p: passthrough mode %d", this, passthrough);
if (!passthrough && this->convert == NULL)
return -ENOTSUP;
if (this->passthrough != passthrough) { if (this->passthrough != passthrough) {
if (passthrough) { if (passthrough) {
/* remove converter split/merge ports */ /* remove converter split/merge ports */
@ -793,8 +786,6 @@ static int impl_node_set_param(void *object, uint32_t id, uint32_t flags,
break; break;
case SPA_PARAM_PORT_CONFIG_MODE_convert: case SPA_PARAM_PORT_CONFIG_MODE_convert:
case SPA_PARAM_PORT_CONFIG_MODE_dsp: case SPA_PARAM_PORT_CONFIG_MODE_dsp:
if (this->convert == NULL)
return -ENOTSUP;
if ((res = reconfigure_mode(this, mode, dir, NULL)) < 0) if ((res = reconfigure_mode(this, mode, dir, NULL)) < 0)
return res; return res;
break; break;
@ -1125,7 +1116,7 @@ static void follower_convert_port_info(void *data,
this->convert_port_flags = info->flags; this->convert_port_flags = info->flags;
if (this->convert && info->change_mask & SPA_PORT_CHANGE_MASK_PARAMS) { if (info->change_mask & SPA_PORT_CHANGE_MASK_PARAMS) {
for (i = 0; i < info->n_params; i++) { for (i = 0; i < info->n_params; i++) {
uint32_t idx; uint32_t idx;
@ -1832,7 +1823,7 @@ static int load_plugin_from(struct impl *this, const struct spa_dict *info,
{ {
struct spa_handle *hnd_convert = NULL; struct spa_handle *hnd_convert = NULL;
void *iface_conv = NULL; void *iface_conv = NULL;
hnd_convert = spa_plugin_loader_load(this->ploader, convertname, NULL); hnd_convert = spa_plugin_loader_load(this->ploader, convertname, info);
if (!hnd_convert) if (!hnd_convert)
return -EINVAL; return -EINVAL;
@ -1958,11 +1949,18 @@ impl_init(const struct spa_handle_factory *factory,
&impl_node, this); &impl_node, this);
ret = load_converter(this, info); ret = load_converter(this, info);
spa_log_debug(this->log, "%p: loaded converter %s, hnd %p, convert %p", this, spa_log_info(this->log, "%p: loaded converter %s, hnd %p, convert %p", this,
this->convertname, this->hnd_convert, this->convert); this->convertname, this->hnd_convert, this->convert);
if (ret < 0) if (ret < 0)
return ret; return ret;
this->target = this->convert;
if (this->convert == NULL) {
this->target = this->follower;
this->passthrough = true;
} else {
this->target = this->convert;
this->passthrough = false;
}
this->info_all = SPA_NODE_CHANGE_MASK_FLAGS | this->info_all = SPA_NODE_CHANGE_MASK_FLAGS |
SPA_NODE_CHANGE_MASK_PROPS | SPA_NODE_CHANGE_MASK_PROPS |
@ -2001,7 +1999,6 @@ impl_init(const struct spa_handle_factory *factory,
} else { } else {
reconfigure_mode(this, SPA_PARAM_PORT_CONFIG_MODE_passthrough, this->direction, NULL); reconfigure_mode(this, SPA_PARAM_PORT_CONFIG_MODE_passthrough, this->direction, NULL);
} }
link_io(this); link_io(this);
return 0; return 0;