policy-node: only set PortConfig when we find a format

This commit is contained in:
Wim Taymans 2020-01-28 15:38:35 +01:00
parent d2d1647634
commit b4c76ba78a

View file

@ -96,6 +96,7 @@ static int activate_node(struct node *node)
char buf[1024]; char buf[1024];
struct spa_pod_builder b = { 0, }; struct spa_pod_builder b = { 0, };
struct spa_pod *param; struct spa_pod *param;
bool have_format = false;
pw_log_debug(NAME" %p: node %p activate", impl, node); pw_log_debug(NAME" %p: node %p activate", impl, node);
@ -121,23 +122,28 @@ static int activate_node(struct node *node)
if (node->format.info.raw.channels < info.info.raw.channels) if (node->format.info.raw.channels < info.info.raw.channels)
node->format = info; node->format = info;
have_format = true;
} }
node->format.info.raw.rate = impl->sample_rate;
spa_pod_builder_init(&b, buf, sizeof(buf)); if (have_format) {
param = spa_format_audio_raw_build(&b, SPA_PARAM_Format, &node->format.info.raw); node->format.info.raw.rate = impl->sample_rate;
param = spa_pod_builder_add_object(&b,
SPA_TYPE_OBJECT_ParamPortConfig, SPA_PARAM_PortConfig,
SPA_PARAM_PORT_CONFIG_direction, SPA_POD_Id(node->direction),
SPA_PARAM_PORT_CONFIG_mode, SPA_POD_Id(SPA_PARAM_PORT_CONFIG_MODE_dsp),
SPA_PARAM_PORT_CONFIG_monitor, SPA_POD_Bool(true),
SPA_PARAM_PORT_CONFIG_format, SPA_POD_Pod(param));
if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG)) spa_pod_builder_init(&b, buf, sizeof(buf));
spa_debug_pod(2, NULL, param); param = spa_format_audio_raw_build(&b, SPA_PARAM_Format, &node->format.info.raw);
param = spa_pod_builder_add_object(&b,
SPA_TYPE_OBJECT_ParamPortConfig, SPA_PARAM_PortConfig,
SPA_PARAM_PORT_CONFIG_direction, SPA_POD_Id(node->direction),
SPA_PARAM_PORT_CONFIG_mode, SPA_POD_Id(SPA_PARAM_PORT_CONFIG_MODE_dsp),
SPA_PARAM_PORT_CONFIG_monitor, SPA_POD_Bool(true),
SPA_PARAM_PORT_CONFIG_format, SPA_POD_Pod(param));
pw_node_set_param((struct pw_node*)node->obj->obj.proxy, if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG))
SPA_PARAM_PortConfig, 0, param); spa_debug_pod(2, NULL, param);
pw_node_set_param((struct pw_node*)node->obj->obj.proxy,
SPA_PARAM_PortConfig, 0, param);
}
node->active = true; node->active = true;
return 0; return 0;