From 6ca526a29d5726fdcf41d3034f1c55553be6ff6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?= Date: Mon, 17 Jun 2024 20:14:58 -0400 Subject: [PATCH] [avnd] Handle passing larger messages from exec to ui --- 3rdparty/libossia | 2 +- .../score-plugin-avnd/Crousti/Executor.hpp | 21 ++++++++++++++----- .../score-plugin-avnd/Crousti/MessageBus.hpp | 13 ++++++++++++ 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/3rdparty/libossia b/3rdparty/libossia index 660fdb4e54..9165c3712f 160000 --- a/3rdparty/libossia +++ b/3rdparty/libossia @@ -1 +1 @@ -Subproject commit 660fdb4e54f10082da49e44f6210a286d11ebd90 +Subproject commit 9165c3712f7bb6c967f85081783f2c1c6d5020d0 diff --git a/src/plugins/score-plugin-avnd/Crousti/Executor.hpp b/src/plugins/score-plugin-avnd/Crousti/Executor.hpp index 99e1221c8b..c17f655ea5 100644 --- a/src/plugins/score-plugin-avnd/Crousti/Executor.hpp +++ b/src/plugins/score-plugin-avnd/Crousti/Executor.hpp @@ -816,11 +816,22 @@ class Executor final if constexpr(avnd::has_processor_to_gui_bus) { - eff.send_message = [this](auto b) mutable { - this->in_edit([this, bb = std::move(b)]() mutable { - if(this->process().to_ui) - MessageBusSender{this->process().to_ui}(std::move(bb)); - }); + eff.send_message = [this](T&& b) mutable { + if constexpr(sizeof(this) + sizeof(b) < Execution::ExecutionCommand::max_storage) + { + this->in_edit([this, bb = std::move(b)]() mutable { + if(this->process().to_ui) + MessageBusSender{this->process().to_ui}(std::move(bb)); + }); + } + else + { + this->in_edit( + [this, bb = std::make_unique>(std::move(b))]() mutable { + if(this->process().to_ui) + MessageBusSender{this->process().to_ui}(*std::move(bb)); + }); + } }; } } diff --git a/src/plugins/score-plugin-avnd/Crousti/MessageBus.hpp b/src/plugins/score-plugin-avnd/Crousti/MessageBus.hpp index 5a294e247c..0c2c5bedf6 100644 --- a/src/plugins/score-plugin-avnd/Crousti/MessageBus.hpp +++ b/src/plugins/score-plugin-avnd/Crousti/MessageBus.hpp @@ -79,6 +79,19 @@ struct MessageBusSender this->bus(std::move(buf)); } + + template + void operator()(const std::shared_ptr& msg) + { + SCORE_ASSERT(msg); + return (*this)(std::move(*msg)); + } + template + void operator()(std::unique_ptr msg) + { + SCORE_ASSERT(msg); + return (*this)(std::move(*msg)); + } }; struct Deserializer