summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/AlsaDriver.cpp4
-rw-r--r--src/Driver.h10
-rw-r--r--src/JackDriver.cpp30
-rw-r--r--src/JackDriver.h1
-rw-r--r--src/Patchage.cpp6
-rw-r--r--src/PatchageCanvas.cpp2
-rw-r--r--src/PatchageEvent.cpp23
-rw-r--r--src/PatchageEvent.h28
-rw-r--r--src/PatchagePort.h2
9 files changed, 62 insertions, 44 deletions
diff --git a/src/AlsaDriver.cpp b/src/AlsaDriver.cpp
index 9a46d14..7ed05bb 100644
--- a/src/AlsaDriver.cpp
+++ b/src/AlsaDriver.cpp
@@ -87,8 +87,6 @@ AlsaDriver::detach()
void
AlsaDriver::refresh()
{
- cerr << "ALSA REFRESH" << endl;
-
if (!is_attached())
return;
@@ -96,8 +94,6 @@ AlsaDriver::refresh()
refresh_ports();
refresh_connections();
-
- undirty();
}
diff --git a/src/Driver.h b/src/Driver.h
index 18489ae..95ffe73 100644
--- a/src/Driver.h
+++ b/src/Driver.h
@@ -44,19 +44,11 @@ public:
Raul::SRSWQueue<PatchageEvent>& events() { return _events; }
- /** Returns whether or not a refresh is required (pending). */
- inline bool is_dirty() const { return _is_dirty; }
-
- /** Clear 'dirty' status after a refresh. */
- inline void undirty() { _is_dirty = false; }
-
sigc::signal<void> signal_attached;
sigc::signal<void> signal_detached;
protected:
- Driver() : _is_dirty(false), _events(1024) /* FIXME: size? */ {}
-
- bool _is_dirty;
+ Driver() : _events(1024) /* FIXME: size? */ {}
Raul::SRSWQueue<PatchageEvent> _events;
};
diff --git a/src/JackDriver.cpp b/src/JackDriver.cpp
index 47bfda1..3428eb6 100644
--- a/src/JackDriver.cpp
+++ b/src/JackDriver.cpp
@@ -76,11 +76,11 @@ JackDriver::attach(bool launch_daemon)
jack_set_error_function(error_cb);
jack_on_shutdown(client, jack_shutdown_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);
jack_set_buffer_size_callback(client, jack_buffer_size_cb, this);
jack_set_xrun_callback(client, jack_xrun_cb, this);
- _is_dirty = true;
_buffer_size = jack_get_buffer_size(client);
if (!jack_activate(client)) {
@@ -169,7 +169,6 @@ JackDriver::shutdown()
{
destroy_all_ports();
signal_detached.emit();
- _is_dirty = false;
}
@@ -179,8 +178,6 @@ JackDriver::shutdown()
void
JackDriver::refresh()
{
- cerr << "JACK REFRESH" << endl;
-
const char** ports;
jack_port_t* port;
@@ -336,7 +333,6 @@ JackDriver::refresh()
}
free(ports);
- undirty();
}
@@ -414,6 +410,25 @@ JackDriver::jack_port_registration_cb(jack_port_id_t port_id, int registered, vo
}
+void
+JackDriver::jack_port_connect_cb(jack_port_id_t src, jack_port_id_t dst, int connect, void* jack_driver)
+{
+ assert(jack_driver);
+ JackDriver* me = reinterpret_cast<JackDriver*>(jack_driver);
+ assert(me->_client);
+
+ jack_reset_max_delayed_usecs(me->_client);
+
+ if (connect) {
+ me->_events.push(PatchageEvent(me->_app,
+ PatchageEvent::CONNECTION, src, dst));
+ } else {
+ me->_events.push(PatchageEvent(me->_app,
+ PatchageEvent::DISCONNECTION, src, dst));
+ }
+}
+
+
int
JackDriver::jack_graph_order_cb(void* jack_driver)
{
@@ -423,8 +438,6 @@ JackDriver::jack_graph_order_cb(void* jack_driver)
jack_reset_max_delayed_usecs(me->_client);
- me->_is_dirty = true;
-
return 0;
}
@@ -462,8 +475,6 @@ JackDriver::jack_xrun_cb(void* jack_driver)
//cerr << "** XRUN Delay = " << me->_xrun_delay << endl;
- me->_is_dirty = true;
-
//(me->_mutex).unlock();
return 0;
@@ -480,7 +491,6 @@ JackDriver::jack_shutdown_cb(void* jack_driver)
jack_reset_max_delayed_usecs(me->_client);
me->_mutex.lock();
- me->_is_dirty = true;
me->_client = NULL;
me->_mutex.unlock();
}
diff --git a/src/JackDriver.h b/src/JackDriver.h
index b89bd94..d036276 100644
--- a/src/JackDriver.h
+++ b/src/JackDriver.h
@@ -97,6 +97,7 @@ private:
void update_time();
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);
static int jack_buffer_size_cb(jack_nframes_t buffer_size, void* me);
static int jack_xrun_cb(void* me);
diff --git a/src/Patchage.cpp b/src/Patchage.cpp
index c8a32a5..35450e4 100644
--- a/src/Patchage.cpp
+++ b/src/Patchage.cpp
@@ -321,12 +321,6 @@ Patchage::idle_callback()
if (_alsa_driver)
_alsa_driver->refresh();
#endif
- }
-
- // Jack driver needs refreshing
- if (_refresh || _jack_driver->is_dirty()) {
- _canvas->flag_all_connections();
- _jack_driver->refresh();
_canvas->destroy_all_flagged_connections();
_refresh = false;
}
diff --git a/src/PatchageCanvas.cpp b/src/PatchageCanvas.cpp
index 97e31bf..6c9e2c8 100644
--- a/src/PatchageCanvas.cpp
+++ b/src/PatchageCanvas.cpp
@@ -51,7 +51,7 @@ PatchageCanvas::find_module(const string& name, ModuleType type)
{
for (ItemList::iterator m = _items.begin(); m != _items.end(); ++m) {
boost::shared_ptr<PatchageModule> pm = boost::dynamic_pointer_cast<PatchageModule>(*m);
- if (pm && pm->name() == name && pm->type() == type) {
+ if (pm && pm->name() == name && (pm->type() == type || pm->type() == InputOutput)) {
return pm;
}
}
diff --git a/src/PatchageEvent.cpp b/src/PatchageEvent.cpp
index aaec3dc..775f030 100644
--- a/src/PatchageEvent.cpp
+++ b/src/PatchageEvent.cpp
@@ -26,12 +26,21 @@
SharedPtr<PatchagePort>
PatchageEvent::find_port(const PortRef& ref)
{
- if (ref.type == ALSA_MIDI) {
- return _patchage->canvas()->find_port(&ref.id.alsa);
+ if (ref.type == PortRef::NULL_PORT_REF)
+ return boost::shared_ptr<PatchagePort>();
+
+ if (ref.type == PortRef::ALSA_ADDR) {
+ return _patchage->canvas()->find_port(&ref.id.alsa_addr);
} else {
+ if (!_patchage->jack_driver()->client())
+ return boost::shared_ptr<PatchagePort>();
+
jack_port_t* jack_port = NULL;
- if (_patchage->jack_driver()->client())
- jack_port = jack_port_by_id(_patchage->jack_driver()->client(), ref.id.jack);
+
+ if (ref.type == PortRef::JACK_PORT)
+ jack_port = ref.id.jack_port;
+ else if (ref.type == PortRef::JACK_ID)
+ jack_port = jack_port_by_id(_patchage->jack_driver()->client(), ref.id.jack_id);
if (!jack_port)
return boost::shared_ptr<PatchagePort>();
@@ -40,8 +49,8 @@ PatchageEvent::find_port(const PortRef& ref)
const string module_name = full_name.substr(0, full_name.find(":"));
const string port_name = full_name.substr(full_name.find(":")+1);
- SharedPtr<PatchageModule> module = PtrCast<PatchageModule>(
- _patchage->canvas()->get_item(module_name));
+ SharedPtr<PatchageModule> module = _patchage->canvas()->find_module(module_name,
+ (jack_port_flags(jack_port) & JackPortIsInput) ? Input : Output);
if (module)
return PtrCast<PatchagePort>(module->get_port(port_name));
@@ -61,7 +70,7 @@ PatchageEvent::execute()
if (_type == PORT_CREATION) {
jack_port_t* jack_port = NULL;
if (_patchage->jack_driver()->client())
- jack_port = jack_port_by_id(_patchage->jack_driver()->client(), _port_1.id.jack);
+ jack_port = jack_port_by_id(_patchage->jack_driver()->client(), _port_1.id.jack_id);
if (!jack_port)
return;
diff --git a/src/PatchageEvent.h b/src/PatchageEvent.h
index da2526b..c249613 100644
--- a/src/PatchageEvent.h
+++ b/src/PatchageEvent.h
@@ -21,6 +21,9 @@
#include <string>
#include <jack/jack.h>
#include "../config.h"
+#ifdef HAVE_ALSA
+#include <alsa/asoundlib.h>
+#endif
#include "PatchagePort.h"
class Patchage;
@@ -50,12 +53,22 @@ public:
{}
PatchageEvent(Patchage* patchage, Type type,
+ jack_port_id_t port_1, jack_port_id_t port_2)
+ : _patchage(patchage)
+ , _type(type)
+ , _port_1(port_1)
+ , _port_2(port_2)
+ {}
+
+#ifdef HAVE_ALSA
+ PatchageEvent(Patchage* patchage, Type type,
snd_seq_addr_t port_1, snd_seq_addr_t port_2)
: _patchage(patchage)
, _type(type)
, _port_1(port_1)
, _port_2(port_2)
{}
+#endif
void execute();
@@ -66,19 +79,22 @@ private:
Type _type;
struct PortRef {
- PortRef() : type((PortType)0xdeadbeef) { id.jack = 0; }
+ PortRef() : type(NULL_PORT_REF) { id.jack_id = 0; }
- PortRef(jack_port_id_t jack_id) : type(JACK_ANY) { id.jack = jack_id; }
+ PortRef(jack_port_id_t jack_id) : type(JACK_ID) { id.jack_id = jack_id; }
+ PortRef(jack_port_t* jack_port) : type(JACK_PORT) { id.jack_port = jack_port; }
#ifdef HAVE_ALSA
- PortRef(snd_seq_addr_t addr) : type(ALSA_MIDI) { id.alsa = addr; }
+ PortRef(snd_seq_addr_t addr) : type(ALSA_ADDR) { id.alsa_addr = addr; }
#endif
- PortType type;
+ enum { NULL_PORT_REF, JACK_ID, JACK_PORT, ALSA_ADDR } type;
+
union {
- jack_port_id_t jack;
+ jack_port_t* jack_port;
+ jack_port_id_t jack_id;
#ifdef HAVE_ALSA
- snd_seq_addr_t alsa;
+ snd_seq_addr_t alsa_addr;
#endif
} id;
};
diff --git a/src/PatchagePort.h b/src/PatchagePort.h
index 4552b85..6109fba 100644
--- a/src/PatchagePort.h
+++ b/src/PatchagePort.h
@@ -32,7 +32,7 @@
using namespace FlowCanvas;
using std::string; using std::list;
-enum PortType { JACK_ANY, JACK_AUDIO, JACK_MIDI, ALSA_MIDI };
+enum PortType { JACK_AUDIO, JACK_MIDI, ALSA_MIDI };
/** A Port on a PatchageModule