From d9c5d89d230b204a90cca4dee4165ba6ebdf00fd Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 21 Jan 2018 20:52:32 +0100 Subject: Only enqueue messages when the engine is remote When the engine is local, messages are emitted in the Gtk thread and applied immediately. This should make the GUI more responsive. --- src/gui/App.cpp | 29 +++++++++++++++++++---------- src/gui/App.hpp | 22 ++++++++++++---------- src/gui/BreadCrumbs.cpp | 2 +- src/gui/ConnectWindow.cpp | 13 +++++++------ src/gui/ingen_gui.cpp | 24 ++++++++++++++---------- 5 files changed, 53 insertions(+), 37 deletions(-) (limited to 'src/gui') diff --git a/src/gui/App.cpp b/src/gui/App.cpp index a8128d8d..de587a7d 100644 --- a/src/gui/App.cpp +++ b/src/gui/App.cpp @@ -28,6 +28,7 @@ #include "ingen/EngineBase.hpp" #include "ingen/Interface.hpp" #include "ingen/Log.hpp" +#include "ingen/QueuedInterface.hpp" #include "ingen/StreamWriter.hpp" #include "ingen/World.hpp" #include "ingen/client/ClientStore.hpp" @@ -157,7 +158,7 @@ App::run() } void -App::attach(SPtr client) +App::attach(SPtr client) { assert(!_client); assert(!_store); @@ -168,7 +169,7 @@ App::attach(SPtr client) } _client = client; - _store = SPtr(new ClientStore(_world->uris(), _world->log(), client)); + _store = SPtr(new ClientStore(_world->uris(), _world->log(), sig_client())); _loader = SPtr(new ThreadedLoader(*this, _world->interface())); if (!_world->store()) { _world->set_store(_store); @@ -181,12 +182,12 @@ App::attach(SPtr client) stderr, ColorContext::Color::CYAN)); - client->signal_message().connect( + sig_client()->signal_message().connect( sigc::mem_fun(*_dumper.get(), &StreamWriter::message)); } _graph_tree_window->init(*this, *_store); - _client->signal_message().connect(sigc::mem_fun(this, &App::message)); + sig_client()->signal_message().connect(sigc::mem_fun(this, &App::message)); } void @@ -212,6 +213,16 @@ App::request_plugins_if_necessary() } } +SPtr +App::sig_client() +{ + SPtr qi = dynamic_ptr_cast(_client); + if (qi) { + return dynamic_ptr_cast(qi->sink()); + } + return dynamic_ptr_cast(_client); +} + SPtr App::serialiser() { @@ -264,7 +275,7 @@ App::set_property(const URI& subject, went as planned here and fire the signal ourselves as if the server feedback came back immediately. */ if (key != uris().ingen_activity) { - _client->signal_message().emit(SetProperty{0, subject, key, value, ctx}); + sig_client()->signal_message().emit(SetProperty{0, subject, key, value, ctx}); } } @@ -365,8 +376,6 @@ App::activity_port_destroyed(Port* port) if (i != _activity_ports.end()) { _activity_ports.erase(i); } - - return; } bool @@ -412,16 +421,16 @@ App::gtk_main_iteration() _messages_window->flush(); } + _enable_signal = false; if (_world->engine()) { if (!_world->engine()->main_iteration()) { Gtk::Main::quit(); return false; } } else { - _enable_signal = false; - _client->emit_signals(); - _enable_signal = true; + dynamic_ptr_cast(_client)->emit(); } + _enable_signal = true; return true; } diff --git a/src/gui/App.hpp b/src/gui/App.hpp index 573925e6..953e1702 100644 --- a/src/gui/App.hpp +++ b/src/gui/App.hpp @@ -75,7 +75,7 @@ public: void error_message(const std::string& str); - void attach(SPtr client); + void attach(SPtr client); void detach(); @@ -118,11 +118,13 @@ public: Style* style() const { return _style; } WindowFactory* window_factory() const { return _window_factory; } - Ingen::Forge& forge() const { return _world->forge(); } - SPtr interface() const { return _world->interface(); } - SPtr client() const { return _client; } - SPtr store() const { return _store; } - SPtr loader() const { return _loader; } + Ingen::Forge& forge() const { return _world->forge(); } + SPtr interface() const { return _world->interface(); } + SPtr client() const { return _client; } + SPtr store() const { return _store; } + SPtr loader() const { return _loader; } + + SPtr sig_client(); SPtr serialiser(); @@ -157,10 +159,10 @@ protected: static Gtk::Main* _main; - SPtr _client; - SPtr _store; - SPtr _loader; - SPtr _dumper; + SPtr _client; + SPtr _store; + SPtr _loader; + SPtr _dumper; Style* _style; diff --git a/src/gui/BreadCrumbs.cpp b/src/gui/BreadCrumbs.cpp index 3f69e998..ae7882e3 100644 --- a/src/gui/BreadCrumbs.cpp +++ b/src/gui/BreadCrumbs.cpp @@ -35,7 +35,7 @@ BreadCrumbs::BreadCrumbs(App& app) , _full_path("/") , _enable_signal(true) { - app.client()->signal_message().connect( + app.sig_client()->signal_message().connect( sigc::mem_fun(this, &BreadCrumbs::message)); set_can_focus(false); diff --git a/src/gui/ConnectWindow.cpp b/src/gui/ConnectWindow.cpp index 8f235264..623db4a0 100644 --- a/src/gui/ConnectWindow.cpp +++ b/src/gui/ConnectWindow.cpp @@ -29,11 +29,12 @@ #include "ingen/Interface.hpp" #include "ingen/Log.hpp" #include "ingen/Module.hpp" +#include "ingen/QueuedInterface.hpp" #include "ingen/World.hpp" #include "ingen/client/ClientStore.hpp" #include "ingen/client/GraphModel.hpp" +#include "ingen/client/SigClientInterface.hpp" #include "ingen/client/SocketClient.hpp" -#include "ingen/client/ThreadedSigClientInterface.hpp" #include "ingen_config.h" #include "App.hpp" @@ -194,13 +195,13 @@ ConnectWindow::connect_remote(const URI& uri) { Ingen::World* world = _app->world(); - SPtr tsci( - new Client::ThreadedSigClientInterface()); + SPtr sci(new SigClientInterface()); + SPtr qi(new QueuedInterface(sci)); - SPtr iface(world->new_interface(uri, tsci)); + SPtr iface(world->new_interface(uri, qi)); if (iface) { world->set_interface(iface); - _app->attach(tsci); + _app->attach(qi); _app->register_callbacks(); return true; } @@ -231,7 +232,7 @@ ConnectWindow::connect(bool existing) _connect_stage = 1; SPtr client = dynamic_ptr_cast(world->interface()); if (client) { - _app->attach(dynamic_ptr_cast(client->respondee())); + _app->attach(client->respondee()); _app->register_callbacks(); } else { error("Connected with invalid client interface type"); diff --git a/src/gui/ingen_gui.cpp b/src/gui/ingen_gui.cpp index 83e41a7e..677296fd 100644 --- a/src/gui/ingen_gui.cpp +++ b/src/gui/ingen_gui.cpp @@ -16,7 +16,8 @@ #include "ingen/Configuration.hpp" #include "ingen/Module.hpp" -#include "ingen/client/ThreadedSigClientInterface.hpp" +#include "ingen/QueuedInterface.hpp" +#include "ingen/client/SigClientInterface.hpp" #include "App.hpp" @@ -24,18 +25,16 @@ namespace Ingen { namespace GUI { struct GUIModule : public Module { - void load(World* world) { - using Client::SigClientInterface; - using Client::ThreadedSigClientInterface; + using SigClientInterface = Client::SigClientInterface; - std::string uri = world->conf().option("connect").ptr(); + void load(World* world) { + URI uri(world->conf().option("connect").ptr()); if (!world->interface()) { - SPtr client(new ThreadedSigClientInterface()); - world->set_interface(world->new_interface(URI(uri), client)); - } else if (!dynamic_ptr_cast( + world->set_interface( + world->new_interface(URI(uri), make_client(world))); + } else if (!dynamic_ptr_cast( world->interface()->respondee())) { - SPtr client(new ThreadedSigClientInterface()); - world->interface()->set_respondee(client); + world->interface()->set_respondee(make_client(world)); } app = GUI::App::create(world); @@ -45,6 +44,11 @@ struct GUIModule : public Module { app->run(); } + SPtr make_client(World* const world) { + SPtr sci(new SigClientInterface()); + return world->engine() ? sci : SPtr(new QueuedInterface(sci)); + } + SPtr app; }; -- cgit v1.2.1