From 59d6a7095c79a84475b95cb4121d9e3845806d16 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 7 Oct 2011 00:13:35 +0000 Subject: Tidy. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3537 a436a847-0d15-0410-975c-d299462d15a1 --- src/server/PatchImpl.cpp | 69 ++++++++++++++++++++++++++++-------------------- 1 file changed, 41 insertions(+), 28 deletions(-) (limited to 'src/server/PatchImpl.cpp') diff --git a/src/server/PatchImpl.cpp b/src/server/PatchImpl.cpp index e253e7b3..4f26473f 100644 --- a/src/server/PatchImpl.cpp +++ b/src/server/PatchImpl.cpp @@ -71,7 +71,7 @@ PatchImpl::activate(BufferFactory& bufs) { NodeImpl::activate(bufs); - for (List::iterator i = _nodes.begin(); i != _nodes.end(); ++i) + for (Nodes::iterator i = _nodes.begin(); i != _nodes.end(); ++i) (*i)->activate(bufs); assert(_activated); @@ -83,7 +83,7 @@ PatchImpl::deactivate() if (_activated) { NodeImpl::deactivate(); - for (List::iterator i = _nodes.begin(); i != _nodes.end(); ++i) { + for (Nodes::iterator i = _nodes.begin(); i != _nodes.end(); ++i) { if ((*i)->activated()) (*i)->deactivate(); assert(!(*i)->activated()); @@ -99,7 +99,7 @@ PatchImpl::disable() _process = false; - for (List::iterator i = _output_ports.begin(); i != _output_ports.end(); ++i) + for (Ports::iterator i = _outputs.begin(); i != _outputs.end(); ++i) if ((*i)->context() == Context::AUDIO) (*i)->clear_buffers(); } @@ -111,10 +111,10 @@ PatchImpl::prepare_internal_poly(BufferFactory& bufs, uint32_t poly) // TODO: Subpatch dynamic polyphony (i.e. changing port polyphony) - for (List::iterator i = _nodes.begin(); i != _nodes.end(); ++i) + for (Nodes::iterator i = _nodes.begin(); i != _nodes.end(); ++i) (*i)->prepare_poly(bufs, poly); - for (List::iterator i = _nodes.begin(); i != _nodes.end(); ++i) + for (Nodes::iterator i = _nodes.begin(); i != _nodes.end(); ++i) for (uint32_t j = 0; j < (*i)->num_ports(); ++j) (*i)->port_impl(j)->prepare_poly_buffers(bufs); @@ -122,16 +122,19 @@ PatchImpl::prepare_internal_poly(BufferFactory& bufs, uint32_t poly) } bool -PatchImpl::apply_internal_poly(ProcessContext& context, BufferFactory& bufs, Raul::Maid& maid, uint32_t poly) +PatchImpl::apply_internal_poly(ProcessContext& context, + BufferFactory& bufs, + Raul::Maid& maid, + uint32_t poly) { ThreadManager::assert_thread(THREAD_PROCESS); // TODO: Subpatch dynamic polyphony (i.e. changing port polyphony) - for (List::iterator i = _nodes.begin(); i != _nodes.end(); ++i) + for (Nodes::iterator i = _nodes.begin(); i != _nodes.end(); ++i) (*i)->apply_poly(maid, poly); - for (List::iterator i = _nodes.begin(); i != _nodes.end(); ++i) { + for (Nodes::iterator i = _nodes.begin(); i != _nodes.end(); ++i) { for (uint32_t j = 0; j < (*i)->num_ports(); ++j) { PortImpl* const port = (*i)->port_impl(j); if (port->is_input() && dynamic_cast(port)->direct_connect()) @@ -141,7 +144,7 @@ PatchImpl::apply_internal_poly(ProcessContext& context, BufferFactory& bufs, Rau } const bool polyphonic = parent_patch() && (poly == parent_patch()->internal_poly()); - for (List::iterator i = _output_ports.begin(); i != _output_ports.end(); ++i) + for (Ports::iterator i = _outputs.begin(); i != _outputs.end(); ++i) (*i)->setup_buffers(bufs, polyphonic ? poly : 1); _internal_poly = poly; @@ -252,7 +255,10 @@ PatchImpl::process_single(ProcessContext& context) } void -PatchImpl::set_buffer_size(Context& context, BufferFactory& bufs, PortType type, size_t size) +PatchImpl::set_buffer_size(Context& context, + BufferFactory& bufs, + PortType type, + size_t size) { NodeImpl::set_buffer_size(context, bufs, type, size); @@ -266,7 +272,7 @@ PatchImpl::set_buffer_size(Context& context, BufferFactory& bufs, PortType type, * Preprocessing thread only. */ void -PatchImpl::add_node(List::Node* ln) +PatchImpl::add_node(Nodes::Node* ln) { ThreadManager::assert_thread(THREAD_PRE_PROCESS); assert(ln != NULL); @@ -284,7 +290,7 @@ PatchImpl::Nodes::Node* PatchImpl::remove_node(const Raul::Symbol& symbol) { ThreadManager::assert_thread(THREAD_PRE_PROCESS); - for (List::iterator i = _nodes.begin(); i != _nodes.end(); ++i) + for (Nodes::iterator i = _nodes.begin(); i != _nodes.end(); ++i) if ((*i)->symbol() == symbol) return _nodes.erase(i); @@ -330,21 +336,24 @@ PatchImpl::num_ports() const if (ThreadManager::thread_is(THREAD_PROCESS)) return NodeImpl::num_ports(); else - return _input_ports.size() + _output_ports.size(); + return _inputs.size() + _outputs.size(); } /** Create a port. Not realtime safe. */ PortImpl* -PatchImpl::create_port(BufferFactory& bufs, const string& name, PortType type, size_t buffer_size, bool is_output, bool polyphonic) +PatchImpl::create_port(BufferFactory& bufs, + const string& name, + PortType type, + size_t buffer_size, + bool is_output, + bool polyphonic) { if (type == PortType::UNKNOWN) { error << "[PatchImpl::create_port] Unknown port type " << type.uri() << endl; return NULL; } - assert( !(type == PortType::UNKNOWN) ); - Raul::Atom value; if (type == PortType::CONTROL) value = 0.0f; @@ -360,25 +369,25 @@ PatchImpl::create_port(BufferFactory& bufs, const string& name, PortType type, s * * Realtime safe. Preprocessing thread only. */ -List::Node* +PatchImpl::Ports::Node* PatchImpl::remove_port(const string& symbol) { ThreadManager::assert_thread(THREAD_PRE_PROCESS); bool found = false; - List::Node* ret = NULL; - for (List::iterator i = _input_ports.begin(); i != _input_ports.end(); ++i) { + Ports::Node* ret = NULL; + for (Ports::iterator i = _inputs.begin(); i != _inputs.end(); ++i) { if ((*i)->symbol() == symbol) { - ret = _input_ports.erase(i); + ret = _inputs.erase(i); found = true; break; } } if (!found) - for (List::iterator i = _output_ports.begin(); i != _output_ports.end(); ++i) { + for (Ports::iterator i = _outputs.begin(); i != _outputs.end(); ++i) { if ((*i)->symbol() == symbol) { - ret = _output_ports.erase(i); + ret = _outputs.erase(i); found = true; break; } @@ -402,8 +411,8 @@ PatchImpl::clear_ports() { ThreadManager::assert_thread(THREAD_PRE_PROCESS); - _input_ports.clear(); - _output_ports.clear(); + _inputs.clear(); + _outputs.clear(); } Raul::Array* @@ -411,16 +420,19 @@ PatchImpl::build_ports_array() const { ThreadManager::assert_thread(THREAD_PRE_PROCESS); - Raul::Array* const result = new Raul::Array(_input_ports.size() + _output_ports.size()); + const size_t n = _inputs.size() + _outputs.size(); + Raul::Array* const result = new Raul::Array(n); size_t i = 0; - for (List::const_iterator p = _input_ports.begin(); p != _input_ports.end(); ++p,++i) + for (Ports::const_iterator p = _inputs.begin(); p != _inputs.end(); ++p,++i) result->at(i) = *p; - for (List::const_iterator p = _output_ports.begin(); p != _output_ports.end(); ++p,++i) + for (Ports::const_iterator p = _outputs.begin(); p != _outputs.end(); ++p,++i) result->at(i) = *p; + assert(i == n - 1); + return result; } @@ -459,7 +471,8 @@ PatchImpl::compile() const } // Add any queued connections that must be run after a cycle - for (Connections::const_iterator i = _connections.begin(); i != _connections.end(); ++i) { + for (Connections::const_iterator i = _connections.begin(); + i != _connections.end(); ++i) { SharedPtr c = PtrCast(i->second); if (c->src_port()->context() == Context::AUDIO && c->dst_port()->context() == Context::MESSAGE) { -- cgit v1.2.1