convert/adapter: enable control port if input direction

This commit is contained in:
Julian Bouzas
2020-02-12 12:02:12 -05:00
parent 2439cab55f
commit 16cdac6dd6
2 changed files with 12 additions and 1 deletions

View File

@@ -49,6 +49,7 @@ on_proxy_enum_format_done (WpProxy *proxy, GAsyncResult *res,
uint8_t buf[1024];
struct spa_pod_builder pod_builder = SPA_POD_BUILDER_INIT(buf, sizeof(buf));
struct spa_pod *param;
gboolean control;
formats = wp_proxy_enum_params_collect_finish (proxy, res, &error);
if (error) {
@@ -90,17 +91,22 @@ on_proxy_enum_format_done (WpProxy *proxy, GAsyncResult *res,
self->format.format = SPA_AUDIO_FORMAT_F32P;
self->format.rate = 48000;
/* Only enable control port for input streams */
control = direction == PW_DIRECTION_INPUT;
if (self->convert) {
param = spa_pod_builder_add_object(&pod_builder,
SPA_TYPE_OBJECT_ParamPortConfig, SPA_PARAM_PortConfig,
SPA_PARAM_PORT_CONFIG_direction, SPA_POD_Id(direction),
SPA_PARAM_PORT_CONFIG_mode, SPA_POD_Id(SPA_PARAM_PORT_CONFIG_MODE_convert));
SPA_PARAM_PORT_CONFIG_mode, SPA_POD_Id(SPA_PARAM_PORT_CONFIG_MODE_convert),
SPA_PARAM_PORT_CONFIG_control, SPA_POD_Bool(control));
} else {
param = spa_format_audio_raw_build(&pod_builder, SPA_PARAM_Format, &self->format);
param = spa_pod_builder_add_object(&pod_builder,
SPA_TYPE_OBJECT_ParamPortConfig, SPA_PARAM_PortConfig,
SPA_PARAM_PORT_CONFIG_direction, SPA_POD_Id(direction),
SPA_PARAM_PORT_CONFIG_mode, SPA_POD_Id(SPA_PARAM_PORT_CONFIG_MODE_dsp),
SPA_PARAM_PORT_CONFIG_control, SPA_POD_Bool(control),
SPA_PARAM_PORT_CONFIG_format, SPA_POD_Pod(param));
}

View File

@@ -117,6 +117,7 @@ on_audio_convert_core_done (WpCore *core, GAsyncResult *res,
struct spa_pod_builder pod_builder = SPA_POD_BUILDER_INIT(buf, sizeof(buf));
struct spa_pod *format;
struct spa_pod *param;
gboolean control;
wp_core_sync_finish (core, res, &error);
if (error) {
@@ -131,6 +132,9 @@ on_audio_convert_core_done (WpCore *core, GAsyncResult *res,
format = spa_format_audio_raw_build(&pod_builder, SPA_PARAM_Format,
&self->format);
/* Only enable control port for input streams */
control = direction == PW_DIRECTION_INPUT;
/* Configure audioconvert to be both merger and splitter; this means it will
have an equal number of input and output ports and just passthrough the
same format, but with altered volume.
@@ -147,6 +151,7 @@ on_audio_convert_core_done (WpCore *core, GAsyncResult *res,
SPA_TYPE_OBJECT_ParamPortConfig, SPA_PARAM_PortConfig,
SPA_PARAM_PORT_CONFIG_direction, SPA_POD_Id(direction),
SPA_PARAM_PORT_CONFIG_mode, SPA_POD_Id(SPA_PARAM_PORT_CONFIG_MODE_dsp),
SPA_PARAM_PORT_CONFIG_control, SPA_POD_Bool(control),
SPA_PARAM_PORT_CONFIG_format, SPA_POD_Pod(format));
wp_audio_stream_set_port_config (WP_AUDIO_STREAM (self), param);
wp_audio_stream_finish_port_config (WP_AUDIO_STREAM (self));