diff options
-rw-r--r-- | src/AlsaDriver.cpp | 284 | ||||
-rw-r--r-- | src/AlsaDriver.hpp | 16 | ||||
-rw-r--r-- | src/JackDriver.cpp | 70 | ||||
-rw-r--r-- | src/JackDriver.hpp | 2 | ||||
-rw-r--r-- | src/Patchage.cpp | 2 | ||||
-rw-r--r-- | src/PatchageCanvas.cpp | 16 | ||||
-rw-r--r-- | src/PatchageCanvas.hpp | 2 | ||||
-rw-r--r-- | src/PatchageEvent.cpp | 7 | ||||
-rw-r--r-- | src/PatchageEvent.hpp | 2 | ||||
-rw-r--r-- | src/PatchageModule.hpp | 7 | ||||
-rw-r--r-- | src/PatchagePort.hpp | 22 |
11 files changed, 197 insertions, 233 deletions
diff --git a/src/AlsaDriver.cpp b/src/AlsaDriver.cpp index a22ecc8..b2ceed7 100644 --- a/src/AlsaDriver.cpp +++ b/src/AlsaDriver.cpp @@ -18,6 +18,7 @@ #include <cassert> #include <set> #include <string> +#include <utility> #include "raul/SharedPtr.hpp" #include "raul/log.hpp" @@ -94,6 +95,8 @@ void AlsaDriver::destroy_all() { _app->canvas()->remove_ports(is_alsa_port); + _modules.clear(); + _port_addrs.clear(); } /** Refresh all Alsa Midi ports and connections. @@ -106,32 +109,122 @@ AlsaDriver::refresh() assert(_seq); - refresh_ports(); - refresh_connections(); + _modules.clear(); + _ignored.clear(); + _port_addrs.clear(); + + snd_seq_client_info_t* cinfo; + snd_seq_client_info_alloca(&cinfo); + snd_seq_client_info_set_client(cinfo, -1); + + snd_seq_port_info_t* pinfo; + snd_seq_port_info_alloca(&pinfo); + + PatchageModule* parent = NULL; + PatchagePort* port = NULL; + + // Create port views + while (snd_seq_query_next_client(_seq, cinfo) >= 0) { + snd_seq_port_info_set_client(pinfo, snd_seq_client_info_get_client(cinfo)); + snd_seq_port_info_set_port(pinfo, -1); + while (snd_seq_query_next_port(_seq, pinfo) >= 0) { + const snd_seq_addr_t& addr = *snd_seq_port_info_get_addr(pinfo); + if (ignore(addr)) { + continue; + } + + create_port_view_internal(_app, addr, parent, port); + if (parent) { + _app->enqueue_resize(parent); + } + } + } + + // Create connections + snd_seq_client_info_set_client(cinfo, -1); + while (snd_seq_query_next_client(_seq, cinfo) >= 0) { + snd_seq_port_info_set_client(pinfo, snd_seq_client_info_get_client(cinfo)); + snd_seq_port_info_set_port(pinfo, -1); + while (snd_seq_query_next_port(_seq, pinfo) >= 0) { + const snd_seq_addr_t* addr = snd_seq_port_info_get_addr(pinfo); + if (ignore(*addr)) { + continue; + } + + PatchagePort* port = _app->canvas()->find_port(PortID(*addr, false)); + if (!port) { + continue; + } + + snd_seq_query_subscribe_t* subsinfo; + snd_seq_query_subscribe_alloca(&subsinfo); + snd_seq_query_subscribe_set_root(subsinfo, addr); + snd_seq_query_subscribe_set_index(subsinfo, 0); + while (!snd_seq_query_port_subscribers(_seq, subsinfo)) { + const snd_seq_addr_t* addr2 = snd_seq_query_subscribe_get_addr(subsinfo); + if (!addr2) + continue; + + PatchagePort* port2 = _app->canvas()->find_port(PortID(*addr2, true)); + if (port2 && !port->is_connected_to(port2)) { + _app->canvas()->add_connection(port, + port2, + port->color() + 0x22222200); + + snd_seq_query_subscribe_set_index( + subsinfo, snd_seq_query_subscribe_get_index(subsinfo) + 1); + } + } + } + } } PatchagePort* AlsaDriver::create_port_view(Patchage* patchage, const PortID& id) { - PatchageModule* parent; - PatchagePort* port; + PatchageModule* parent = NULL; + PatchagePort* port = NULL; create_port_view_internal(patchage, id.id.alsa_addr, parent, port); return port; } PatchageModule* +AlsaDriver::find_module(uint8_t client_id, ModuleType type) +{ + const Modules::const_iterator i = _modules.find(client_id); + if (i == _modules.end()) + return NULL; + + PatchageModule* io_module = NULL; + for (Modules::const_iterator j = i; + j != _modules.end() && j->first == client_id; + ++j) { + if (j->second->type() == type) { + return j->second; + } else if (j->second->type() == InputOutput) { + io_module = j->second; + } + } + + // Return InputOutput module for Input or Output, or NULL if not found + return io_module; +} + +PatchageModule* AlsaDriver::find_or_create_module( Patchage* patchage, + uint8_t client_id, const std::string& client_name, ModuleType type) { - PatchageModule* m = _app->canvas()->find_module(client_name, type); + PatchageModule* m = find_module(client_id, type); if (!m) { m = new PatchageModule(patchage, client_name, type); m->load_location(); _app->canvas()->add_module(client_name, m); _app->enqueue_resize(m); + _modules.insert(std::make_pair(client_id, m)); } return m; } @@ -196,29 +289,26 @@ AlsaDriver::create_port_view_internal( << " split = " << split << endl;*/ if (!split) { - m = find_or_create_module(_app, client_name, InputOutput); + m = find_or_create_module(_app, addr.client, client_name, InputOutput); if (!m->get_port(port_name)) { port = create_port(*m, port_name, is_input, addr); port->show(); - m->add_port(port); } } else { // split ModuleType type = ((is_input) ? Input : Output); - m = find_or_create_module(_app, client_name, type); + m = find_or_create_module(_app, addr.client, client_name, type); if (!m->get_port(port_name)) { port = create_port(*m, port_name, is_input, addr); port->show(); - m->add_port(port); } if (is_duplex) { type = ((!is_input) ? Input : Output); - m = find_or_create_module(_app, client_name, type); + m = find_or_create_module(_app, addr.client, client_name, type); if (!m->get_port(port_name)) { port = create_port(*m, port_name, !is_input, addr); port->show(); - m->add_port(port); } } } @@ -235,7 +325,8 @@ AlsaDriver::create_port(PatchageModule& parent, dynamic_cast<PatchageCanvas*>(parent.canvas())->index_port( PortID(addr, is_input), ret); - ret->alsa_addr(addr); + _app->canvas()->index_port(PortID(addr, is_input), ret); + _port_addrs.insert(std::make_pair(ret, PortID(addr, is_input))); return ret; } @@ -280,101 +371,6 @@ AlsaDriver::ignore(const snd_seq_addr_t& addr, bool add) return false; } -/** Refresh all Alsa Midi ports. - */ -void -AlsaDriver::refresh_ports() -{ - assert(is_attached()); - assert(_seq); - - snd_seq_client_info_t* cinfo; - snd_seq_client_info_alloca(&cinfo); - snd_seq_client_info_set_client(cinfo, -1); - - snd_seq_port_info_t* pinfo; - snd_seq_port_info_alloca(&pinfo); - - PatchageModule* parent; - PatchagePort* port; - - std::set<PatchageModule*> to_resize; - - while (snd_seq_query_next_client (_seq, cinfo) >= 0) { - snd_seq_port_info_set_client(pinfo, snd_seq_client_info_get_client(cinfo)); - snd_seq_port_info_set_port(pinfo, -1); - while (snd_seq_query_next_port(_seq, pinfo) >= 0) { - const snd_seq_addr_t& addr = *snd_seq_port_info_get_addr(pinfo); - if (!ignore(addr)) { - create_port_view_internal(_app, addr, parent, port); - if (parent) - _app->enqueue_resize(parent); - } - } - } -} - -/** Refresh all Alsa Midi connections. - */ -void -AlsaDriver::refresh_connections() -{ - assert(is_attached()); - assert(_seq); - - PatchageModule* m = NULL; - PatchagePort* p = NULL; - - for (FlowCanvas::Canvas::Items::iterator i = _app->canvas()->items().begin(); - i != _app->canvas()->items().end(); ++i) { - m = dynamic_cast<PatchageModule*>(*i); - if (m) { - for (FlowCanvas::Module::Ports::const_iterator j = m->ports().begin(); j != m->ports().end(); ++j) { - p = dynamic_cast<PatchagePort*>(*j); - if (p->type() == ALSA_MIDI) - add_connections(p); - } - } - } -} - -/** Add all connections for the given port. - */ -void -AlsaDriver::add_connections(PatchagePort* port) -{ - assert(is_attached()); - assert(_seq); - - const snd_seq_addr_t* addr = port->alsa_addr(); - PatchagePort* connected_port; - - // Fix a problem with duplex->duplex connections (would show up twice) - // No sense doing them all twice anyway.. - if (port->is_input()) - return; - - snd_seq_query_subscribe_t* subsinfo; - snd_seq_query_subscribe_alloca(&subsinfo); - snd_seq_query_subscribe_set_root(subsinfo, addr); - snd_seq_query_subscribe_set_index(subsinfo, 0); - - while (!snd_seq_query_port_subscribers(_seq, subsinfo)) { - const snd_seq_addr_t* connected_addr = snd_seq_query_subscribe_get_addr(subsinfo); - if (!connected_addr) - continue; - - PortID id(*connected_addr, true); - connected_port = _app->canvas()->find_port(id); - - if (connected_port && !port->is_connected_to(connected_port)) - _app->canvas()->add_connection(port, connected_port, port->color() + 0x22222200); - - snd_seq_query_subscribe_set_index(subsinfo, snd_seq_query_subscribe_get_index(subsinfo) + 1); - } - -} - /** Connects two Alsa Midi ports. * * \return Whether connection succeeded. @@ -383,31 +379,43 @@ bool AlsaDriver::connect(PatchagePort* src_port, PatchagePort* dst_port) { - const snd_seq_addr_t* src = src_port->alsa_addr(); - const snd_seq_addr_t* dst = dst_port->alsa_addr(); + PortAddrs::const_iterator s = _port_addrs.find(src_port); + PortAddrs::const_iterator d = _port_addrs.find(dst_port); + + if (s == _port_addrs.end() || d == _port_addrs.end()) { + Raul::error << "[ALSA] Attempt to connect port with no address" << endl; + return false; + } + + const PortID src = s->second; + const PortID dst = d->second; + + if (src.id.alsa_addr.client == dst.id.alsa_addr.client + && src.id.alsa_addr.port == dst.id.alsa_addr.port) { + Raul::warn << "[ALSA] Refusing to connect port to itself" << endl; + return false; + } bool result = true; - if (src && dst) { - snd_seq_port_subscribe_t* subs; - snd_seq_port_subscribe_malloc(&subs); - snd_seq_port_subscribe_set_sender(subs, src); - snd_seq_port_subscribe_set_dest(subs, dst); - snd_seq_port_subscribe_set_exclusive(subs, 0); - snd_seq_port_subscribe_set_time_update(subs, 0); - snd_seq_port_subscribe_set_time_real(subs, 0); - - // Already connected (shouldn't happen) - if (!snd_seq_get_port_subscription(_seq, subs)) { - Raul::error << "[ALSA] Attempt to subscribe ports that are already subscribed." << endl; - result = false; - } + snd_seq_port_subscribe_t* subs; + snd_seq_port_subscribe_malloc(&subs); + snd_seq_port_subscribe_set_sender(subs, &src.id.alsa_addr); + snd_seq_port_subscribe_set_dest(subs, &dst.id.alsa_addr); + snd_seq_port_subscribe_set_exclusive(subs, 0); + snd_seq_port_subscribe_set_time_update(subs, 0); + snd_seq_port_subscribe_set_time_real(subs, 0); - int ret = snd_seq_subscribe_port(_seq, subs); - if (ret < 0) { - Raul::error << "[ALSA] Subscription failed: " << snd_strerror(ret) << endl; - result = false; - } + // Already connected (shouldn't happen) + if (!snd_seq_get_port_subscription(_seq, subs)) { + Raul::error << "[ALSA] Attempt to double subscribe ports" << endl; + result = false; + } + + int ret = snd_seq_subscribe_port(_seq, subs); + if (ret < 0) { + Raul::error << "[ALSA] Subscription failed: " << snd_strerror(ret) << endl; + result = false; } if (result) @@ -428,13 +436,21 @@ bool AlsaDriver::disconnect(PatchagePort* src_port, PatchagePort* dst_port) { - const snd_seq_addr_t* src = src_port->alsa_addr(); - const snd_seq_addr_t* dst = dst_port->alsa_addr(); + PortAddrs::const_iterator s = _port_addrs.find(src_port); + PortAddrs::const_iterator d = _port_addrs.find(dst_port); + + if (s == _port_addrs.end() || d == _port_addrs.end()) { + Raul::error << "[ALSA] Attempt to connect port with no address" << endl; + return false; + } + + const PortID src = s->second; + const PortID dst = d->second; snd_seq_port_subscribe_t* subs; snd_seq_port_subscribe_malloc(&subs); - snd_seq_port_subscribe_set_sender(subs, src); - snd_seq_port_subscribe_set_dest(subs, dst); + snd_seq_port_subscribe_set_sender(subs, &src.id.alsa_addr); + snd_seq_port_subscribe_set_dest(subs, &dst.id.alsa_addr); snd_seq_port_subscribe_set_exclusive(subs, 0); snd_seq_port_subscribe_set_time_update(subs, 0); snd_seq_port_subscribe_set_time_real(subs, 0); @@ -547,6 +563,10 @@ AlsaDriver::_refresh_main() PortID(ev->data.addr, true))); _events.push(PatchageEvent(PatchageEvent::PORT_DESTRUCTION, PortID(ev->data.addr, false))); + _port_addrs.erase(_app->canvas()->find_port( + PortID(ev->data.addr, false))); + _port_addrs.erase(_app->canvas()->find_port( + PortID(ev->data.addr, true))); } break; case SND_SEQ_EVENT_CLIENT_CHANGE: diff --git a/src/AlsaDriver.hpp b/src/AlsaDriver.hpp index 54c35b1..8279273 100644 --- a/src/AlsaDriver.hpp +++ b/src/AlsaDriver.hpp @@ -21,12 +21,14 @@ #include <queue> #include <set> #include <string> +#include <map> #include <alsa/asoundlib.h> #include <pthread.h> #include "Driver.hpp" #include "PatchageModule.hpp" + class Patchage; class PatchagePort; @@ -61,18 +63,16 @@ public: void process_events(Patchage* app); private: - void refresh_ports(); - void refresh_connections(); - - void add_connections(PatchagePort* port); - bool create_refresh_port(); static void* refresh_main(void* me); void _refresh_main(); + PatchageModule* find_module(uint8_t client_id, ModuleType type); + PatchageModule* find_or_create_module( Patchage* patchage, + uint8_t client_id, const std::string& client_name, ModuleType type); @@ -105,6 +105,12 @@ private: typedef std::set<snd_seq_addr_t, SeqAddrComparator> Ignored; Ignored _ignored; + typedef std::multimap<uint8_t, PatchageModule*> Modules; + Modules _modules; + + typedef std::map<PatchagePort*, PortID> PortAddrs; + PortAddrs _port_addrs; + bool ignore(const snd_seq_addr_t& addr, bool add=true); }; diff --git a/src/JackDriver.cpp b/src/JackDriver.cpp index 1973303..27cab50 100644 --- a/src/JackDriver.cpp +++ b/src/JackDriver.cpp @@ -78,7 +78,6 @@ JackDriver::attach(bool launch_daemon) 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); jack_set_buffer_size_callback(client, jack_buffer_size_cb, this); jack_set_xrun_callback(client, jack_xrun_cb, this); @@ -127,13 +126,13 @@ PatchagePort* JackDriver::create_port_view(Patchage* patchage, const PortID& id) { - jack_port_t* jack_port = NULL; - - if (id.type == PortID::JACK_ID) - jack_port = jack_port_by_id(_client, id.id.jack_id); - - if (jack_port == NULL) + assert(id.type == PortID::JACK_ID); + + jack_port_t* jack_port = jack_port_by_id(_client, id.id.jack_id); + if (!jack_port) { + Raul::error << "[JACK] Failed to find port with ID " << id << endl; return NULL; + } const int jack_flags = jack_port_flags(jack_port); @@ -141,8 +140,8 @@ JackDriver::create_port_view(Patchage* patchage, port_names(id, module_name, port_name); ModuleType type = InputOutput; - if (_app->state_manager()->get_module_split(module_name, - (jack_flags & JackPortIsTerminal))) { + if (_app->state_manager()->get_module_split( + module_name, (jack_flags & JackPortIsTerminal))) { if (jack_flags & JackPortIsInput) { type = Input; } else { @@ -151,28 +150,18 @@ JackDriver::create_port_view(Patchage* patchage, } PatchageModule* parent = _app->canvas()->find_module(module_name, type); - - bool resize = false; - if (!parent) { parent = new PatchageModule(patchage, module_name, type); parent->load_location(); patchage->canvas()->add_module(module_name, parent); parent->show(); - resize = true; } - PatchagePort* port = dynamic_cast<PatchagePort*>(parent->get_port(port_name)); - - if (!port) { - port = create_port(*parent, jack_port, id); - port->show(); - parent->add_port(port); - resize = true; - } + assert(!parent->get_port(port_name)); - if (resize) - _app->enqueue_resize(parent); + PatchagePort* port = create_port(*parent, jack_port, id); + port->show(); + _app->enqueue_resize(parent); return port; } @@ -243,7 +232,7 @@ JackDriver::refresh() size_t colon; // Add all ports - for (int i=0; ports[i]; ++i) { + for (int i = 0; ports[i]; ++i) { port = jack_port_by_name(_client, ports[i]); client1_name = ports[i]; @@ -281,14 +270,13 @@ JackDriver::refresh() } if (!m->get_port(jack_port_short_name(port))) - m->add_port(create_port(*m, port, PortID())); + create_port(*m, port, PortID()); _app->enqueue_resize(m); } // Add all connections for (int i = 0; ports[i]; ++i) { - port = jack_port_by_name(_client, ports[i]); const char** connected_ports = jack_port_get_all_connections(_client, port); @@ -297,7 +285,8 @@ JackDriver::refresh() port1_name = client1_name.substr(colon + 1); client1_name = client1_name.substr(0, colon); - const ModuleType port1_type = (jack_port_flags(port) & JackPortIsInput) ? Input : Output; + const ModuleType port1_type = (jack_port_flags(port) & JackPortIsInput) + ? Input : Output; PatchageModule* client1_module = _app->canvas()->find_module(client1_name, port1_type); @@ -336,11 +325,11 @@ JackDriver::refresh() _app->canvas()->add_connection(src, dst, port1->color() + 0x22222200); } - free(connected_ports); + jack_free(connected_ports); } } - free(ports); + jack_free(ports); } bool @@ -416,12 +405,9 @@ JackDriver::disconnect(PatchagePort* const src_port, void 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_reset_max_delayed_usecs(me->_client); - if (registered) { me->_events.push(PatchageEvent(PatchageEvent::CLIENT_CREATION, name)); } else { @@ -432,12 +418,9 @@ JackDriver::jack_client_registration_cb(const char* name, int registered, void* 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_reset_max_delayed_usecs(me->_client); - if (registered) { me->_events.push(PatchageEvent(PatchageEvent::PORT_CREATION, port_id)); } else { @@ -448,12 +431,9 @@ 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(PatchageEvent::CONNECTION, src, dst)); } else { @@ -462,21 +442,8 @@ JackDriver::jack_port_connect_cb(jack_port_id_t src, jack_port_id_t dst, int con } int -JackDriver::jack_graph_order_cb(void* jack_driver) -{ - assert(jack_driver); - JackDriver* me = reinterpret_cast<JackDriver*>(jack_driver); - assert(me->_client); - - //jack_reset_max_delayed_usecs(me->_client); - - return 0; -} - -int JackDriver::jack_buffer_size_cb(jack_nframes_t buffer_size, void* jack_driver) { - assert(jack_driver); JackDriver* me = reinterpret_cast<JackDriver*>(jack_driver); assert(me->_client); @@ -497,7 +464,6 @@ JackDriver::jack_buffer_size_cb(jack_nframes_t buffer_size, void* jack_driver) int JackDriver::jack_xrun_cb(void* jack_driver) { - assert(jack_driver); JackDriver* me = reinterpret_cast<JackDriver*>(jack_driver); assert(me->_client); diff --git a/src/JackDriver.hpp b/src/JackDriver.hpp index f503bf9..80298de 100644 --- a/src/JackDriver.hpp +++ b/src/JackDriver.hpp @@ -19,7 +19,7 @@ #define PATCHAGE_JACKDRIVER_HPP #include <string> -#include <boost/shared_ptr.hpp> + #include <jack/jack.h> #include <jack/statistics.h> #include <glibmm/thread.h> diff --git a/src/Patchage.cpp b/src/Patchage.cpp index ab093dd..441247a 100644 --- a/src/Patchage.cpp +++ b/src/Patchage.cpp @@ -349,7 +349,7 @@ Patchage::idle_callback() } #endif - // Do a full refresh (ie user clicked refresh) + // Do a full refresh if (_refresh) { refresh(); } else if (_driver_detached) { diff --git a/src/PatchageCanvas.cpp b/src/PatchageCanvas.cpp index 69633c8..ebbfc39 100644 --- a/src/PatchageCanvas.cpp +++ b/src/PatchageCanvas.cpp @@ -98,22 +98,16 @@ PatchageCanvas::find_port(const PortID& id) return pp; } -PatchagePort* +void PatchageCanvas::remove_port(const PortID& id) { PatchagePort* const port = find_port(id); - if (!port) - return port; + if (!port) { + Raul::error << "Failed to find port " << id << " to remove" << std::endl; + } _port_index.erase(id); - - PatchageModule* module = dynamic_cast<PatchageModule*>(port->module()); - if (!module) - return port; - - module->remove_port(port); - _app->enqueue_resize(module); - return port; + delete port; } void diff --git a/src/PatchageCanvas.hpp b/src/PatchageCanvas.hpp index e7e8214..6412511 100644 --- a/src/PatchageCanvas.hpp +++ b/src/PatchageCanvas.hpp @@ -65,7 +65,7 @@ public: void add_module(const std::string& name, PatchageModule* module); bool remove_item(FlowCanvas::Item* i); - PatchagePort* remove_port(const PortID& id); + void remove_port(const PortID& id); void destroy(); diff --git a/src/PatchageEvent.cpp b/src/PatchageEvent.cpp index d1afb1a..32136e3 100644 --- a/src/PatchageEvent.cpp +++ b/src/PatchageEvent.cpp @@ -82,12 +82,7 @@ PatchageEvent::execute(Patchage* patchage) } else if (_type == PORT_DESTRUCTION) { - PatchagePort* port = patchage->canvas()->remove_port(_port_1); - if (port) { - delete port; - } else { - Raul::error << "Unable to find port `" << _port_1 << "' to destroy" << endl; - } + patchage->canvas()->remove_port(_port_1); } else if (_type == CONNECTION) { diff --git a/src/PatchageEvent.hpp b/src/PatchageEvent.hpp index 7102b72..2f97eec 100644 --- a/src/PatchageEvent.hpp +++ b/src/PatchageEvent.hpp @@ -55,7 +55,7 @@ public: {} PatchageEvent(Type type, const char* str) - : _str(strdup(str)) // FIXME: not realtime (jack) :( + : _str(strdup(str)) , _type(type) {} diff --git a/src/PatchageModule.hpp b/src/PatchageModule.hpp index 2a58182..d9ba9dd 100644 --- a/src/PatchageModule.hpp +++ b/src/PatchageModule.hpp @@ -21,6 +21,7 @@ #include <string> #include "flowcanvas/Module.hpp" +#include "flowcanvas/Port.hpp" #include "StateManager.hpp" @@ -32,9 +33,6 @@ public: PatchageModule(Patchage* app, const std::string& name, ModuleType type, double x=0, double y=0); ~PatchageModule(); - void add_port(FlowCanvas::Port* port); - void remove_port(FlowCanvas::Port* port); - void split(); void join(); @@ -49,6 +47,9 @@ public: ModuleType type() const { return _type; } protected: + void add_port(FlowCanvas::Port* port); + void remove_port(FlowCanvas::Port* port); + Patchage* _app; ModuleType _type; }; diff --git a/src/PatchagePort.hpp b/src/PatchagePort.hpp index 47c1513..33b6d7e 100644 --- a/src/PatchagePort.hpp +++ b/src/PatchagePort.hpp @@ -30,10 +30,6 @@ #include "PortID.hpp" #include "StateManager.hpp" -#ifdef HAVE_ALSA - #include <alsa/asoundlib.h> -#endif - /** A Port on a PatchageModule */ class PatchagePort : public FlowCanvas::Port @@ -46,31 +42,17 @@ public: uint32_t color) : Port(module, name, is_input, color) , _type(type) - { -#ifdef HAVE_ALSA - _alsa_addr.client = '\0'; - _alsa_addr.port = '\0'; -#endif - } + {} virtual ~PatchagePort() {} -#ifdef HAVE_ALSA - // FIXME: This driver specific crap really needs to go - void alsa_addr(const snd_seq_addr_t addr) { _alsa_addr = addr; } - const snd_seq_addr_t* alsa_addr() const { return (_type == ALSA_MIDI) ? &_alsa_addr : NULL; } -#endif - /** Returns the full name of this port, as "modulename:portname" */ std::string full_name() const { return _module->name() + ":" + _name; } PortType type() const { return _type; } private: -#ifdef HAVE_ALSA - snd_seq_addr_t _alsa_addr; -#endif - PortType _type; + PortType _type; }; #endif // PATCHAGE_PATCHAGEPORT_HPP |