diff options
author | David Robillard <d@drobilla.net> | 2009-05-13 05:31:05 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-05-13 05:31:05 +0000 |
commit | f62ef545425476959b1335f3a303d6d5f80ca0e5 (patch) | |
tree | c6ac8347ae8c820c1cbc1cecac358ac872c20585 /src/engine/events/RequestMetadataEvent.cpp | |
parent | 5b8e8680fb6f7f6a86d8738cda817a34d53a349d (diff) | |
download | ingen-f62ef545425476959b1335f3a303d6d5f80ca0e5.tar.gz ingen-f62ef545425476959b1335f3a303d6d5f80ca0e5.tar.bz2 ingen-f62ef545425476959b1335f3a303d6d5f80ca0e5.zip |
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
Diffstat (limited to 'src/engine/events/RequestMetadataEvent.cpp')
-rw-r--r-- | src/engine/events/RequestMetadataEvent.cpp | 35 |
1 files changed, 33 insertions, 2 deletions
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> 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); @@ -65,10 +72,34 @@ RequestMetadataEvent::pre_process() void +RequestMetadataEvent::execute(ProcessContext& context) +{ + QueuedEvent::execute(context); + if (_special_type == PORT_VALUE) { + PortImpl* port = dynamic_cast<PortImpl*>(_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 { |