summaryrefslogtreecommitdiffstats
path: root/src/JackDbusDriver.hpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-11-28 21:41:26 +0100
committerDavid Robillard <d@drobilla.net>2020-11-28 22:49:10 +0100
commit5128bfab7ddb9504abf17375e910e5bc94af291e (patch)
tree79cc0953718e1f79ed47282b9f11f9f087edc3bc /src/JackDbusDriver.hpp
parent0f25dd575f9c74cc34a54e64468f07e6c631750d (diff)
downloadpatchage-5128bfab7ddb9504abf17375e910e5bc94af291e.tar.gz
patchage-5128bfab7ddb9504abf17375e910e5bc94af291e.tar.bz2
patchage-5128bfab7ddb9504abf17375e910e5bc94af291e.zip
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.
Diffstat (limited to 'src/JackDbusDriver.hpp')
-rw-r--r--src/JackDbusDriver.hpp64
1 files changed, 12 insertions, 52 deletions
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 <dbus/dbus.h>
#include <glibmm/thread.h>
#include <jack/jack.h>
#include <jack/statistics.h>
+#include <queue>
#include <string>
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<PatchageEvent> _events;
+
bool _server_responding;
bool _server_started;