diff options
Diffstat (limited to 'src/PatchageEvent.cpp')
-rw-r--r-- | src/PatchageEvent.cpp | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/PatchageEvent.cpp b/src/PatchageEvent.cpp index 3f03208..d123188 100644 --- a/src/PatchageEvent.cpp +++ b/src/PatchageEvent.cpp @@ -22,6 +22,10 @@ #include "PatchageModule.hpp" #include "PatchageEvent.hpp" #include "Driver.hpp" +#include "JackDriver.hpp" +#ifdef HAVE_ALSA +#include "AlsaDriver.hpp" +#endif using namespace std; @@ -49,13 +53,24 @@ PatchageEvent::execute(Patchage* patchage) } else if (_type == PORT_CREATION) { - if ( ! _driver->create_port_view(patchage, _port_1)) { - cerr << "Unable to create port view (already exists?" << endl; + Driver* driver; + if (_port_1.type == PatchageEvent::PortRef::JACK_ID) + driver = patchage->jack_driver(); +#ifdef HAVE_ALSA + else if (_port_1.type == PatchageEvent::PortRef::ALSA_ADDR) + driver = patchage->alsa_driver(); +#endif + + if (driver) { + if ( ! driver->create_port_view(patchage, _port_1)) + cerr << "Unable to create port view (already exists?" << endl; + } else { + cerr << "ERROR: Create port with unknown port type" << endl; } } else if (_type == PORT_DESTRUCTION) { - SharedPtr<PatchagePort> port = _driver->find_port_view(patchage, _port_1); + SharedPtr<PatchagePort> port = patchage->canvas()->find_port(_port_1); if (port) { SharedPtr<PatchageModule> module = PtrCast<PatchageModule>(port->module().lock()); @@ -78,8 +93,8 @@ PatchageEvent::execute(Patchage* patchage) } else if (_type == CONNECTION) { - SharedPtr<PatchagePort> port_1 = _driver->find_port_view(patchage, _port_1); - SharedPtr<PatchagePort> port_2 = _driver->find_port_view(patchage, _port_2); + SharedPtr<PatchagePort> port_1 = patchage->canvas()->find_port(_port_1); + SharedPtr<PatchagePort> port_2 = patchage->canvas()->find_port(_port_2); if (port_1 && port_2) patchage->canvas()->add_connection(port_1, port_2, port_1->color() + 0x22222200); @@ -88,8 +103,8 @@ PatchageEvent::execute(Patchage* patchage) } else if (_type == DISCONNECTION) { - SharedPtr<PatchagePort> port_1 = _driver->find_port_view(patchage, _port_1); - SharedPtr<PatchagePort> port_2 = _driver->find_port_view(patchage, _port_2); + SharedPtr<PatchagePort> port_1 = patchage->canvas()->find_port(_port_1); + SharedPtr<PatchagePort> port_2 = patchage->canvas()->find_port(_port_2); if (port_1 && port_2) patchage->canvas()->remove_connection(port_1, port_2); |