summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-02-20 18:40:16 +0000
committerDavid Robillard <d@drobilla.net>2008-02-20 18:40:16 +0000
commit75b652d59639cf0171fe51a0c1442d03081f3b2f (patch)
tree91234a404baba903e3a3a3327de2a49fe9d51ba7 /src
parentbbb3abbe4b86a23ef884d38ca299aff13b8f9242 (diff)
downloadpatchage-75b652d59639cf0171fe51a0c1442d03081f3b2f.tar.gz
patchage-75b652d59639cf0171fe51a0c1442d03081f3b2f.tar.bz2
patchage-75b652d59639cf0171fe51a0c1442d03081f3b2f.zip
Support jack client de-registration event.
git-svn-id: http://svn.drobilla.net/lad/patchage@1152 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/JackDriver.cpp25
-rw-r--r--src/JackDriver.hpp1
-rw-r--r--src/PatchageEvent.cpp17
-rw-r--r--src/PatchageEvent.hpp12
4 files changed, 52 insertions, 3 deletions
diff --git a/src/JackDriver.cpp b/src/JackDriver.cpp
index 3a57047..0586717 100644
--- a/src/JackDriver.cpp
+++ b/src/JackDriver.cpp
@@ -75,6 +75,7 @@ JackDriver::attach(bool launch_daemon)
jack_set_error_function(error_cb);
jack_on_shutdown(client, jack_shutdown_cb, this);
+ jack_set_client_registration_callback(client, jack_client_registration_cb, this);
jack_set_port_registration_callback(client, jack_port_registration_cb, this);
jack_set_port_connect_callback(client, jack_port_connect_cb, this);
jack_set_graph_order_callback(client, jack_graph_order_cb, this);
@@ -461,15 +462,33 @@ JackDriver::disconnect(boost::shared_ptr<PatchagePort> const src_port, boost::sh
void
-JackDriver::jack_port_registration_cb(jack_port_id_t port_id, int registered, void* jack_driver)
+JackDriver::jack_client_registration_cb(const char* name, int registered, void* jack_driver)
{
assert(jack_driver);
JackDriver* me = reinterpret_cast<JackDriver*>(jack_driver);
assert(me->_client);
- jack_port_t* const port = jack_port_by_id(me->_client, port_id);
- const string full_name = jack_port_name(port);
+ jack_reset_max_delayed_usecs(me->_client);
+
+ // FIXME: This sucks, not realtime :(
+ if (registered) {
+ me->_events.push(PatchageEvent(me, PatchageEvent::CLIENT_CREATION, name));
+ } else {
+ me->_events.push(PatchageEvent(me, PatchageEvent::CLIENT_DESTRUCTION, name));
+ }
+}
+
+
+void
+JackDriver::jack_port_registration_cb(jack_port_id_t port_id, int registered, void* jack_driver)
+{
+ assert(jack_driver);
+ JackDriver* me = reinterpret_cast<JackDriver*>(jack_driver);
+ assert(me->_client);
+ //jack_port_t* const port = jack_port_by_id(me->_client, port_id);
+ //const string full_name = jack_port_name(port);
+
jack_reset_max_delayed_usecs(me->_client);
if (registered) {
diff --git a/src/JackDriver.hpp b/src/JackDriver.hpp
index 3569255..b22f13e 100644
--- a/src/JackDriver.hpp
+++ b/src/JackDriver.hpp
@@ -104,6 +104,7 @@ private:
void destroy_all_ports();
void shutdown();
+ static void jack_client_registration_cb(const char* name, int registered, void* me);
static void jack_port_registration_cb(jack_port_id_t port_id, int registered, void* me);
static void jack_port_connect_cb(jack_port_id_t src, jack_port_id_t dst, int connect, void* me);
static int jack_graph_order_cb(void* me);
diff --git a/src/PatchageEvent.cpp b/src/PatchageEvent.cpp
index da64899..5b63486 100644
--- a/src/PatchageEvent.cpp
+++ b/src/PatchageEvent.cpp
@@ -31,6 +31,22 @@ PatchageEvent::execute(Patchage* patchage)
{
if (_type == REFRESH) {
patchage->refresh();
+ } else if (_type == CLIENT_CREATION) {
+ // No empty modules (for now)
+ free(_str);
+ _str = NULL;
+ } else if (_type == CLIENT_DESTRUCTION) {
+ SharedPtr<PatchageModule> module = PtrCast<PatchageModule>(
+ patchage->canvas()->find_module(_str, InputOutput));
+
+ if (module) {
+ patchage->canvas()->remove_item(module);
+ module.reset();
+ }
+
+ free(_str);
+ _str = NULL;
+
} else if (_type == PORT_CREATION) {
if ( ! _driver->create_port_view(patchage, _port_1)) {
@@ -48,6 +64,7 @@ PatchageEvent::execute(Patchage* patchage)
module->remove_port(port);
port->hide();
+ // No empty modules (for now)
if (module->num_ports() == 0) {
patchage->canvas()->remove_item(module);
module.reset();
diff --git a/src/PatchageEvent.hpp b/src/PatchageEvent.hpp
index bffc3c8..1f15543 100644
--- a/src/PatchageEvent.hpp
+++ b/src/PatchageEvent.hpp
@@ -36,6 +36,8 @@ public:
enum Type {
NULL_EVENT = 0,
REFRESH,
+ CLIENT_CREATION,
+ CLIENT_DESTRUCTION,
PORT_CREATION,
PORT_DESTRUCTION,
CONNECTION,
@@ -44,12 +46,20 @@ public:
PatchageEvent(Driver* d = NULL, Type type=NULL_EVENT)
: _driver(d)
+ , _str(NULL)
+ , _type(type)
+ {}
+
+ PatchageEvent(Driver* driver, Type type, const char* str)
+ : _driver(driver)
+ , _str(strdup(str)) // FIXME: not realtime (jack) :(
, _type(type)
{}
template <typename P>
PatchageEvent(Driver* driver, Type type, P port)
: _driver(driver)
+ , _str(NULL)
, _port_1(port)
, _type(type)
{}
@@ -57,6 +67,7 @@ public:
template <typename P>
PatchageEvent(Driver* driver, Type type, P port_1, P port_2)
: _driver(driver)
+ , _str(NULL)
, _port_1(port_1, false)
, _port_2(port_2, true)
, _type(type)
@@ -95,6 +106,7 @@ public:
private:
Driver* _driver;
+ char* _str;
PortRef _port_1;
PortRef _port_2;
uint8_t _type;