summaryrefslogtreecommitdiffstats
path: root/src/engine/ConnectionImpl.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-02-25 20:40:13 +0000
committerDavid Robillard <d@drobilla.net>2010-02-25 20:40:13 +0000
commit77a9beca75debd2d87d735fc4fe847694eee6f13 (patch)
treeae03699b999e84bc4c283abfd215c8037ecddaf6 /src/engine/ConnectionImpl.cpp
parente22984efe9b82ab006494aea93814a592cd44ece (diff)
downloadingen-77a9beca75debd2d87d735fc4fe847694eee6f13.tar.gz
ingen-77a9beca75debd2d87d735fc4fe847694eee6f13.tar.bz2
ingen-77a9beca75debd2d87d735fc4fe847694eee6f13.zip
Work on contexts and polymorphic ports.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2492 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine/ConnectionImpl.cpp')
-rw-r--r--src/engine/ConnectionImpl.cpp28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/engine/ConnectionImpl.cpp b/src/engine/ConnectionImpl.cpp
index 02955757..d3ec6cc7 100644
--- a/src/engine/ConnectionImpl.cpp
+++ b/src/engine/ConnectionImpl.cpp
@@ -19,13 +19,16 @@
#include "raul/log.hpp"
#include "raul/Maid.hpp"
#include "raul/IntrusivePtr.hpp"
+#include "shared/LV2URIMap.hpp"
#include "AudioBuffer.hpp"
#include "BufferFactory.hpp"
#include "ConnectionImpl.hpp"
#include "Engine.hpp"
#include "EventBuffer.hpp"
#include "InputPort.hpp"
+#include "InputPort.hpp"
#include "MessageContext.hpp"
+#include "OutputPort.hpp"
#include "PortImpl.hpp"
#include "ProcessContext.hpp"
#include "mix.hpp"
@@ -53,7 +56,7 @@ ConnectionImpl::ConnectionImpl(BufferFactory& bufs, PortImpl* src_port, PortImpl
assert(src_port->path() != dst_port->path());
if (must_mix() || must_queue())
- _local_buffer = bufs.get(dst_port->type(), dst_port->buffer_size(), true);
+ _local_buffer = bufs.get(dst_port->buffer_type(), dst_port->buffer_size(), true);
if (must_queue())
_queue = new Raul::RingBuffer<LV2_Object>(src_port->buffer_size() * 2);
@@ -82,7 +85,7 @@ void
ConnectionImpl::allocate_buffer(BufferFactory& bufs)
{
if (!_local_buffer)
- _local_buffer = bufs.get(_dst_port->type(), _dst_port->buffer_size());
+ _local_buffer = bufs.get(_dst_port->buffer_type(), _dst_port->buffer_size());
}
@@ -97,7 +100,7 @@ ConnectionImpl::prepare_poly(BufferFactory& bufs, uint32_t poly)
const bool mix = _src_port->prepared_poly() > _dst_port->prepared_poly();
if ((mix || must_queue()) && !_local_buffer)
- _local_buffer = bufs.get(_dst_port->type(), _dst_port->buffer(0)->size());
+ _local_buffer = bufs.get(_dst_port->buffer_type(), _dst_port->buffer(0)->size());
}
@@ -181,5 +184,24 @@ ConnectionImpl::queue(Context& context)
}
+bool
+ConnectionImpl::can_connect(const OutputPort* src, const InputPort* dst)
+{
+ const LV2URIMap& uris = Shared::LV2URIMap::instance();
+ return (
+ ( (src->is_a(PortType::CONTROL) || src->is_a(PortType::AUDIO))
+ && (dst->is_a(PortType::CONTROL) || dst->is_a(PortType::AUDIO)))
+ || ( src->is_a(PortType::EVENTS) && src->context() == Context::AUDIO
+ && dst->is_a(PortType::MESSAGE) && dst->context() == Context::MESSAGE)
+ || ( src->is_a(PortType::MESSAGE) && src->context() == Context::MESSAGE
+ && dst->is_a(PortType::EVENTS) && dst->context() == Context::AUDIO)
+ || (src->is_a(PortType::EVENTS) && dst->is_a(PortType::EVENTS))
+ || (src->is_a(PortType::CONTROL) && dst->supports(uris.object_class_float32))
+ || (src->is_a(PortType::AUDIO) && dst->supports(uris.object_class_vector))
+ || (src->supports(uris.object_class_float32) && dst->is_a(PortType::CONTROL))
+ || (src->supports(uris.object_class_vector) && dst->is_a(PortType::AUDIO)));
+}
+
+
} // namespace Ingen