diff options
author | David Robillard <d@drobilla.net> | 2012-08-14 22:48:58 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-08-14 22:48:58 +0000 |
commit | 68c2d72ba4e2208ff926461bb6faccfbadcf2a61 (patch) | |
tree | ebda7b74b59165a7732293aad53228952e0b9e72 | |
parent | 76b602f1f834cb2c255848c5ba887b3d7c47171a (diff) | |
download | ingen-68c2d72ba4e2208ff926461bb6faccfbadcf2a61.tar.gz ingen-68c2d72ba4e2208ff926461bb6faccfbadcf2a61.tar.bz2 ingen-68c2d72ba4e2208ff926461bb6faccfbadcf2a61.zip |
Don't look up system ports by path in the audio thread.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4697 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | src/server/DirectDriver.hpp | 7 | ||||
-rw-r--r-- | src/server/Driver.hpp | 8 | ||||
-rw-r--r-- | src/server/JackDriver.cpp | 13 | ||||
-rw-r--r-- | src/server/JackDriver.hpp | 5 | ||||
-rw-r--r-- | src/server/events/Delete.cpp | 9 | ||||
-rw-r--r-- | src/server/ingen_lv2.cpp | 15 |
6 files changed, 30 insertions, 27 deletions
diff --git a/src/server/DirectDriver.hpp b/src/server/DirectDriver.hpp index b6d66df6..8acb3f11 100644 --- a/src/server/DirectDriver.hpp +++ b/src/server/DirectDriver.hpp @@ -47,11 +47,12 @@ public: return NULL; } + virtual EnginePort* port(const Raul::Path& path) { return NULL; } + virtual void add_port(ProcessContext& context, EnginePort* port) {} - virtual Raul::Deletable* remove_port(ProcessContext& context, - const Raul::Path& path, - EnginePort** port = NULL) { + virtual Raul::Deletable* remove_port(ProcessContext& context, + EnginePort* port) { return NULL; } diff --git a/src/server/Driver.hpp b/src/server/Driver.hpp index c96545b9..da9f09a5 100644 --- a/src/server/Driver.hpp +++ b/src/server/Driver.hpp @@ -60,13 +60,15 @@ public: virtual EnginePort* engine_port(ProcessContext& context, const Raul::Path& path) = 0; + /** Find a system port by path. */ + virtual EnginePort* port(const Raul::Path& path) = 0; + /** Add a system visible port (e.g. a port on the root patch). */ virtual void add_port(ProcessContext& context, EnginePort* port) = 0; /** Remove a system visible port. */ - virtual Raul::Deletable* remove_port(ProcessContext& context, - const Raul::Path& path, - EnginePort** port = NULL) = 0; + virtual Raul::Deletable* remove_port(ProcessContext& context, + EnginePort* port) = 0; /** Return the audio buffer size in frames */ virtual SampleCount block_length() const = 0; diff --git a/src/server/JackDriver.cpp b/src/server/JackDriver.cpp index e24bc13a..372feaa6 100644 --- a/src/server/JackDriver.cpp +++ b/src/server/JackDriver.cpp @@ -327,20 +327,15 @@ JackDriver::add_port(ProcessContext& context, EnginePort* port) * It is the callers responsibility to delete the returned port. */ Raul::Deletable* -JackDriver::remove_port(ProcessContext& context, - const Raul::Path& path, - EnginePort** port) +JackDriver::remove_port(ProcessContext& context, + EnginePort* port) { for (Raul::List<JackPort*>::iterator i = _ports.begin(); i != _ports.end(); ++i) { - if ((*i)->patch_port()->path() == path) { - Raul::List<JackPort*>::Node* node = _ports.erase(i); - if (port) - *port = node->elem(); - return node; + if (*i == port) { + return _ports.erase(i); } } - LOG(Raul::warn)(Raul::fmt("Unable to find port %1%\n") % path.c_str()); return NULL; } diff --git a/src/server/JackDriver.hpp b/src/server/JackDriver.hpp index 76d9b3be..b41ebca5 100644 --- a/src/server/JackDriver.hpp +++ b/src/server/JackDriver.hpp @@ -101,9 +101,8 @@ public: void add_port(ProcessContext& context, EnginePort* port); EnginePort* engine_port(ProcessContext& context, const Raul::Path& path); - Raul::Deletable* remove_port(ProcessContext& context, - const Raul::Path& path, - EnginePort** port = NULL); + Raul::Deletable* remove_port(ProcessContext& context, + EnginePort* port); /** Transport state for this frame. * Intended to only be called from the audio thread. */ diff --git a/src/server/events/Delete.cpp b/src/server/events/Delete.cpp index 96668af1..97f1161f 100644 --- a/src/server/events/Delete.cpp +++ b/src/server/events/Delete.cpp @@ -109,6 +109,10 @@ Delete::pre_process() _ports_array = _port->parent_patch()->build_ports_array(); assert(_ports_array->size() == _port->parent_patch()->num_ports_non_rt()); } + + if (!_port->parent_patch()->parent()) { + _engine_port = _engine.driver()->port(_port->path()); + } } } @@ -140,8 +144,9 @@ Delete::execute(ProcessContext& context) _engine.maid()->push(_port->parent_patch()->external_ports()); _port->parent_patch()->external_ports(_ports_array); - if ( ! _port->parent_patch()->parent()) - _garbage = _engine.driver()->remove_port(context, _port->path(), &_engine_port); + if (_engine_port) { + _garbage = _engine.driver()->remove_port(context, _engine_port); + } } if (parent_patch) { diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp index 4c9c7d85..1ad6ac72 100644 --- a/src/server/ingen_lv2.cpp +++ b/src/server/ingen_lv2.cpp @@ -209,25 +209,26 @@ public: virtual void set_root_patch(PatchImpl* patch) { _root_patch = patch; } virtual PatchImpl* root_patch() { return _root_patch; } + /** Unused since LV2 has no dynamic ports. */ + EnginePort* port(const Raul::Path& path) { return NULL; } + + /** Doesn't have to be real-time safe since LV2 has no dynamic ports. */ virtual void add_port(ProcessContext& context, EnginePort* port) { - // Note this doesn't have to be realtime safe since there's no dynamic LV2 ports assert(dynamic_cast<LV2Port*>(port)); assert(port->patch_port()->index() == _ports.size()); _ports.push_back((LV2Port*)port); } - virtual Raul::Deletable* remove_port(ProcessContext& context, - const Raul::Path& path, - EnginePort** port = NULL) { - // Note this doesn't have to be realtime safe since there's no dynamic LV2 ports + /** Doesn't have to be real-time safe since LV2 has no dynamic ports. */ + virtual Raul::Deletable* remove_port(ProcessContext& context, + EnginePort* port) { for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) { - if ((*i)->patch_port()->path() == path) { + if (*i == port) { _ports.erase(i); return NULL; } } - Raul::warn << "Unable to find port " << path << std::endl; return NULL; } |