From f62ef545425476959b1335f3a303d6d5f80ca0e5 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 13 May 2009 05:31:05 +0000 Subject: Remove special request_port_value, just use request_variable with predicate ingen:value. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1996 a436a847-0d15-0410-975c-d299462d15a1 --- src/engine/events/RequestMetadataEvent.cpp | 35 ++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'src/engine/events/RequestMetadataEvent.cpp') diff --git a/src/engine/events/RequestMetadataEvent.cpp b/src/engine/events/RequestMetadataEvent.cpp index 685108f4..cf8a127a 100644 --- a/src/engine/events/RequestMetadataEvent.cpp +++ b/src/engine/events/RequestMetadataEvent.cpp @@ -22,12 +22,16 @@ #include "GraphObjectImpl.hpp" #include "EngineStore.hpp" #include "ClientBroadcaster.hpp" +#include "PortImpl.hpp" +#include "AudioBuffer.hpp" using namespace std; using namespace Raul; namespace Ingen { +using namespace Shared; + RequestMetadataEvent::RequestMetadataEvent(Engine& engine, SharedPtr responder, @@ -36,6 +40,7 @@ RequestMetadataEvent::RequestMetadataEvent(Engine& engine, const Path& node_path, const URI& key) : QueuedEvent(engine, responder, timestamp) + , _special_type(NONE) , _path(node_path) , _property(property) , _key(key) @@ -55,7 +60,9 @@ RequestMetadataEvent::pre_process() } } - if (_property) + if (_key.str() == "ingen:value") + _special_type = PORT_VALUE; + else if (_property) _value = _object->get_property(_key); else _value = _object->get_variable(_key); @@ -64,11 +71,35 @@ RequestMetadataEvent::pre_process() } +void +RequestMetadataEvent::execute(ProcessContext& context) +{ + QueuedEvent::execute(context); + if (_special_type == PORT_VALUE) { + PortImpl* port = dynamic_cast(_object); + if (port) { + if (port->type() == DataType::CONTROL || port->type() == DataType::AUDIO) + _value = ((AudioBuffer*)port->buffer(0))->value_at(0); // TODO: offset + } else { + _object = 0; + } + } +} + + void RequestMetadataEvent::post_process() { if (_responder->client()) { - if (!_object) { + if (_special_type == PORT_VALUE) { + if (_object) { + _responder->respond_ok(); + _responder->client()->set_port_value(_path, _value); + } else { + const string msg = "Get value for non-port " + _path.str(); + _responder->respond_error(msg); + } + } else if (!_object) { const string msg = "Unable to find variable subject " + _path.str(); _responder->respond_error(msg); } else { -- cgit v1.2.1