From 85ffe68ea31e99781638c82db48b2ade4874dbab Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 9 Nov 2022 16:24:45 +0100 Subject: [PATCH] Revert "adapter: removed unused follower_current_format" This reverts commit 6c963ed9337c24331a05f1f92cba8fa54000543c. This code was meant to set a filter on the format for the follower but is not implemented yet. Problem is that the unit tests and wireplumber call this code and would need to be patched. --- spa/plugins/audioconvert/audioadapter.c | 25 ++++++++++++++++++++++++- spa/plugins/videoconvert/videoadapter.c | 22 +++++++++++++++++++++- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/spa/plugins/audioconvert/audioadapter.c b/spa/plugins/audioconvert/audioadapter.c index b7ebe3d9a..99ba4c770 100644 --- a/spa/plugins/audioconvert/audioadapter.c +++ b/spa/plugins/audioconvert/audioadapter.c @@ -68,6 +68,7 @@ struct impl { struct spa_node *follower; struct spa_hook follower_listener; uint32_t follower_flags; + struct spa_audio_info follower_current_format; struct spa_audio_info default_format; struct spa_handle *hnd_convert; @@ -560,10 +561,32 @@ static int impl_node_set_param(void *object, uint32_t id, uint32_t flags, { int res = 0, res2 = 0; struct impl *this = object; + struct spa_audio_info info = { 0 }; spa_log_debug(this->log, "%p: set param %d", this, id); switch (id) { + case SPA_PARAM_Format: + if (this->started) + return -EIO; + if (param == NULL) + return -EINVAL; + + if ((res = spa_format_parse(param, &info.media_type, &info.media_subtype)) < 0) + return res; + if (info.media_type != SPA_MEDIA_TYPE_audio || + info.media_subtype != SPA_MEDIA_SUBTYPE_raw) + return -EINVAL; + if (spa_format_audio_raw_parse(param, &info.info.raw) < 0) + return -EINVAL; + if (info.info.raw.format == 0 || + info.info.raw.rate == 0 || + info.info.raw.channels == 0) + return -EINVAL; + + this->follower_current_format = info; + break; + case SPA_PARAM_PortConfig: { enum spa_direction dir; @@ -1608,7 +1631,7 @@ impl_init(const struct spa_handle_factory *factory, this->params[IDX_EnumFormat] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ); this->params[IDX_PropInfo] = SPA_PARAM_INFO(SPA_PARAM_PropInfo, SPA_PARAM_INFO_READ); this->params[IDX_Props] = SPA_PARAM_INFO(SPA_PARAM_Props, SPA_PARAM_INFO_READWRITE); - this->params[IDX_Format] = SPA_PARAM_INFO(SPA_PARAM_Format, SPA_PARAM_INFO_READ); + this->params[IDX_Format] = SPA_PARAM_INFO(SPA_PARAM_Format, SPA_PARAM_INFO_WRITE); this->params[IDX_EnumPortConfig] = SPA_PARAM_INFO(SPA_PARAM_EnumPortConfig, SPA_PARAM_INFO_READ); this->params[IDX_PortConfig] = SPA_PARAM_INFO(SPA_PARAM_PortConfig, SPA_PARAM_INFO_READWRITE); this->params[IDX_Latency] = SPA_PARAM_INFO(SPA_PARAM_Latency, SPA_PARAM_INFO_READWRITE); diff --git a/spa/plugins/videoconvert/videoadapter.c b/spa/plugins/videoconvert/videoadapter.c index 66d214f65..0a2a1422b 100644 --- a/spa/plugins/videoconvert/videoadapter.c +++ b/spa/plugins/videoconvert/videoadapter.c @@ -68,6 +68,7 @@ struct impl { struct spa_node *follower; struct spa_hook follower_listener; uint32_t follower_flags; + struct spa_video_info follower_current_format; struct spa_video_info default_format; struct spa_handle *hnd_convert; @@ -566,10 +567,29 @@ static int impl_node_set_param(void *object, uint32_t id, uint32_t flags, { int res = 0, res2 = 0; struct impl *this = object; + struct spa_video_info info = { 0 }; spa_log_debug(this->log, "%p: set param %d", this, id); switch (id) { + case SPA_PARAM_Format: + if (this->started) + return -EIO; + if (param == NULL) + return -EINVAL; + + if ((res = spa_format_parse(param, &info.media_type, &info.media_subtype)) < 0) + return res; + if (info.media_type != SPA_MEDIA_TYPE_video || + info.media_subtype != SPA_MEDIA_SUBTYPE_raw) + return -EINVAL; + + if (spa_format_video_raw_parse(param, &info.info.raw) < 0) + return -EINVAL; + + this->follower_current_format = info; + break; + case SPA_PARAM_PortConfig: { enum spa_direction dir; @@ -1594,7 +1614,7 @@ impl_init(const struct spa_handle_factory *factory, this->params[IDX_EnumFormat] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ); this->params[IDX_PropInfo] = SPA_PARAM_INFO(SPA_PARAM_PropInfo, SPA_PARAM_INFO_READ); this->params[IDX_Props] = SPA_PARAM_INFO(SPA_PARAM_Props, SPA_PARAM_INFO_READWRITE); - this->params[IDX_Format] = SPA_PARAM_INFO(SPA_PARAM_Format, SPA_PARAM_INFO_READ); + this->params[IDX_Format] = SPA_PARAM_INFO(SPA_PARAM_Format, SPA_PARAM_INFO_WRITE); this->params[IDX_EnumPortConfig] = SPA_PARAM_INFO(SPA_PARAM_EnumPortConfig, SPA_PARAM_INFO_READ); this->params[IDX_PortConfig] = SPA_PARAM_INFO(SPA_PARAM_PortConfig, SPA_PARAM_INFO_READWRITE); this->params[IDX_Latency] = SPA_PARAM_INFO(SPA_PARAM_Latency, SPA_PARAM_INFO_READWRITE);