From 64bd557e75113743f179086b365ea7d97b72ee3e Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 12 Nov 2009 06:56:26 +0000 Subject: String port support. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2255 a436a847-0d15-0410-975c-d299462d15a1 --- src/engine/events/RequestMetadata.cpp | 13 ++++++++----- src/engine/events/RequestMetadata.hpp | 10 +++++----- src/engine/events/SendPortValue.hpp | 21 +++++++++++---------- src/engine/events/SetPortValue.cpp | 24 +++++++++++++++++------- 4 files changed, 41 insertions(+), 27 deletions(-) (limited to 'src/engine/events') diff --git a/src/engine/events/RequestMetadata.cpp b/src/engine/events/RequestMetadata.cpp index 145260ef..e633ca10 100644 --- a/src/engine/events/RequestMetadata.cpp +++ b/src/engine/events/RequestMetadata.cpp @@ -25,6 +25,7 @@ #include "PortImpl.hpp" #include "PluginImpl.hpp" #include "AudioBuffer.hpp" +#include "StringBuffer.hpp" using namespace std; using namespace Raul; @@ -36,11 +37,11 @@ using namespace Shared; RequestMetadata::RequestMetadata(Engine& engine, - SharedPtr responder, - SampleCount timestamp, - bool is_meta, - const URI& subject, - const URI& key) + SharedPtr responder, + SampleCount timestamp, + bool is_meta, + const URI& subject, + const URI& key) : QueuedEvent(engine, responder, timestamp) , _error(NO_ERROR) , _special_type(NONE) @@ -93,6 +94,8 @@ RequestMetadata::execute(ProcessContext& context) if (port) { if (port->type() == DataType::CONTROL || port->type() == DataType::AUDIO) _value = ((AudioBuffer*)port->buffer(0))->value_at(0); // TODO: offset + else if (port->type() == DataType::STRING) + _value = (char*)((StringBuffer*)port->buffer(0))->data(); } else { _resource = 0; } diff --git a/src/engine/events/RequestMetadata.hpp b/src/engine/events/RequestMetadata.hpp index ba860aaf..0777c79a 100644 --- a/src/engine/events/RequestMetadata.hpp +++ b/src/engine/events/RequestMetadata.hpp @@ -45,11 +45,11 @@ class RequestMetadata : public QueuedEvent { public: RequestMetadata(Engine& engine, - SharedPtr responder, - SampleCount timestamp, - bool meta, - const Raul::URI& subject, - const Raul::URI& key); + SharedPtr responder, + SampleCount timestamp, + bool meta, + const Raul::URI& subject, + const Raul::URI& key); void pre_process(); void execute(ProcessContext& context); diff --git a/src/engine/events/SendPortValue.hpp b/src/engine/events/SendPortValue.hpp index d3ac61f7..b942398c 100644 --- a/src/engine/events/SendPortValue.hpp +++ b/src/engine/events/SendPortValue.hpp @@ -18,6 +18,7 @@ #ifndef SENDPORTVALUEEVENT_H #define SENDPORTVALUEEVENT_H +#include "raul/Atom.hpp" #include "engine/Event.hpp" #include "engine/types.hpp" @@ -43,12 +44,12 @@ class SendPortValue : public Event { public: inline SendPortValue( - Engine& engine, - SampleCount timestamp, - PortImpl* port, - bool omni, - uint32_t voice_num, - Sample value) + Engine& engine, + SampleCount timestamp, + PortImpl* port, + bool omni, + uint32_t voice_num, + const Raul::Atom& value) : Event(engine, SharedPtr(), timestamp) , _port(port) , _omni(omni) @@ -67,10 +68,10 @@ public: void post_process(); private: - PortImpl* _port; - bool _omni; - uint32_t _voice_num; - Sample _value; + PortImpl* _port; + bool _omni; + uint32_t _voice_num; + Raul::Atom _value; }; diff --git a/src/engine/events/SetPortValue.cpp b/src/engine/events/SetPortValue.cpp index eacf172b..1964880d 100644 --- a/src/engine/events/SetPortValue.cpp +++ b/src/engine/events/SetPortValue.cpp @@ -31,6 +31,7 @@ #include "ProcessContext.hpp" #include "Responder.hpp" #include "SetPortValue.hpp" +#include "StringBuffer.hpp" using namespace std; using namespace Raul; @@ -169,21 +170,18 @@ SetPortValue::apply(uint32_t start, uint32_t nframes) return; } - EventBuffer* const ebuf = dynamic_cast(buf); - const LV2Features::Feature* f = _engine.world()->lv2_features->feature(LV2_URI_MAP_URI); LV2URIMap* map = (LV2URIMap*)f->controller; - // FIXME: eliminate lookups - // FIXME: need a proper prefix system - if (ebuf && _value.type() == Atom::BLOB) { + // TODO: eliminate lookups + EventBuffer* const ebuf = dynamic_cast(buf); + if (ebuf) { const uint32_t frames = std::max( - (uint32_t)(_time - start), + uint32_t(_time - start), ebuf->latest_frames()); // Size 0 event, pass it along to the plugin as a typed but empty event if (_value.data_size() == 0) { - cout << "BANG!" << endl; const uint32_t type_id = map->uri_to_id(NULL, _value.get_blob_type()); ebuf->append(frames, 0, type_id, 0, NULL); _port->raise_set_by_user_flag(); @@ -202,6 +200,18 @@ SetPortValue::apply(uint32_t start, uint32_t nframes) } } + StringBuffer* const sbuf = dynamic_cast(buf); + if (sbuf) { + if (_value.type() != Atom::STRING) { + _error = TYPE_MISMATCH; + return; + } + strncpy(sbuf->data(), _value.get_string(), + std::min(sbuf->size(), strlen(_value.get_string()))); + return; + } + + if (_value.type() == Atom::BLOB) cerr << "WARNING: Unknown value blob type " << _value.get_blob_type() << endl; else -- cgit v1.2.1