From 5128bfab7ddb9504abf17375e910e5bc94af291e Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 28 Nov 2020 21:41:26 +0100 Subject: Refresh by emitting events This decouples drivers from the rest of the application, in particular the horrible situation where they were working with the canvas directly, by having them always communicate changes by emitting events. --- src/JackDbusDriver.hpp | 64 ++++++++++---------------------------------------- 1 file changed, 12 insertions(+), 52 deletions(-) (limited to 'src/JackDbusDriver.hpp') diff --git a/src/JackDbusDriver.hpp b/src/JackDbusDriver.hpp index 37a7877..db77658 100644 --- a/src/JackDbusDriver.hpp +++ b/src/JackDbusDriver.hpp @@ -20,23 +20,21 @@ #include "Driver.hpp" #include "Patchage.hpp" -#include "PatchageModule.hpp" #include #include #include #include +#include #include class ILog; -class PatchageCanvas; -class PatchagePort; class JackDriver : public Driver { public: - explicit JackDriver(Patchage* app, ILog& log); + explicit JackDriver(ILog& log); JackDriver(const JackDriver&) = delete; JackDriver& operator=(const JackDriver&) = delete; @@ -52,8 +50,7 @@ public: bool is_attached() const override; bool is_realtime() const; - void refresh() override; - void destroy_all() override; + void refresh(const EventSink& sink) override; bool connect(PortID tail_id, PortID head_id) override; bool disconnect(PortID tail_id, PortID head_id) override; @@ -67,56 +64,18 @@ public: jack_nframes_t buffer_size(); bool set_buffer_size(jack_nframes_t size); - void process_events(Patchage*) override {} - - PatchagePort* - create_port_view(Patchage* patchage, const PortID& ref) override; + void process_events(Patchage* app) override; private: + PortType patchage_port_type(dbus_uint32_t dbus_port_type) const; + + PortInfo port_info(const std::string& port_name, + dbus_uint32_t port_type, + dbus_uint32_t port_flags) const; + void error_msg(const std::string& msg) const; void info_msg(const std::string& msg) const; - PatchageModule* - find_or_create_module(SignalDirection type, const std::string& name); - - void add_port(PatchageModule* module, - PortType type, - const PortID& id, - const std::string& name, - bool is_input); - - void add_port(dbus_uint64_t client_id, - const char* client_name, - dbus_uint64_t port_id, - const char* port_name, - dbus_uint32_t port_flags, - dbus_uint32_t port_type); - - void remove_port(dbus_uint64_t client_id, - const char* client_name, - dbus_uint64_t port_id, - const char* port_name); - - void connect_ports(dbus_uint64_t connection_id, - dbus_uint64_t client1_id, - const char* client1_name, - dbus_uint64_t port1_id, - const char* port1_name, - dbus_uint64_t client2_id, - const char* client2_name, - dbus_uint64_t port2_id, - const char* port2_name); - - void disconnect_ports(dbus_uint64_t connection_id, - dbus_uint64_t client1_id, - const char* client1_name, - dbus_uint64_t port1_id, - const char* port1_name, - dbus_uint64_t client2_id, - const char* client2_name, - dbus_uint64_t port2_id, - const char* port2_name); - bool call(bool response_expected, const char* iface, const char* method, @@ -140,12 +99,13 @@ private: void on_jack_disappeared(); - Patchage* _app; ILog& _log; DBusError _dbus_error; DBusConnection* _dbus_connection; float _max_dsp_load; + std::queue _events; + bool _server_responding; bool _server_started; -- cgit v1.2.1