diff options
author | David Robillard <d@drobilla.net> | 2011-04-20 16:26:40 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-04-20 16:26:40 +0000 |
commit | 138a87e915ad3aff184730415105f94c874174bf (patch) | |
tree | 0d942bdddfdbcc3d969b4fce5592e770ab851b86 /src/server/DuplexPort.cpp | |
parent | 1f1758f4dda0ddaf01c0b1d3a756f9db8ddc979d (diff) | |
download | ingen-138a87e915ad3aff184730415105f94c874174bf.tar.gz ingen-138a87e915ad3aff184730415105f94c874174bf.tar.bz2 ingen-138a87e915ad3aff184730415105f94c874174bf.zip |
Rename Ingen::Engine to Ingen::Server (hopefully avoid odd name clases and fix #675).
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3184 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/server/DuplexPort.cpp')
-rw-r--r-- | src/server/DuplexPort.cpp | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/src/server/DuplexPort.cpp b/src/server/DuplexPort.cpp new file mode 100644 index 00000000..773aab37 --- /dev/null +++ b/src/server/DuplexPort.cpp @@ -0,0 +1,99 @@ +/* This file is part of Ingen. + * Copyright 2007-2011 David Robillard <http://drobilla.net> + * + * Ingen is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <cstdlib> +#include <cassert> +#include <string> + +#include "shared/LV2URIMap.hpp" + +#include "ConnectionImpl.hpp" +#include "DuplexPort.hpp" +#include "EventBuffer.hpp" +#include "NodeImpl.hpp" +#include "OutputPort.hpp" +#include "ProcessContext.hpp" +#include "util.hpp" + +using namespace std; + +namespace Ingen { +namespace Server { + +DuplexPort::DuplexPort( + BufferFactory& bufs, + NodeImpl* parent, + const string& name, + uint32_t index, + bool polyphonic, + uint32_t poly, + PortType type, + const Raul::Atom& value, + size_t buffer_size, + bool is_output) + : PortImpl(bufs, parent, name, index, poly, type, value, buffer_size) + , InputPort(bufs, parent, name, index, poly, type, value, buffer_size) + , OutputPort(bufs, parent, name, index, poly, type, value, buffer_size) + , _is_output(is_output) +{ + assert(PortImpl::_parent == parent); + set_property(bufs.uris().ingen_polyphonic, polyphonic); +} + +bool +DuplexPort::get_buffers(BufferFactory& bufs, Raul::Array<BufferFactory::Ref>* buffers, uint32_t poly) +{ + if (_is_output) + return InputPort::get_buffers(bufs, buffers, poly); + else + return OutputPort::get_buffers(bufs, buffers, poly); +} + +/** Prepare for the execution of parent patch */ +void +DuplexPort::pre_process(Context& context) +{ + // If we're a patch output, we're an input from the internal perspective. + // Prepare buffers for write (so plugins can deliver to them) + if (_is_output) { + for (uint32_t v = 0; v < _poly; ++v) + _buffers->at(v)->prepare_write(context); + + // If we're a patch input, were an output from the internal perspective. + // Do whatever a normal node's input port does to prepare input for reading. + } else { + InputPort::pre_process(context); + } +} + +/** Finalize after the execution of parent patch (deliver outputs) */ +void +DuplexPort::post_process(Context& context) +{ + // If we're a patch output, we're an input from the internal perspective. + // Mix down input delivered by plugins so output (external perspective) is ready. + if (_is_output) { + InputPort::pre_process(context); + + if (_broadcast) + broadcast_value(context, false); + } +} + +} // namespace Server +} // namespace Ingen + |