summaryrefslogtreecommitdiffstats
path: root/src/PatchageEvent.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-07-05 03:06:59 +0000
committerDavid Robillard <d@drobilla.net>2007-07-05 03:06:59 +0000
commit6067f8f8572bd7b318d3d17f16dc192079c7e046 (patch)
tree8f1b6a37ea61b72f918c672b282056c48098e5d9 /src/PatchageEvent.cpp
parent8006c612d557bd071f9ab033c82d27a499bdc0e6 (diff)
downloadpatchage-6067f8f8572bd7b318d3d17f16dc192079c7e046.tar.gz
patchage-6067f8f8572bd7b318d3d17f16dc192079c7e046.tar.bz2
patchage-6067f8f8572bd7b318d3d17f16dc192079c7e046.zip
More memory consumption reduction.
git-svn-id: http://svn.drobilla.net/lad/patchage@579 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/PatchageEvent.cpp')
-rw-r--r--src/PatchageEvent.cpp40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/PatchageEvent.cpp b/src/PatchageEvent.cpp
index 775f030..0d46c41 100644
--- a/src/PatchageEvent.cpp
+++ b/src/PatchageEvent.cpp
@@ -24,15 +24,15 @@
SharedPtr<PatchagePort>
-PatchageEvent::find_port(const PortRef& ref)
+PatchageEvent::find_port(const Patchage* patchage, const PortRef& ref)
{
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);
+ return patchage->canvas()->find_port(&ref.id.alsa_addr);
} else {
- if (!_patchage->jack_driver()->client())
+ if (!patchage->jack_driver()->client())
return boost::shared_ptr<PatchagePort>();
jack_port_t* jack_port = NULL;
@@ -40,7 +40,7 @@ PatchageEvent::find_port(const PortRef& ref)
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);
+ jack_port = jack_port_by_id(patchage->jack_driver()->client(), ref.id.jack_id);
if (!jack_port)
return boost::shared_ptr<PatchagePort>();
@@ -49,7 +49,7 @@ 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 = _patchage->canvas()->find_module(module_name,
+ SharedPtr<PatchageModule> module = patchage->canvas()->find_module(module_name,
(jack_port_flags(jack_port) & JackPortIsInput) ? Input : Output);
if (module)
@@ -63,14 +63,14 @@ PatchageEvent::find_port(const PortRef& ref)
void
-PatchageEvent::execute()
+PatchageEvent::execute(Patchage* patchage)
{
//cerr << "{ EXECUTING EVENT" << endl;
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 (patchage->jack_driver()->client())
+ jack_port = jack_port_by_id(patchage->jack_driver()->client(), _port_1.id.jack_id);
if (!jack_port)
return;
@@ -79,29 +79,29 @@ PatchageEvent::execute()
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,
+ 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));
+ new PatchageModule(patchage, module_name, InputOutput));
module->load_location();
module->store_location();
- _patchage->canvas()->add_item(module);
+ 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);
+ port = patchage->jack_driver()->create_port(module, jack_port);
module->add_port(port);
module->resize();
}
} else if (_type == PORT_DESTRUCTION) {
- SharedPtr<PatchagePort> port = find_port(_port_1);
+ SharedPtr<PatchagePort> port = find_port(patchage, _port_1);
if (port) {
SharedPtr<PatchageModule> module = PtrCast<PatchageModule>(port->module().lock());
@@ -111,7 +111,7 @@ PatchageEvent::execute()
module->remove_port(port);
//assert(removed_port == port);
if (module->num_ports() == 0) {
- _patchage->canvas()->remove_item(module);
+ patchage->canvas()->remove_item(module);
module.reset();
}
} else {
@@ -120,21 +120,21 @@ PatchageEvent::execute()
} else if (_type == CONNECTION) {
- SharedPtr<PatchagePort> port_1 = find_port(_port_1);
- SharedPtr<PatchagePort> port_2 = find_port(_port_2);
+ SharedPtr<PatchagePort> port_1 = find_port(patchage, _port_1);
+ SharedPtr<PatchagePort> port_2 = find_port(patchage, _port_2);
if (port_1 && port_2)
- _patchage->canvas()->add_connection(port_1, port_2, port_1->color() + 0x22222200);
+ patchage->canvas()->add_connection(port_1, port_2, port_1->color() + 0x22222200);
else
cerr << "Unable to find port to connect" << endl;
} else if (_type == DISCONNECTION) {
- SharedPtr<PatchagePort> port_1 = find_port(_port_1);
- SharedPtr<PatchagePort> port_2 = find_port(_port_2);
+ SharedPtr<PatchagePort> port_1 = find_port(patchage, _port_1);
+ SharedPtr<PatchagePort> port_2 = find_port(patchage, _port_2);
if (port_1 && port_2)
- _patchage->canvas()->remove_connection(port_1, port_2);
+ patchage->canvas()->remove_connection(port_1, port_2);
else
cerr << "Unable to find port to disconnect" << endl;
}