From a51defebd91e66f83d1bdf58b7ac719e5def529b Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 20 Aug 2011 17:38:20 +0000 Subject: Fix compilation of Jack DBus driver (probably doesn't work correctly, though). git-svn-id: http://svn.drobilla.net/lad/trunk/patchage@3436 a436a847-0d15-0410-975c-d299462d15a1 --- src/JackDbusDriver.cpp | 86 +++++++++++++++++++------------------------------- src/JackDbusDriver.hpp | 10 +++--- 2 files changed, 38 insertions(+), 58 deletions(-) diff --git a/src/JackDbusDriver.cpp b/src/JackDbusDriver.cpp index 7b43e58..8deeabb 100644 --- a/src/JackDbusDriver.cpp +++ b/src/JackDbusDriver.cpp @@ -82,30 +82,18 @@ JackDriver::~JackDriver() } } +static bool +is_jack_port(const PatchagePort* port) +{ + return port->type() == JACK_AUDIO || port->type() == JACK_MIDI; +} + /** Destroy all JACK (canvas) ports. */ void JackDriver::destroy_all() { - FlowCanvas::Items modules = _app->canvas()->items(); // copy - for (FlowCanvas::Items::iterator m = modules.begin(); m != modules.end(); ++m) { - SharedPtr module = PtrCast(*m); - if (!module) - continue; - - FlowCanvas::Module::Ports ports = module->ports(); // copy - for (FlowCanvas::Module::Ports::iterator p = ports.begin(); p != ports.end(); ++p) { - SharedPtr port = boost::dynamic_pointer_cast(*p); - if (port && (port->type() == JACK_AUDIO || port->type() == JACK_MIDI)) { - _app->canvas()->remove_port(port->id()); - } - } - - if (module->ports().empty()) - _app->canvas()->remove_item(module); - else - _app->enqueue_resize(module); - } + _app->canvas()->remove_ports(is_jack_port); } void @@ -515,25 +503,21 @@ JackDriver::is_attached() const void JackDriver::add_port( - SharedPtr& module, - PortType type, - const std::string& name, - bool is_input) + PatchageModule* module, + PortType type, + const std::string& name, + bool is_input) { if (module->get_port(name)) { return; } - module->add_port( - SharedPtr( - new PatchagePort( - module, - type, - name, - is_input, - _app->state_manager()->get_port_color(type)))); - - _app->enqueue_resize(module); + new PatchagePort( + *module, + type, + name, + is_input, + _app->state_manager()->get_port_color(type)); } void @@ -568,7 +552,7 @@ JackDriver::add_port( } } - SharedPtr module = find_or_create_module(type, client_name); + PatchageModule* module = find_or_create_module(type, client_name); add_port(module, local_port_type, port_name, port_flags & JACKDBUS_PORT_FLAG_INPUT); } @@ -580,23 +564,19 @@ JackDriver::remove_port( dbus_uint64_t port_id, const char* port_name) { - SharedPtr port = _app->canvas()->find_port_by_name(client_name, port_name); + PatchagePort* port = _app->canvas()->find_port_by_name(client_name, port_name); if (!port) { error_msg("Unable to remove unknown port"); return; } - SharedPtr module = PtrCast(port->module().lock()); + PatchageModule* module = dynamic_cast(port->module()); - module->remove_port(port); - port.reset(); + delete port; // No empty modules (for now) if (module->num_ports() == 0) { - _app->canvas()->remove_item(module); - module.reset(); - } else { - _app->enqueue_resize(module); + delete module; } if (_app->canvas()->items().empty()) { @@ -608,15 +588,15 @@ JackDriver::remove_port( } } -SharedPtr +PatchageModule* JackDriver::find_or_create_module( ModuleType type, const std::string& name) { - SharedPtr module = _app->canvas()->find_module(name, type); + PatchageModule* module = _app->canvas()->find_module(name, type); if (!module) { - module = SharedPtr(new PatchageModule(_app, name, type)); + module = new PatchageModule(_app, name, type); module->load_location(); _app->canvas()->add_module(name, module); } @@ -636,13 +616,13 @@ JackDriver::connect_ports( dbus_uint64_t port2_id, const char* port2_name) { - SharedPtr port1 = _app->canvas()->find_port_by_name(client1_name, port1_name); + PatchagePort* port1 = _app->canvas()->find_port_by_name(client1_name, port1_name); if (!port1) { error_msg((std::string)"Unable to connect unknown port '" + port1_name + "' of client '" + client1_name + "'"); return; } - SharedPtr port2 = _app->canvas()->find_port_by_name(client2_name, port2_name); + PatchagePort* port2 = _app->canvas()->find_port_by_name(client2_name, port2_name); if (!port2) { error_msg((std::string)"Unable to connect unknown port '" + port2_name + "' of client '" + client2_name + "'"); return; @@ -663,13 +643,13 @@ JackDriver::disconnect_ports( dbus_uint64_t port2_id, const char* port2_name) { - SharedPtr port1 = _app->canvas()->find_port_by_name(client1_name, port1_name); + PatchagePort* port1 = _app->canvas()->find_port_by_name(client1_name, port1_name); if (!port1) { error_msg((std::string)"Unable to disconnect unknown port '" + port1_name + "' of client '" + client1_name + "'"); return; } - SharedPtr port2 = _app->canvas()->find_port_by_name(client2_name, port2_name); + PatchagePort* port2 = _app->canvas()->find_port_by_name(client2_name, port2_name); if (!port2) { error_msg((std::string)"Unable to disconnect unknown port '" + port2_name + "' of client '" + client2_name + "'"); return; @@ -853,9 +833,9 @@ JackDriver::connect( const char* port2_name; DBusMessage* reply_ptr; - client1_name = src->module().lock()->name().c_str(); + client1_name = src->module()->name().c_str(); port1_name = src->name().c_str(); - client2_name = dst->module().lock()->name().c_str(); + client2_name = dst->module()->name().c_str(); port2_name = dst->name().c_str(); if (!call(true, JACKDBUS_IFACE_PATCHBAY, "ConnectPortsByName", &reply_ptr, @@ -882,9 +862,9 @@ JackDriver::disconnect( const char* port2_name; DBusMessage* reply_ptr; - client1_name = src->module().lock()->name().c_str(); + client1_name = src->module()->name().c_str(); port1_name = src->name().c_str(); - client2_name = dst->module().lock()->name().c_str(); + client2_name = dst->module()->name().c_str(); port2_name = dst->name().c_str(); if (!call(true, JACKDBUS_IFACE_PATCHBAY, "DisconnectPortsByName", &reply_ptr, diff --git a/src/JackDbusDriver.hpp b/src/JackDbusDriver.hpp index ca4fb91..0debdc0 100644 --- a/src/JackDbusDriver.hpp +++ b/src/JackDbusDriver.hpp @@ -75,15 +75,15 @@ private: void error_msg(const std::string& msg) const; void info_msg(const std::string& msg) const; - boost::shared_ptr find_or_create_module( + PatchageModule* find_or_create_module( ModuleType type, const std::string& name); void add_port( - boost::shared_ptr& module, - PortType type, - const std::string& name, - bool is_input); + PatchageModule* module, + PortType type, + const std::string& name, + bool is_input); void add_port( dbus_uint64_t client_id, -- cgit v1.2.1