summaryrefslogtreecommitdiffstats
path: root/src/engine
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
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')
-rw-r--r--src/engine/ConnectionImpl.cpp28
-rw-r--r--src/engine/ConnectionImpl.hpp4
-rw-r--r--src/engine/InputPort.cpp8
-rw-r--r--src/engine/JackDriver.cpp13
-rw-r--r--src/engine/LADSPANode.cpp8
-rw-r--r--src/engine/LV2Node.cpp22
-rw-r--r--src/engine/ObjectSender.cpp7
-rw-r--r--src/engine/OutputPort.cpp2
-rw-r--r--src/engine/PortImpl.cpp28
-rw-r--r--src/engine/PortImpl.hpp30
-rw-r--r--src/engine/events/Connect.cpp72
-rw-r--r--src/engine/events/Connect.hpp2
-rw-r--r--src/engine/events/Disconnect.cpp10
-rw-r--r--src/engine/events/RequestMetadata.cpp15
-rw-r--r--src/engine/events/SetMetadata.cpp2
-rw-r--r--src/engine/events/SetPortValue.cpp2
16 files changed, 146 insertions, 107 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
diff --git a/src/engine/ConnectionImpl.hpp b/src/engine/ConnectionImpl.hpp
index 896b055b..232d8033 100644
--- a/src/engine/ConnectionImpl.hpp
+++ b/src/engine/ConnectionImpl.hpp
@@ -32,6 +32,8 @@ using namespace std;
namespace Ingen {
class PortImpl;
+class OutputPort;
+class InputPort;
class Buffer;
class BufferFactory;
@@ -92,6 +94,8 @@ public:
/** Returns true if this connection crosses contexts and must buffer */
inline bool must_queue() const { return _src_port->context() != _dst_port->context(); }
+ static bool can_connect(const OutputPort* src, const InputPort* dst);
+
protected:
void dump() const;
diff --git a/src/engine/InputPort.cpp b/src/engine/InputPort.cpp
index f9ddbfe2..d5051865 100644
--- a/src/engine/InputPort.cpp
+++ b/src/engine/InputPort.cpp
@@ -93,7 +93,7 @@ InputPort::get_buffers(BufferFactory& bufs, Raul::Array<BufferFactory::Ref>* buf
size_t num_connections = (ThreadManager::current_thread_id() == THREAD_PROCESS)
? _connections.size() : _num_connections;
- if (_type == PortType::AUDIO && num_connections == 0) {
+ if (buffer_type() == PortType::AUDIO && num_connections == 0) {
// Audio input with no connections, use shared zero buffer
for (uint32_t v = 0; v < poly; ++v)
buffers->at(v) = bufs.silent_buffer();
@@ -113,7 +113,7 @@ InputPort::get_buffers(BufferFactory& bufs, Raul::Array<BufferFactory::Ref>* buf
// Use local buffers
for (uint32_t v = 0; v < poly; ++v) {
buffers->at(v) = NULL; // Release first (potential immediate recycling)
- buffers->at(v) = _bufs.get(_type, _buffer_size);
+ buffers->at(v) = _bufs.get(buffer_type(), _buffer_size);
buffers->at(v)->clear();
}
}
@@ -136,7 +136,7 @@ InputPort::add_connection(Connections::Node* const c)
_connections.push_back(c);
// Automatically broadcast connected control inputs
- if (_type == PortType::CONTROL)
+ if (is_a(PortType::CONTROL))
_broadcast = true;
}
@@ -170,7 +170,7 @@ InputPort::remove_connection(ProcessContext& context, const OutputPort* src_port
}
// Turn off broadcasting if we're no longer connected
- if (_type == PortType::CONTROL && _connections.size() == 0)
+ if (is_a(PortType::CONTROL) && _connections.size() == 0)
_broadcast = false;
return connection;
diff --git a/src/engine/JackDriver.cpp b/src/engine/JackDriver.cpp
index a604aeae..6c66cba3 100644
--- a/src/engine/JackDriver.cpp
+++ b/src/engine/JackDriver.cpp
@@ -77,7 +77,7 @@ JackPort::create()
_jack_port = jack_port_register(
_driver->jack_client(),
ingen_jack_port_name(_patch_port->path()).c_str(),
- (_patch_port->type() == PortType::AUDIO)
+ (_patch_port->buffer_type() == PortType::AUDIO)
? JACK_DEFAULT_AUDIO_TYPE : JACK_DEFAULT_MIDI_TYPE,
(_patch_port->is_input())
? JackPortIsInput : JackPortIsOutput,
@@ -115,13 +115,13 @@ JackPort::pre_process(ProcessContext& context)
const SampleCount nframes = context.nframes();
- if (_patch_port->type() == PortType::AUDIO) {
+ if (_patch_port->buffer_type() == PortType::AUDIO) {
jack_sample_t* jack_buf = (jack_sample_t*)jack_port_get_buffer(_jack_port, nframes);
AudioBuffer* patch_buf = (AudioBuffer*)_patch_port->buffer(0).get();
patch_buf->copy(jack_buf, 0, nframes - 1);
- } else if (_patch_port->type() == PortType::EVENTS) {
+ } else if (_patch_port->buffer_type() == PortType::EVENTS) {
void* jack_buf = jack_port_get_buffer(_jack_port, nframes);
EventBuffer* patch_buf = (EventBuffer*)_patch_port->buffer(0).get();
@@ -149,13 +149,13 @@ JackPort::post_process(ProcessContext& context)
const SampleCount nframes = context.nframes();
- if (_patch_port->type() == PortType::AUDIO) {
+ if (_patch_port->buffer_type() == PortType::AUDIO) {
jack_sample_t* jack_buf = (jack_sample_t*)jack_port_get_buffer(_jack_port, nframes);
AudioBuffer* patch_buf = (AudioBuffer*)_patch_port->buffer(0).get();
memcpy(jack_buf, patch_buf->data(), nframes * sizeof(Sample));
- } else if (_patch_port->type() == PortType::EVENTS) {
+ } else if (_patch_port->buffer_type() == PortType::EVENTS) {
void* jack_buf = jack_port_get_buffer(_jack_port, context.nframes());
EventBuffer* patch_buf = (EventBuffer*)_patch_port->buffer(0).get();
@@ -367,7 +367,8 @@ DriverPort*
JackDriver::create_port(DuplexPort* patch_port)
{
try {
- if (patch_port->type() == PortType::AUDIO || patch_port->type() == PortType::EVENTS)
+ if (patch_port->buffer_type() == PortType::AUDIO
+ || patch_port->buffer_type() == PortType::EVENTS)
return new JackPort(this, patch_port);
else
return NULL;
diff --git a/src/engine/LADSPANode.cpp b/src/engine/LADSPANode.cpp
index ec793915..ddcb774f 100644
--- a/src/engine/LADSPANode.cpp
+++ b/src/engine/LADSPANode.cpp
@@ -89,10 +89,10 @@ LADSPANode::prepare_poly(BufferFactory& bufs, uint32_t poly)
PortImpl* const port = _ports->at(j);
Buffer* const buffer = port->prepared_buffer(i).get();
if (buffer) {
- if (port->type() == PortType::CONTROL) {
+ if (port->is_a(PortType::CONTROL)) {
((AudioBuffer*)buffer)->set_value(port->value().get_float(), 0, 0);
- } else if (port->type() == PortType::AUDIO) {
- ((AudioBuffer*)buffer)->set_value(0.0f, 0, 0);
+ } else {
+ buffer->clear();
}
}
}
@@ -281,7 +281,7 @@ LADSPANode::set_port_buffer(uint32_t voice, uint32_t port_num,
NodeImpl::set_port_buffer(voice, port_num, buf, offset);
_descriptor->connect_port(instance(voice), port_num,
- buf ? (LADSPA_Data*)buf->port_data(_ports->at(port_num)->type(), offset) : NULL);
+ buf ? (LADSPA_Data*)buf->port_data(_ports->at(port_num)->buffer_type(), offset) : NULL);
}
diff --git a/src/engine/LV2Node.cpp b/src/engine/LV2Node.cpp
index 60bb2bbb..b682ca4e 100644
--- a/src/engine/LV2Node.cpp
+++ b/src/engine/LV2Node.cpp
@@ -94,10 +94,10 @@ LV2Node::prepare_poly(BufferFactory& bufs, uint32_t poly)
PortImpl* const port = _ports->at(j);
Buffer* const buffer = port->prepared_buffer(i).get();
if (buffer) {
- if (port->type() == PortType::CONTROL) {
+ if (port->is_a(PortType::CONTROL)) {
((AudioBuffer*)buffer)->set_value(port->value().get_float(), 0, 0);
- } else if (port->type() == PortType::AUDIO) {
- ((AudioBuffer*)buffer)->set_value(0.0f, 0, 0);
+ } else {
+ buffer->clear();
}
}
}
@@ -201,6 +201,9 @@ LV2Node::instantiate(BufferFactory& bufs)
SLV2Value port_property_pred = slv2_value_new_uri(info->lv2_world(),
"http://lv2plug.in/ns/lv2core#portProperty");
+ SLV2Value supports_pred = slv2_value_new_uri(info->lv2_world(),
+ LV2_OBJECT_URI "#supports");
+
//SLV2Value as_large_as_pred = slv2_value_new_uri(info->lv2_world(),
// "http://lv2plug.in/ns/dev/resize-port#asLargeAs");
@@ -302,6 +305,17 @@ LV2Node::instantiate(BufferFactory& bufs)
}
}
+ // Set obj:supports properties
+ SLV2Values types = slv2_port_get_value(plug, id, supports_pred);
+ for (uint32_t i = 0; i < slv2_values_size(types); ++i) {
+ SLV2Value type = slv2_values_get_at(types, i);
+ std::cout << path() << " port " << id << " supports " <<
+ slv2_value_as_uri(type) << std::endl;
+ if (slv2_value_is_uri(type)) {
+ port->add_property(uris.obj_supports, Raul::URI(slv2_value_as_uri(type)));
+ }
+ }
+
SLV2Values contexts = slv2_port_get_value(plug, id, context_pred);
for (uint32_t i = 0; i < slv2_values_size(contexts); ++i) {
SLV2Value c = slv2_values_get_at(contexts, i);
@@ -397,7 +411,7 @@ LV2Node::set_port_buffer(uint32_t voice, uint32_t port_num,
{
NodeImpl::set_port_buffer(voice, port_num, buf, offset);
slv2_instance_connect_port(instance(voice), port_num,
- buf ? buf->port_data(_ports->at(port_num)->type(), offset) : NULL);
+ buf ? buf->port_data(_ports->at(port_num)->buffer_type(), offset) : NULL);
}
diff --git a/src/engine/ObjectSender.cpp b/src/engine/ObjectSender.cpp
index adb35f13..0055dff1 100644
--- a/src/engine/ObjectSender.cpp
+++ b/src/engine/ObjectSender.cpp
@@ -141,11 +141,8 @@ ObjectSender::send_port(ClientInterface* client, const PortImpl* port, bool bund
client->put(port->path(), port->properties());
// Send control value
- if (port->type() == PortType::CONTROL) {
- //const Sample& value = PtrCast<const AudioBuffer>(port->buffer(0))->value_at(0);
- const Sample& value = ((const AudioBuffer*)port->buffer(0).get())->value_at(0);
- client->set_property(port->path(), map.ingen_value, value);
- }
+ if (port->is_a(PortType::CONTROL))
+ client->set_property(port->path(), map.ingen_value, port->value());
if (bundle)
client->bundle_end();
diff --git a/src/engine/OutputPort.cpp b/src/engine/OutputPort.cpp
index 269d6da6..c2381cff 100644
--- a/src/engine/OutputPort.cpp
+++ b/src/engine/OutputPort.cpp
@@ -55,7 +55,7 @@ void
OutputPort::get_buffers(BufferFactory& bufs, Raul::Array<BufferFactory::Ref>* buffers, uint32_t poly)
{
for (uint32_t v = 0; v < poly; ++v)
- buffers->at(v) = bufs.get(_type, _buffer_size);
+ buffers->at(v) = bufs.get(buffer_type(), _buffer_size);
}
diff --git a/src/engine/PortImpl.cpp b/src/engine/PortImpl.cpp
index 1f2c6530..a1a20ba8 100644
--- a/src/engine/PortImpl.cpp
+++ b/src/engine/PortImpl.cpp
@@ -53,7 +53,7 @@ PortImpl::PortImpl(BufferFactory& bufs,
, _index(index)
, _poly(poly)
, _buffer_size(buffer_size)
- , _type(type)
+ , _buffer_type(type)
, _value(value)
, _broadcast(false)
, _set_by_user(false)
@@ -62,6 +62,7 @@ PortImpl::PortImpl(BufferFactory& bufs,
, _buffers(new Array<BufferFactory::Ref>(static_cast<size_t>(poly)))
, _prepared_buffers(NULL)
{
+ _types.insert(type);
assert(node != NULL);
assert(_poly > 0);
@@ -84,6 +85,13 @@ PortImpl::~PortImpl()
}
+bool
+PortImpl::supports(const Raul::URI& value_type) const
+{
+ return has_property(Shared::LV2URIMap::instance().obj_supports, value_type);
+}
+
+
Raul::Array<BufferFactory::Ref>*
PortImpl::set_buffers(Raul::Array<BufferFactory::Ref>* buffers)
{
@@ -105,7 +113,7 @@ bool
PortImpl::prepare_poly(BufferFactory& bufs, uint32_t poly)
{
ThreadManager::assert_thread(THREAD_PRE_PROCESS);
- if (_type != PortType::CONTROL && _type != PortType::AUDIO)
+ if (buffer_type() != PortType::CONTROL && buffer_type() != PortType::AUDIO)
return false;
if (_poly == poly)
@@ -130,7 +138,7 @@ bool
PortImpl::apply_poly(Maid& maid, uint32_t poly)
{
ThreadManager::assert_thread(THREAD_PROCESS);
- if (_type != PortType::CONTROL && _type != PortType::AUDIO)
+ if (buffer_type() != PortType::CONTROL && buffer_type() != PortType::AUDIO)
return false;
if (!_prepared_buffers)
@@ -145,7 +153,7 @@ PortImpl::apply_poly(Maid& maid, uint32_t poly)
assert(_buffers == _prepared_buffers);
_prepared_buffers = NULL;
- if (_type == PortType::CONTROL)
+ if (is_a(PortType::CONTROL))
for (uint32_t v = 0; v < _poly; ++v)
if (_buffers->at(v))
boost::static_pointer_cast<AudioBuffer>(_buffers->at(v))->set_value(
@@ -199,7 +207,7 @@ void
PortImpl::broadcast_value(Context& context, bool force)
{
Raul::Atom val;
- switch (_type.symbol()) {
+ switch (buffer_type().symbol()) {
case PortType::UNKNOWN:
break;
case PortType::AUDIO:
@@ -214,7 +222,7 @@ PortImpl::broadcast_value(Context& context, bool force)
break;
case PortType::VALUE:
case PortType::MESSAGE:
- LV2Object::to_atom(context.engine().world(), ((ObjectBuffer*)buffer(0).get())->object(), val);
+ LV2Object::to_atom(((ObjectBuffer*)buffer(0).get())->object(), val);
break;
}
@@ -242,4 +250,12 @@ PortImpl::set_context(Context::ID c)
}
+PortType
+PortImpl::buffer_type() const
+{
+ // TODO: multiple types
+ return *_types.begin();
+}
+
+
} // namespace Ingen
diff --git a/src/engine/PortImpl.hpp b/src/engine/PortImpl.hpp
index 6771b78a..637336af 100644
--- a/src/engine/PortImpl.hpp
+++ b/src/engine/PortImpl.hpp
@@ -20,6 +20,7 @@
#include <cstdlib>
#include <string>
+#include <set>
#include "raul/Array.hpp"
#include "raul/Atom.hpp"
#include "interface/Port.hpp"
@@ -103,8 +104,13 @@ public:
virtual bool is_input() const = 0;
virtual bool is_output() const = 0;
- uint32_t index() const { return _index; }
- Shared::PortType type() const { return _type; }
+ uint32_t index() const { return _index; }
+
+ const PortTypes& types() const { return _types; }
+
+ PortType buffer_type() const;
+
+ bool supports(const Raul::URI& value_type) const;
size_t buffer_size() const { return _buffer_size; }
@@ -116,6 +122,7 @@ public:
}
void set_buffer_size(Context& context, BufferFactory& bufs, size_t size);
+ void set_buffer_type(PortType type);
void broadcast(bool b) { _broadcast = b; }
bool broadcast() { return _broadcast; }
@@ -137,15 +144,16 @@ protected:
const Raul::Atom& value,
size_t buffer_size);
- BufferFactory& _bufs;
- uint32_t _index;
- uint32_t _poly;
- uint32_t _buffer_size;
- Shared::PortType _type;
- Raul::Atom _value;
- bool _broadcast;
- bool _set_by_user;
- Raul::Atom _last_broadcasted_value;
+ BufferFactory& _bufs;
+ uint32_t _index;
+ uint32_t _poly;
+ uint32_t _buffer_size;
+ PortType _buffer_type;
+ std::set<Shared::PortType> _types;
+ Raul::Atom _value;
+ bool _broadcast;
+ bool _set_by_user;
+ Raul::Atom _last_broadcasted_value;
Context::ID _context;
Raul::Array<BufferFactory::Ref>* _buffers;
diff --git a/src/engine/events/Connect.cpp b/src/engine/events/Connect.cpp
index b4389438..5b7726d9 100644
--- a/src/engine/events/Connect.cpp
+++ b/src/engine/events/Connect.cpp
@@ -47,8 +47,6 @@ Connect::Connect(Engine& engine, SharedPtr<Request> request, SampleCount timesta
, _src_port_path(src_port_path)
, _dst_port_path(dst_port_path)
, _patch(NULL)
- , _src_port(NULL)
- , _dst_port(NULL)
, _src_output_port(NULL)
, _dst_input_port(NULL)
, _compiled_patch(NULL)
@@ -61,58 +59,46 @@ Connect::Connect(Engine& engine, SharedPtr<Request> request, SampleCount timesta
void
Connect::pre_process()
{
- if (_src_port_path.parent().parent() != _dst_port_path.parent().parent()
- && _src_port_path.parent() != _dst_port_path.parent().parent()
- && _src_port_path.parent().parent() != _dst_port_path.parent()) {
- _error = PARENT_PATCH_DIFFERENT;
+ PortImpl* src_port = _engine.engine_store()->find_port(_src_port_path);
+ PortImpl* dst_port = _engine.engine_store()->find_port(_dst_port_path);
+ if (!src_port || !dst_port) {
+ _error = PORT_NOT_FOUND;
QueuedEvent::pre_process();
return;
}
- _src_port = _engine.engine_store()->find_port(_src_port_path);
- _dst_port = _engine.engine_store()->find_port(_dst_port_path);
-
- if (_src_port == NULL || _dst_port == NULL) {
- _error = PORT_NOT_FOUND;
+ _dst_input_port = dynamic_cast<InputPort*>(dst_port);
+ _src_output_port = dynamic_cast<OutputPort*>(src_port);
+ if (!_dst_input_port || !_src_output_port) {
+ _error = DIRECTION_MISMATCH;
QueuedEvent::pre_process();
return;
}
- const PortType src_type = _src_port->type();
- const PortType dst_type = _dst_port->type();
-
- if ( !(
- // Equal types
- (src_type == dst_type)
-
- || // or Control=>Audio or Audio=>Control
- ((src_type == PortType::CONTROL || src_type == PortType::AUDIO)
- && (dst_type == PortType::CONTROL || dst_type == PortType::AUDIO))
-
- || // or Events=>Message or Message=>Events
- ((src_type == PortType::EVENTS || src_type == PortType::MESSAGE)
- && (dst_type == PortType::EVENTS || dst_type == PortType::MESSAGE))
- )) {
- _error = TYPE_MISMATCH;
+ NodeImpl* const src_node = src_port->parent_node();
+ NodeImpl* const dst_node = dst_port->parent_node();
+ if (!src_node || !dst_node) {
+ _error = PARENTS_NOT_FOUND;
QueuedEvent::pre_process();
return;
}
- _dst_input_port = dynamic_cast<InputPort*>(_dst_port);
- _src_output_port = dynamic_cast<OutputPort*>(_src_port);
-
- if (!_dst_input_port || !_src_output_port) {
- _error = DIRECTION_MISMATCH;
+ if (src_node->parent() != dst_node->parent()
+ && src_node != dst_node->parent()
+ && src_node->parent() != dst_node) {
+ _error = PARENT_PATCH_DIFFERENT;
QueuedEvent::pre_process();
return;
}
- NodeImpl* const src_node = _src_port->parent_node();
- NodeImpl* const dst_node = _dst_port->parent_node();
+ if (!ConnectionImpl::can_connect(_src_output_port, _dst_input_port)) {
+ _error = TYPE_MISMATCH;
+ QueuedEvent::pre_process();
+ return;
+ }
// Connection to a patch port from inside the patch
if (src_node->parent_patch() != dst_node->parent_patch()) {
-
assert(src_node->parent() == dst_node || dst_node->parent() == src_node);
if (src_node->parent() == dst_node)
_patch = dynamic_cast<PatchImpl*>(dst_node);
@@ -128,28 +114,14 @@ Connect::pre_process()
_patch = src_node->parent_patch();
}
- assert(_patch);
-
if (_patch->has_connection(_src_output_port, _dst_input_port)) {
_error = ALREADY_CONNECTED;
QueuedEvent::pre_process();
return;
}
- if (src_node == NULL || dst_node == NULL) {
- _error = PARENTS_NOT_FOUND;
- QueuedEvent::pre_process();
- return;
- }
-
- if (_patch != src_node && src_node->parent() != _patch && dst_node->parent() != _patch) {
- _error = PARENTS_NOT_FOUND;
- QueuedEvent::pre_process();
- return;
- }
-
_connection = SharedPtr<ConnectionImpl>(
- new ConnectionImpl(*_engine.buffer_factory(), _src_port, _dst_port));
+ new ConnectionImpl(*_engine.buffer_factory(), _src_output_port, _dst_input_port));
_port_listnode = new InputPort::Connections::Node(_connection);
diff --git a/src/engine/events/Connect.hpp b/src/engine/events/Connect.hpp
index 322a5dbf..cfb924c2 100644
--- a/src/engine/events/Connect.hpp
+++ b/src/engine/events/Connect.hpp
@@ -70,8 +70,6 @@ private:
Raul::Path _dst_port_path;
PatchImpl* _patch;
- PortImpl* _src_port;
- PortImpl* _dst_port;
OutputPort* _src_output_port;
InputPort* _dst_input_port;
diff --git a/src/engine/events/Disconnect.cpp b/src/engine/events/Disconnect.cpp
index 250dc234..f25c0f4a 100644
--- a/src/engine/events/Disconnect.cpp
+++ b/src/engine/events/Disconnect.cpp
@@ -190,10 +190,12 @@ Disconnect::execute(ProcessContext& context)
_dst_input_port->connect_buffers();
if (_clear_dst_port) {
for (uint32_t v = 0; v < _dst_input_port->poly(); ++v) {
- if (_dst_input_port->type() == PortType::CONTROL) {
- PtrCast<AudioBuffer>(_dst_input_port->buffer(v))->set_value(
- _dst_input_port->value().get_float(),
- context.start(), context.start());
+ if (_dst_input_port->is_a(PortType::CONTROL)) {
+ IntrusivePtr<AudioBuffer> abuf(PtrCast<AudioBuffer>(
+ _dst_input_port->buffer(v)));
+ if (abuf)
+ abuf->set_value(_dst_input_port->value().get_float(),
+ context.start(), context.start());
} else {
_dst_input_port->buffer(v)->clear();
}
diff --git a/src/engine/events/RequestMetadata.cpp b/src/engine/events/RequestMetadata.cpp
index 707398bd..4d879298 100644
--- a/src/engine/events/RequestMetadata.cpp
+++ b/src/engine/events/RequestMetadata.cpp
@@ -15,6 +15,7 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "raul/IntrusivePtr.hpp"
#include "interface/ClientInterface.hpp"
#include "events/RequestMetadata.hpp"
#include "shared/LV2Object.hpp"
@@ -94,11 +95,15 @@ RequestMetadata::execute(ProcessContext& context)
if (_special_type == PORT_VALUE) {
PortImpl* port = dynamic_cast<PortImpl*>(_resource);
if (port) {
- if (port->type() == PortType::CONTROL || port->type() == PortType::AUDIO)
- _value = ((AudioBuffer*)port->buffer(0).get())->value_at(0); // TODO: offset
- else if (port->type() == PortType::VALUE || port->type() == PortType::MESSAGE)
- LV2Object::to_atom(context.engine().world(),
- ((ObjectBuffer*)port->buffer(0).get())->object(), _value);
+ IntrusivePtr<AudioBuffer> abuf = PtrCast<AudioBuffer>(port->buffer(0));
+ if (abuf) {
+ _value = abuf->value_at(0);
+ } else {
+ IntrusivePtr<ObjectBuffer> obuf = PtrCast<ObjectBuffer>(port->buffer(0));
+ if (obuf) {
+ LV2Object::to_atom(obuf->object(), _value);
+ }
+ }
} else {
_resource = 0;
}
diff --git a/src/engine/events/SetMetadata.cpp b/src/engine/events/SetMetadata.cpp
index c1cc97f0..a44261d4 100644
--- a/src/engine/events/SetMetadata.cpp
+++ b/src/engine/events/SetMetadata.cpp
@@ -193,7 +193,7 @@ SetMetadata::pre_process()
ev->pre_process();
_set_events.push_back(ev);
} else if (key == uris.ingen_controlBinding) {
- if (port->type() == Shared::PortType::CONTROL) {
+ if (port->is_a(Shared::PortType::CONTROL)) {
if (value == uris.wildcard) {
_engine.control_bindings()->learn(port);
} else if (value.type() == Atom::DICT) {
diff --git a/src/engine/events/SetPortValue.cpp b/src/engine/events/SetPortValue.cpp
index 2ad94082..b93783c2 100644
--- a/src/engine/events/SetPortValue.cpp
+++ b/src/engine/events/SetPortValue.cpp
@@ -176,7 +176,7 @@ SetPortValue::apply(Context& context)
ObjectBuffer* const obuf = dynamic_cast<ObjectBuffer*>(buf);
if (obuf) {
obuf->object()->size = obuf->size() - sizeof(LV2_Object);
- if (LV2Object::from_atom(_engine.world(), _value, obuf->object())) {
+ if (LV2Object::from_atom(_value, obuf->object())) {
debug << "Converted atom " << _value << " :: " << obuf->object()->type
<< " * " << obuf->object()->size << " @ " << obuf->object() << endl;
return;