diff --git a/spa/plugins/audioconvert/audioadapter.c b/spa/plugins/audioconvert/audioadapter.c index 644b85a90..3d65e1df6 100644 --- a/spa/plugins/audioconvert/audioadapter.c +++ b/spa/plugins/audioconvert/audioadapter.c @@ -74,6 +74,7 @@ struct impl { unsigned int started:1; unsigned int active:1; unsigned int driver:1; + unsigned int master:1; }; /** \endcond */ @@ -180,7 +181,14 @@ static void emit_node_info(struct impl *this, bool full) { if (full) this->info.change_mask = this->info_all; + if (this->info.change_mask) { + struct spa_dict_item items[1]; + + this->info.change_mask |= SPA_NODE_CHANGE_MASK_PROPS; + items[0] = SPA_DICT_ITEM_INIT(SPA_KEY_NODE_DRIVER, this->driver ? "1" : "0"); + this->info.props = &SPA_DICT_INIT(items, 1); + spa_node_emit_info(&this->hooks, &this->info); this->info.change_mask = 0; } @@ -307,17 +315,21 @@ static const struct spa_node_events convert_node_events = { static void slave_info(void *data, const struct spa_node_info *info) { struct impl *this = data; - const char *dir; + const char *str; - if (info->max_input_ports > 0) { + if (info->max_input_ports > 0) this->direction = SPA_DIRECTION_INPUT; - dir = "input"; - } - else { + else this->direction = SPA_DIRECTION_OUTPUT; - dir = "output"; + + spa_log_debug(this->log, NAME" %p: slave info %s", this, + this->direction == SPA_DIRECTION_INPUT ? + "Input" : "Output"); + + if (info->props) { + if ((str = spa_dict_lookup(info->props, SPA_KEY_NODE_DRIVER)) != NULL) + this->driver = strcmp(str, "true") == 0 || atoi(str) == 1; } - spa_log_debug(this->log, NAME" %p: slave info %s", this, dir); } static const struct spa_node_events slave_node_events = { @@ -770,7 +782,7 @@ static int impl_node_process(void *object) status = spa_node_process(this->slave); - if (this->direction == SPA_DIRECTION_OUTPUT) { + if (this->direction == SPA_DIRECTION_OUTPUT && !this->master) { if (this->use_converter) status = spa_node_process(this->convert); } diff --git a/src/modules/module-adapter/adapter.c b/src/modules/module-adapter/adapter.c index bf2baf583..a59130a02 100644 --- a/src/modules/module-adapter/adapter.c +++ b/src/modules/module-adapter/adapter.c @@ -268,8 +268,6 @@ struct pw_node *pw_adapter_new(struct pw_core *core, enum pw_direction direction; int res = -ENOENT; - pw_properties_set(props, PW_KEY_MEDIA_CLASS, NULL); - info = pw_node_get_info(slave); if (info == NULL) { errno = EINVAL; @@ -297,6 +295,8 @@ struct pw_node *pw_adapter_new(struct pw_core *core, pw_properties_setf(props, "audio.adapt.slave", "%p", slave->node); pw_properties_set(props, "factory.mode", mode); pw_properties_set(props, SPA_KEY_LIBRARY_NAME, "audioconvert/libspa-audioconvert"); + pw_properties_setf(props, PW_KEY_MEDIA_CLASS, "Audio/%s", + direction == PW_DIRECTION_INPUT ? "Sink" : "Source"); node = pw_spa_node_load(core, NULL, NULL, SPA_NAME_AUDIO_ADAPT,