From 4df8895cf62db13f03ad7165c9d2b1060b04de4c Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 13 Dec 2016 18:01:15 -0500 Subject: Don't use path to determine if nodes are the main graph Doing so is slower and touches std::string code that could in theory not be RT-safe (though always is in practice). --- src/server/InputPort.cpp | 4 ++-- src/server/NodeImpl.hpp | 8 ++++++++ src/server/PortImpl.cpp | 6 +++--- 3 files changed, 13 insertions(+), 5 deletions(-) (limited to 'src/server') diff --git a/src/server/InputPort.cpp b/src/server/InputPort.cpp index 61ce0c05..fc2abd56 100644 --- a/src/server/InputPort.cpp +++ b/src/server/InputPort.cpp @@ -152,7 +152,7 @@ InputPort::pre_process(RunContext& context) update_set_state(context, v); // Prepare for write in case a set event executes this cycle - if (!_parent->path().is_root()) { + if (!_parent->is_main()) { buffer(v)->prepare_write(context); } } @@ -251,7 +251,7 @@ bool InputPort::direct_connect() const { return _arcs.size() == 1 - && !_parent->path().is_root() + && !_parent->is_main() && !_arcs.front().must_mix() && buffer(0)->type() != _bufs.uris().atom_Sequence; } diff --git a/src/server/NodeImpl.hpp b/src/server/NodeImpl.hpp index dc85a757..517fbdb6 100644 --- a/src/server/NodeImpl.hpp +++ b/src/server/NodeImpl.hpp @@ -89,6 +89,14 @@ public: virtual bool apply_poly( RunContext& context, Raul::Maid& maid, uint32_t poly) = 0; + /** Return true iff this is main (the top level Node). + * + * This is sometimes called "the root graph", but the term "main" is used + * to avoid ambiguity with the root path, since main does not have the path + * "/", but usually "/main" to leave namespace for non-node things. + */ + bool is_main() const { return !_parent; } + protected: NodeImpl(const Ingen::URIs& uris, NodeImpl* parent, diff --git a/src/server/PortImpl.cpp b/src/server/PortImpl.cpp index 669e4b9d..c27cdb9e 100644 --- a/src/server/PortImpl.cpp +++ b/src/server/PortImpl.cpp @@ -298,7 +298,7 @@ PortImpl::update_set_state(RunContext& context, uint32_t v) if (state.time < context.start() && buf->is_sequence() && buf->value_type() == _bufs.uris().atom_Float && - !_parent->path().is_root()) { + !_parent->is_main()) { buf->clear(); state.time = context.start(); } @@ -325,7 +325,7 @@ bool PortImpl::prepare_poly(BufferFactory& bufs, uint32_t poly) { ThreadManager::assert_thread(THREAD_PRE_PROCESS); - if (_is_driver_port || _parent->path().is_root() || + if (_is_driver_port || _parent->is_main() || (_type == PortType::ATOM && !_value.is_valid())) { return false; } @@ -353,7 +353,7 @@ PortImpl::prepare_poly(BufferFactory& bufs, uint32_t poly) bool PortImpl::apply_poly(RunContext& context, Raul::Maid& maid, uint32_t poly) { - if (_parent->path().is_root() || + if (_parent->is_main() || (_type == PortType::ATOM && !_value.is_valid())) { return false; } -- cgit v1.2.1