summaryrefslogtreecommitdiffstats
path: root/src/PatchageEvent.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/PatchageEvent.cpp')
-rw-r--r--src/PatchageEvent.cpp85
1 files changed, 9 insertions, 76 deletions
diff --git a/src/PatchageEvent.cpp b/src/PatchageEvent.cpp
index 7877200..da64899 100644
--- a/src/PatchageEvent.cpp
+++ b/src/PatchageEvent.cpp
@@ -21,92 +21,25 @@
#include "PatchageCanvas.hpp"
#include "PatchageModule.hpp"
#include "PatchageEvent.hpp"
-#include "JackDriver.hpp"
+#include "Driver.hpp"
using namespace std;
-
-SharedPtr<PatchagePort>
-PatchageEvent::find_port(const Patchage* patchage, const PortRef& ref)
-{
- if (ref.type == PortRef::NULL_PORT_REF)
- return boost::shared_ptr<PatchagePort>();
-
-#ifdef HAVE_ALSA
- if (ref.type == PortRef::ALSA_ADDR) {
- return patchage->canvas()->find_port(ref.id.alsa_addr, ref.is_input);
- } else
-#endif
- {
- if (!patchage->jack_driver()->client())
- return boost::shared_ptr<PatchagePort>();
-
- jack_port_t* jack_port = NULL;
-
- 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>();
-
- const string full_name = jack_port_name(jack_port);
- 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 = patchage->canvas()->find_module(module_name,
- (jack_port_flags(jack_port) & JackPortIsInput) ? Input : Output);
-
- if (module)
- return PtrCast<PatchagePort>(module->get_port(port_name));
- else
- return boost::shared_ptr<PatchagePort>();
- }
-
- return boost::shared_ptr<PatchagePort>();
-}
-
void
PatchageEvent::execute(Patchage* patchage)
{
- if (_type == REFRESH) {
+ if (_type == REFRESH) {
patchage->refresh();
} else 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_id);
-
- if (!jack_port)
- return;
-
- const string full_name = jack_port_name(jack_port);
- 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 = patchage->canvas()->find_module(module_name,
- (jack_port_flags(jack_port) & JackPortIsInput) ? Input : Output);
- if (!module) {
- module = SharedPtr<PatchageModule>(
- new PatchageModule(patchage, module_name, InputOutput));
- module->load_location();
- patchage->canvas()->add_item(module);
- module->show();
- }
-
- boost::shared_ptr<PatchagePort> port = PtrCast<PatchagePort>(
- module->get_port(port_name));
- if (!port) {
- port = patchage->jack_driver()->create_port(module, jack_port);
- module->add_port(port);
- module->resize();
+ if ( ! _driver->create_port_view(patchage, _port_1)) {
+ cerr << "Unable to create port view (already exists?" << endl;
}
} else if (_type == PORT_DESTRUCTION) {
- SharedPtr<PatchagePort> port = find_port(patchage, _port_1);
+ SharedPtr<PatchagePort> port = _driver->find_port_view(patchage, _port_1);
if (port) {
SharedPtr<PatchageModule> module = PtrCast<PatchageModule>(port->module().lock());
@@ -128,8 +61,8 @@ PatchageEvent::execute(Patchage* patchage)
} else if (_type == CONNECTION) {
- SharedPtr<PatchagePort> port_1 = find_port(patchage, _port_1);
- SharedPtr<PatchagePort> port_2 = find_port(patchage, _port_2);
+ SharedPtr<PatchagePort> port_1 = _driver->find_port_view(patchage, _port_1);
+ SharedPtr<PatchagePort> port_2 = _driver->find_port_view(patchage, _port_2);
if (port_1 && port_2)
patchage->canvas()->add_connection(port_1, port_2, port_1->color() + 0x22222200);
@@ -138,8 +71,8 @@ PatchageEvent::execute(Patchage* patchage)
} else if (_type == DISCONNECTION) {
- SharedPtr<PatchagePort> port_1 = find_port(patchage, _port_1);
- SharedPtr<PatchagePort> port_2 = find_port(patchage, _port_2);
+ SharedPtr<PatchagePort> port_1 = _driver->find_port_view(patchage, _port_1);
+ SharedPtr<PatchagePort> port_2 = _driver->find_port_view(patchage, _port_2);
if (port_1 && port_2)
patchage->canvas()->remove_connection(port_1, port_2);