summaryrefslogtreecommitdiffstats
path: root/src/server
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-05-22 03:30:42 +0000
committerDavid Robillard <d@drobilla.net>2012-05-22 03:30:42 +0000
commitb1d4027b58465d9cc31d6cb1be05a7ff4f202711 (patch)
treeb1b7e9d1379fc16c5f451fda7afff0d2bc071e18 /src/server
parente3b0886bfbd12f65450d4b302371f07f511458c3 (diff)
downloadingen-b1d4027b58465d9cc31d6cb1be05a7ff4f202711.tar.gz
ingen-b1d4027b58465d9cc31d6cb1be05a7ff4f202711.tar.bz2
ingen-b1d4027b58465d9cc31d6cb1be05a7ff4f202711.zip
More work on test suite.
Clean up, simplify, and shrink event code. Support disconnect_all via Atom protocol. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4432 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/server')
-rw-r--r--src/server/Engine.cpp21
-rw-r--r--src/server/Engine.hpp5
-rw-r--r--src/server/Event.cpp72
-rw-r--r--src/server/Event.hpp32
-rw-r--r--src/server/EventWriter.cpp7
-rw-r--r--src/server/PreProcessor.cpp4
-rw-r--r--src/server/events/Connect.cpp30
-rw-r--r--src/server/events/Connect.hpp2
-rw-r--r--src/server/events/CreateNode.cpp44
-rw-r--r--src/server/events/CreateNode.hpp5
-rw-r--r--src/server/events/CreatePatch.cpp42
-rw-r--r--src/server/events/CreatePatch.hpp3
-rw-r--r--src/server/events/CreatePort.cpp33
-rw-r--r--src/server/events/CreatePort.hpp2
-rw-r--r--src/server/events/Delete.cpp9
-rw-r--r--src/server/events/Delete.hpp2
-rw-r--r--src/server/events/Disconnect.cpp22
-rw-r--r--src/server/events/Disconnect.hpp2
-rw-r--r--src/server/events/DisconnectAll.cpp21
-rw-r--r--src/server/events/DisconnectAll.hpp2
-rw-r--r--src/server/events/Get.cpp12
-rw-r--r--src/server/events/Get.hpp3
-rw-r--r--src/server/events/Move.cpp23
-rw-r--r--src/server/events/Move.hpp2
-rw-r--r--src/server/events/SetMetadata.cpp58
-rw-r--r--src/server/events/SetMetadata.hpp2
-rw-r--r--src/server/events/SetPortValue.cpp25
-rw-r--r--src/server/events/SetPortValue.hpp2
-rw-r--r--src/server/ingen_lv2.cpp3
-rw-r--r--src/server/wscript1
30 files changed, 184 insertions, 307 deletions
diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp
index 9359bacf..ead11895 100644
--- a/src/server/Engine.cpp
+++ b/src/server/Engine.cpp
@@ -66,6 +66,7 @@ Engine::Engine(Ingen::Shared::World* a_world)
, _message_context(*this)
, _process_context(*this)
, _quit_flag(false)
+ , _direct_driver(true)
{
if (a_world->store()) {
SharedPtr<EngineStore> estore = PtrCast<EngineStore>(a_world->store());
@@ -133,10 +134,27 @@ Engine::set_driver(SharedPtr<Driver> driver)
_driver = driver;
}
+SampleCount
+Engine::event_time()
+{
+ const SampleCount start = _direct_driver
+ ? _process_context.start()
+ : _driver->frame_time();
+
+ /* Exactly one cycle latency (some could run ASAP if we get lucky, but not
+ always, and a slight constant latency is far better than jittery lower
+ (average) latency */
+ return start + _driver->block_length();
+}
+
static void
execute_and_delete_event(ProcessContext& context, Event* ev)
{
ev->pre_process();
+ if (ev->time() < context.start()) {
+ // Didn't get around to executing in time, oh well...
+ ev->set_time(context.start());
+ }
ev->execute(context);
ev->post_process();
delete ev;
@@ -146,6 +164,7 @@ void
Engine::init(double sample_rate, uint32_t block_length)
{
set_driver(SharedPtr<Driver>(new DirectDriver(sample_rate, block_length)));
+ _direct_driver = true;
}
bool
@@ -252,6 +271,8 @@ Engine::deactivate()
unsigned
Engine::run(uint32_t sample_count)
{
+ _process_context.locate(_process_context.end(), sample_count, 0);
+
// Apply control bindings to input
control_bindings()->pre_process(
_process_context, _root_patch->port_impl(0)->buffer(0).get());
diff --git a/src/server/Engine.hpp b/src/server/Engine.hpp
index edbe33ae..11b7b35b 100644
--- a/src/server/Engine.hpp
+++ b/src/server/Engine.hpp
@@ -68,6 +68,7 @@ public:
virtual void init(double sample_rate, uint32_t block_length);
virtual bool activate();
virtual void deactivate();
+ virtual bool pending_events();
virtual unsigned run(uint32_t sample_count);
virtual void quit();
virtual bool main_iteration();
@@ -77,8 +78,7 @@ public:
void set_driver(SharedPtr<Driver> driver);
- /** Return true iff any events are pending. */
- bool pending_events();
+ SampleCount event_time();
/** Enqueue an event to be processed (non-realtime threads only). */
void enqueue_event(Event* ev);
@@ -128,6 +128,7 @@ private:
ProcessContext _process_context;
bool _quit_flag;
+ bool _direct_driver;
};
} // namespace Server
diff --git a/src/server/Event.cpp b/src/server/Event.cpp
deleted file mode 100644
index 7063acdb..00000000
--- a/src/server/Event.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- This file is part of Ingen.
- Copyright 2007-2012 David Robillard <http://drobilla.net/>
-
- Ingen is free software: you can redistribute it and/or modify it under the
- terms of the GNU Affero General Public License as published by the Free
- Software Foundation, either version 3 of the License, or any later version.
-
- Ingen is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for details.
-
- You should have received a copy of the GNU Affero General Public License
- along with Ingen. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "ingen/Interface.hpp"
-
-#include "Driver.hpp"
-#include "Engine.hpp"
-#include "Event.hpp"
-#include "ProcessContext.hpp"
-#include "ThreadManager.hpp"
-
-/*! \page methods Method Documentation
- *
- * <p>All changes in Ingen (both engine and client) occur as a result of
- * a small set of methods defined in terms of RDF and matching the
- * HTTP and WebDAV standards as closely as possible.</p>
- */
-
-namespace Ingen {
-namespace Server {
-
-void
-Event::pre_process()
-{
- ThreadManager::assert_thread(THREAD_PRE_PROCESS);
- assert(_pre_processed == false);
- _pre_processed = true;
-}
-
-void
-Event::execute(ProcessContext& context)
-{
- assert(_pre_processed);
- assert(!_executed);
- assert(_time <= context.end());
-
- // Didn't get around to executing in time, jitter, oh well...
- if (_time < context.start())
- _time = context.start();
-
- _executed = true;
-}
-
-void
-Event::post_process()
-{
- ThreadManager::assert_not_thread(THREAD_PROCESS);
-}
-
-void
-Event::respond(Status status)
-{
- if (_request_client) {
- _request_client->response(_request_id, status);
- }
-}
-
-} // namespace Server
-} // namespace Ingen
diff --git a/src/server/Event.hpp b/src/server/Event.hpp
index d47a8e94..6820e8e2 100644
--- a/src/server/Event.hpp
+++ b/src/server/Event.hpp
@@ -52,20 +52,23 @@ public:
virtual ~Event() {}
/** Pre-process event before execution (non-realtime). */
- virtual void pre_process();
+ virtual bool pre_process() = 0;
/** Execute this event in the audio thread (realtime). */
- virtual void execute(ProcessContext& context);
+ virtual void execute(ProcessContext& context) = 0;
/** Post-process event after execution (non-realtime). */
- virtual void post_process();
+ virtual void post_process() = 0;
/** Return true iff this event has been pre-processed. */
- inline bool is_prepared() const { return _pre_processed; }
+ inline bool is_prepared() const { return _status != NOT_PREPARED; }
/** Return the time stamp of this event. */
inline SampleCount time() const { return _time; }
+ /** Set the time stamp of this event. */
+ inline void set_time(SampleCount time) { _time = time; }
+
/** Get the next event to be processed after this one. */
Event* next() const { return _next.get(); }
@@ -76,7 +79,11 @@ public:
Status status() const { return _status; }
/** Respond to the originating client. */
- void respond(Status status);
+ void respond(Status status) {
+ if (_request_client) {
+ _request_client->response(_request_id, status);
+ }
+ }
protected:
Event(Engine& engine, Interface* client, int32_t id, FrameTime time)
@@ -84,9 +91,7 @@ protected:
, _request_client(client)
, _request_id(id)
, _time(time)
- , _status(SUCCESS)
- , _pre_processed(false)
- , _executed(false)
+ , _status(NOT_PREPARED)
{}
/** Constructor for internal events only */
@@ -95,19 +100,20 @@ protected:
, _request_client(NULL)
, _request_id(-1)
, _time(0)
- , _status(SUCCESS)
- , _pre_processed(false)
- , _executed(false)
+ , _status(NOT_PREPARED)
{}
+ inline bool pre_process_done(Status st) {
+ _status = st;
+ return !st;
+ }
+
Engine& _engine;
Raul::AtomicPtr<Event> _next;
Interface* _request_client;
int32_t _request_id;
FrameTime _time;
Status _status;
- bool _pre_processed;
- bool _executed;
};
} // namespace Server
diff --git a/src/server/EventWriter.cpp b/src/server/EventWriter.cpp
index 6fb682c2..33462c1c 100644
--- a/src/server/EventWriter.cpp
+++ b/src/server/EventWriter.cpp
@@ -46,12 +46,7 @@ EventWriter::~EventWriter()
SampleCount
EventWriter::now() const
{
- /* Exactly one cycle latency (some could run ASAP if we get lucky, but not
- always, and a slight constant latency is far better than jittery lower
- (average) latency */
- return (_engine.driver())
- ? _engine.driver()->frame_time() + _engine.driver()->block_length()
- : 0;
+ return _engine.event_time();
}
void
diff --git a/src/server/PreProcessor.cpp b/src/server/PreProcessor.cpp
index 013a43dd..9db13fd1 100644
--- a/src/server/PreProcessor.cpp
+++ b/src/server/PreProcessor.cpp
@@ -83,6 +83,10 @@ PreProcessor::process(ProcessContext& context, PostProcessor& dest, bool limit)
Event* last = ev;
while (ev && ev->is_prepared() && ev->time() < context.end()) {
+ if (ev->time() < context.start()) {
+ // Didn't get around to executing in time, oh well...
+ ev->set_time(context.start());
+ }
ev->execute(context);
last = ev;
ev = (Event*)ev->next();
diff --git a/src/server/events/Connect.cpp b/src/server/events/Connect.cpp
index 8fec67f6..64f81e78 100644
--- a/src/server/events/Connect.cpp
+++ b/src/server/events/Connect.cpp
@@ -55,7 +55,7 @@ Connect::Connect(Engine& engine,
, _buffers(NULL)
{}
-void
+bool
Connect::pre_process()
{
Glib::RWLock::ReaderLock rlock(_engine.engine_store()->lock());
@@ -63,39 +63,29 @@ Connect::pre_process()
PortImpl* tail = _engine.engine_store()->find_port(_tail_path);
PortImpl* head = _engine.engine_store()->find_port(_head_path);
if (!tail || !head) {
- _status = PORT_NOT_FOUND;
- Event::pre_process();
- return;
+ return Event::pre_process_done(PORT_NOT_FOUND);
}
_dst_input_port = dynamic_cast<InputPort*>(head);
_src_output_port = dynamic_cast<OutputPort*>(tail);
if (!_dst_input_port || !_src_output_port) {
- _status = DIRECTION_MISMATCH;
- Event::pre_process();
- return;
+ return Event::pre_process_done(DIRECTION_MISMATCH);
}
NodeImpl* const src_node = tail->parent_node();
NodeImpl* const dst_node = head->parent_node();
if (!src_node || !dst_node) {
- _status = PARENT_NOT_FOUND;
- Event::pre_process();
- return;
+ return Event::pre_process_done(PARENT_NOT_FOUND);
}
if (src_node->parent() != dst_node->parent()
&& src_node != dst_node->parent()
&& src_node->parent() != dst_node) {
- _status = PARENT_DIFFERS;
- Event::pre_process();
- return;
+ return Event::pre_process_done(PARENT_DIFFERS);
}
if (!EdgeImpl::can_connect(_src_output_port, _dst_input_port)) {
- _status = TYPE_MISMATCH;
- Event::pre_process();
- return;
+ return Event::pre_process_done(TYPE_MISMATCH);
}
if (src_node->parent_patch() != dst_node->parent_patch()) {
@@ -115,9 +105,7 @@ Connect::pre_process()
}
if (_patch->has_edge(_src_output_port, _dst_input_port)) {
- _status = EXISTS;
- Event::pre_process();
- return;
+ return Event::pre_process_done(EXISTS);
}
_edge = SharedPtr<EdgeImpl>(
@@ -149,14 +137,12 @@ Connect::pre_process()
if (_patch->enabled())
_compiled_patch = _patch->compile();
- Event::pre_process();
+ return Event::pre_process_done(SUCCESS);
}
void
Connect::execute(ProcessContext& context)
{
- Event::execute(context);
-
if (_status == SUCCESS) {
// This must be inserted here, since they're actually used by the audio thread
_dst_input_port->add_edge(context, _edge.get());
diff --git a/src/server/events/Connect.hpp b/src/server/events/Connect.hpp
index f5939386..8a93200f 100644
--- a/src/server/events/Connect.hpp
+++ b/src/server/events/Connect.hpp
@@ -55,7 +55,7 @@ public:
const Raul::Path& tail,
const Raul::Path& head);
- void pre_process();
+ bool pre_process();
void execute(ProcessContext& context);
void post_process();
diff --git a/src/server/events/CreateNode.cpp b/src/server/events/CreateNode.cpp
index 4c2d1382..756f937d 100644
--- a/src/server/events/CreateNode.cpp
+++ b/src/server/events/CreateNode.cpp
@@ -39,43 +39,43 @@ CreateNode::CreateNode(Engine& engine,
int32_t id,
SampleCount timestamp,
const Raul::Path& path,
- const Raul::URI& plugin_uri,
const Resource::Properties& properties)
: Event(engine, client, id, timestamp)
, _path(path)
- , _plugin_uri(plugin_uri)
, _properties(properties)
, _patch(NULL)
, _node(NULL)
, _compiled_patch(NULL)
{}
-void
+bool
CreateNode::pre_process()
{
Ingen::Shared::URIs& uris = _engine.world()->uris();
+ typedef Resource::Properties::const_iterator iterator;
+
+ const iterator t = _properties.find(uris.ingen_prototype);
+ if (t != _properties.end() && t->second.type() == uris.forge.URI) {
+ _plugin_uri = t->second.get_uri();
+ } else {
+ return Event::pre_process_done(BAD_REQUEST);
+ }
+
if (_engine.engine_store()->find_object(_path)) {
- _status = EXISTS;
- Event::pre_process();
- return;
+ return Event::pre_process_done(EXISTS);
}
if (!(_patch = _engine.engine_store()->find_patch(_path.parent()))) {
- _status = PARENT_NOT_FOUND;
- Event::pre_process();
- return;
+ return Event::pre_process_done(PARENT_NOT_FOUND);
}
- PluginImpl* plugin = _engine.node_factory()->plugin(_plugin_uri.str());
+ PluginImpl* plugin = _engine.node_factory()->plugin(_plugin_uri);
if (!plugin) {
- _status = PLUGIN_NOT_FOUND;
- Event::pre_process();
- return;
+ return Event::pre_process_done(PLUGIN_NOT_FOUND);
}
- const Resource::Properties::const_iterator p = _properties.find(
- _engine.world()->uris().ingen_polyphonic);
+ const iterator p = _properties.find(uris.ingen_polyphonic);
const bool polyphonic = (
p != _properties.end() &&
p->second.type() == _engine.world()->forge().Bool &&
@@ -86,9 +86,7 @@ CreateNode::pre_process()
polyphonic,
_patch,
_engine))) {
- _status = CREATION_FAILED;
- Event::pre_process();
- return;
+ return Event::pre_process_done(CREATION_FAILED);
}
_node->properties().insert(_properties.begin(), _properties.end());
@@ -115,14 +113,12 @@ CreateNode::pre_process()
_update.push_back(std::make_pair(port->path(), pprops));
}
- Event::pre_process();
+ return Event::pre_process_done(SUCCESS);
}
void
CreateNode::execute(ProcessContext& context)
{
- Event::execute(context);
-
if (_node) {
_engine.maid()->push(_patch->compiled_patch());
_patch->compiled_patch(_compiled_patch);
@@ -132,10 +128,8 @@ CreateNode::execute(ProcessContext& context)
void
CreateNode::post_process()
{
- if (_status) {
- respond(_status);
- } else {
- respond(SUCCESS);
+ respond(_status);
+ if (!_status) {
for (Update::const_iterator i = _update.begin(); i != _update.end(); ++i) {
_engine.broadcaster()->put(i->first, i->second);
}
diff --git a/src/server/events/CreateNode.hpp b/src/server/events/CreateNode.hpp
index 95d504de..90b2b2b6 100644
--- a/src/server/events/CreateNode.hpp
+++ b/src/server/events/CreateNode.hpp
@@ -45,10 +45,9 @@ public:
int32_t id,
SampleCount timestamp,
const Raul::Path& node_path,
- const Raul::URI& plugin_uri,
const Resource::Properties& properties);
- void pre_process();
+ bool pre_process();
void execute(ProcessContext& context);
void post_process();
@@ -57,7 +56,7 @@ private:
typedef std::list< std::pair<Raul::URI, Resource::Properties> > Update;
Raul::Path _path;
- Raul::URI _plugin_uri;
+ std::string _plugin_uri;
Resource::Properties _properties;
Update _update;
PatchImpl* _patch;
diff --git a/src/server/events/CreatePatch.cpp b/src/server/events/CreatePatch.cpp
index 92d7a5e3..575cf11e 100644
--- a/src/server/events/CreatePatch.cpp
+++ b/src/server/events/CreatePatch.cpp
@@ -36,7 +36,6 @@ CreatePatch::CreatePatch(Engine& engine,
int32_t id,
SampleCount timestamp,
const Raul::Path& path,
- int poly,
const Resource::Properties& properties)
: Event(engine, client, id, timestamp)
, _path(path)
@@ -44,37 +43,38 @@ CreatePatch::CreatePatch(Engine& engine,
, _patch(NULL)
, _parent(NULL)
, _compiled_patch(NULL)
- , _poly(poly)
+ , _poly(1)
{
+ Ingen::Shared::URIs& uris = _engine.world()->uris();
+ typedef Resource::Properties::const_iterator iterator;
+ iterator p = _properties.find(uris.ingen_polyphony);
+ if (p != _properties.end() && p->second.type() == uris.forge.Int) {
+ _poly = p->second.get_int32();
+ }
}
-void
+bool
CreatePatch::pre_process()
{
if (_path.is_root() || _engine.engine_store()->find_object(_path) != NULL) {
- _status = EXISTS;
- Event::pre_process();
- return;
+ return Event::pre_process_done(EXISTS);
}
if (_poly < 1) {
- _status = INVALID_POLY;
- Event::pre_process();
- return;
+ return Event::pre_process_done(INVALID_POLY);
}
const Raul::Path& path = (const Raul::Path&)_path;
_parent = _engine.engine_store()->find_patch(path.parent());
- if (_parent == NULL) {
- _status = PARENT_NOT_FOUND;
- Event::pre_process();
- return;
+ if (!_parent) {
+ return Event::pre_process_done(PARENT_NOT_FOUND);
}
uint32_t poly = 1;
- if (_parent != NULL && _poly > 1 && _poly == static_cast<int>(_parent->internal_poly()))
+ if (_poly > 1 && _poly == static_cast<int>(_parent->internal_poly())) {
poly = _poly;
+ }
const Ingen::Shared::URIs& uris = _engine.world()->uris();
@@ -85,12 +85,10 @@ CreatePatch::pre_process()
_patch->add_property(uris.rdf_type,
Resource::Property(uris.ingen_Node, Resource::EXTERNAL));
- if (_parent) {
- _parent->add_node(new PatchImpl::Nodes::Node(_patch));
- if (_parent->enabled()) {
- _patch->enable();
- _compiled_patch = _parent->compile();
- }
+ _parent->add_node(new PatchImpl::Nodes::Node(_patch));
+ if (_parent->enabled()) {
+ _patch->enable();
+ _compiled_patch = _parent->compile();
}
_patch->activate(*_engine.buffer_factory());
@@ -100,14 +98,12 @@ CreatePatch::pre_process()
_update = _patch->properties();
- Event::pre_process();
+ return Event::pre_process_done(SUCCESS);
}
void
CreatePatch::execute(ProcessContext& context)
{
- Event::execute(context);
-
if (_patch) {
assert(_parent);
assert(!_path.is_root());
diff --git a/src/server/events/CreatePatch.hpp b/src/server/events/CreatePatch.hpp
index 0747ec06..95f24641 100644
--- a/src/server/events/CreatePatch.hpp
+++ b/src/server/events/CreatePatch.hpp
@@ -40,10 +40,9 @@ public:
int32_t id,
SampleCount timestamp,
const Raul::Path& path,
- int poly,
const Resource::Properties& properties);
- void pre_process();
+ bool pre_process();
void execute(ProcessContext& context);
void post_process();
diff --git a/src/server/events/CreatePort.cpp b/src/server/events/CreatePort.cpp
index a783512f..9f061238 100644
--- a/src/server/events/CreatePort.cpp
+++ b/src/server/events/CreatePort.cpp
@@ -81,30 +81,21 @@ CreatePort::CreatePort(Engine& engine,
_buffer_type = _engine.world()->uri_map().map_uri(i->second.get_uri());
}
}
-
- if (_port_type == PortType::UNKNOWN) {
- _status = UNKNOWN_TYPE;
- }
}
-void
+bool
CreatePort::pre_process()
{
- if (_status) {
- Event::pre_process();
- return;
+ if (_port_type == PortType::UNKNOWN) {
+ return Event::pre_process_done(UNKNOWN_TYPE);
}
if (_engine.engine_store()->find_object(_path)) {
- _status = EXISTS;
- Event::pre_process();
- return;
+ return Event::pre_process_done(_status);
}
if (!(_patch = _engine.engine_store()->find_patch(_path.parent()))) {
- _status = PARENT_NOT_FOUND;
- Event::pre_process();
- return;
+ return Event::pre_process_done(PARENT_NOT_FOUND);
}
const Ingen::Shared::URIs& uris = _engine.world()->uris();
@@ -124,9 +115,7 @@ CreatePort::pre_process()
_engine.world()->forge().make(int32_t(old_num_ports))));
} else if (index_i->second.type() != uris.forge.Int
|| index_i->second.get_int32() != static_cast<int32_t>(old_num_ports)) {
- _status = BAD_INDEX;
- Event::pre_process();
- return;
+ return Event::pre_process_done(BAD_INDEX);
}
Resource::Properties::const_iterator poly_i = _properties.find(uris.ingen_polyphonic);
@@ -137,9 +126,7 @@ CreatePort::pre_process()
if (!(_patch_port = _patch->create_port(
*_engine.buffer_factory(), _path.symbol(),
_port_type, _buffer_type, buffer_size, _is_output, polyphonic))) {
- _status = CREATION_FAILED;
- Event::pre_process();
- return;
+ return Event::pre_process_done(CREATION_FAILED);
}
_patch_port->properties().insert(_properties.begin(), _properties.end());
@@ -168,19 +155,17 @@ CreatePort::pre_process()
assert(_ports_array->size() == _patch->num_ports_non_rt());
} else {
- _status = CREATION_FAILED;
+ return Event::pre_process_done(CREATION_FAILED);
}
_update = _patch_port->properties();
- Event::pre_process();
+ return Event::pre_process_done(SUCCESS);
}
void
CreatePort::execute(ProcessContext& context)
{
- Event::execute(context);
-
if (_patch_port) {
_engine.maid()->push(_patch->external_ports());
_patch->external_ports(_ports_array);
diff --git a/src/server/events/CreatePort.hpp b/src/server/events/CreatePort.hpp
index 3b40136e..3952b1b7 100644
--- a/src/server/events/CreatePort.hpp
+++ b/src/server/events/CreatePort.hpp
@@ -49,7 +49,7 @@ public:
bool is_output,
const Resource::Properties& properties);
- void pre_process();
+ bool pre_process();
void execute(ProcessContext& context);
void post_process();
diff --git a/src/server/events/Delete.cpp b/src/server/events/Delete.cpp
index d54bcab4..5e7dd20e 100644
--- a/src/server/events/Delete.cpp
+++ b/src/server/events/Delete.cpp
@@ -60,12 +60,11 @@ Delete::~Delete()
delete _disconnect_event;
}
-void
+bool
Delete::pre_process()
{
if (_path.is_root() || _path == "path:/control_in" || _path == "path:/control_out") {
- Event::pre_process();
- return;
+ return Event::pre_process_done(NOT_DELETABLE);
}
_lock.acquire();
@@ -125,14 +124,12 @@ Delete::pre_process()
}
- Event::pre_process();
+ return Event::pre_process_done(SUCCESS);
}
void
Delete::execute(ProcessContext& context)
{
- Event::execute(context);
-
PatchImpl* parent_patch = NULL;
if (_patch_node_listnode) {
diff --git a/src/server/events/Delete.hpp b/src/server/events/Delete.hpp
index 2ca24469..4316763f 100644
--- a/src/server/events/Delete.hpp
+++ b/src/server/events/Delete.hpp
@@ -65,7 +65,7 @@ public:
~Delete();
- void pre_process();
+ bool pre_process();
void execute(ProcessContext& context);
void post_process();
diff --git a/src/server/events/Disconnect.cpp b/src/server/events/Disconnect.cpp
index e1a86b13..fc6813ea 100644
--- a/src/server/events/Disconnect.cpp
+++ b/src/server/events/Disconnect.cpp
@@ -111,7 +111,7 @@ Disconnect::Impl::Impl(Engine& e,
}
}
-void
+bool
Disconnect::pre_process()
{
Glib::RWLock::WriterLock lock(_engine.engine_store()->lock());
@@ -119,18 +119,14 @@ Disconnect::pre_process()
if (_tail_path.parent().parent() != _head_path.parent().parent()
&& _tail_path.parent() != _head_path.parent().parent()
&& _tail_path.parent().parent() != _head_path.parent()) {
- _status = PARENT_DIFFERS;
- Event::pre_process();
- return;
+ return Event::pre_process_done(PARENT_DIFFERS);
}
_tail = _engine.engine_store()->find_port(_tail_path);
_head = _engine.engine_store()->find_port(_head_path);
if (_tail == NULL || _head == NULL) {
- _status = PORT_NOT_FOUND;
- Event::pre_process();
- return;
+ return Event::pre_process_done(PORT_NOT_FOUND);
}
NodeImpl* const src_node = _tail->parent_node();
@@ -155,15 +151,11 @@ Disconnect::pre_process()
assert(_patch);
if (!_patch->has_edge(_tail, _head)) {
- _status = NOT_FOUND;
- Event::pre_process();
- return;
+ return Event::pre_process_done(NOT_FOUND);
}
if (src_node == NULL || dst_node == NULL) {
- _status = PARENT_NOT_FOUND;
- Event::pre_process();
- return;
+ return Event::pre_process_done(PARENT_NOT_FOUND);
}
_impl = new Impl(_engine,
@@ -174,7 +166,7 @@ Disconnect::pre_process()
if (_patch->enabled())
_compiled_patch = _patch->compile();
- Event::pre_process();
+ return Event::pre_process_done(SUCCESS);
}
bool
@@ -208,8 +200,6 @@ Disconnect::Impl::execute(ProcessContext& context, bool set_dst_buffers)
void
Disconnect::execute(ProcessContext& context)
{
- Event::execute(context);
-
if (_status == SUCCESS) {
if (!_impl->execute(context, true)) {
_status = NOT_FOUND;
diff --git a/src/server/events/Disconnect.hpp b/src/server/events/Disconnect.hpp
index fa17e9f4..68356e84 100644
--- a/src/server/events/Disconnect.hpp
+++ b/src/server/events/Disconnect.hpp
@@ -52,7 +52,7 @@ public:
const Raul::Path& tail_path,
const Raul::Path& head_path);
- void pre_process();
+ bool pre_process();
void execute(ProcessContext& context);
void post_process();
diff --git a/src/server/events/DisconnectAll.cpp b/src/server/events/DisconnectAll.cpp
index 0a4c2ef1..d9f8b8c1 100644
--- a/src/server/events/DisconnectAll.cpp
+++ b/src/server/events/DisconnectAll.cpp
@@ -79,7 +79,7 @@ DisconnectAll::~DisconnectAll()
delete (*i);
}
-void
+bool
DisconnectAll::pre_process()
{
Glib::RWLock::WriterLock lock(_engine.engine_store()->lock(), Glib::NOT_LOCK);
@@ -88,25 +88,18 @@ DisconnectAll::pre_process()
lock.acquire();
_parent = _engine.engine_store()->find_patch(_parent_path);
-
- if (_parent == NULL) {
- _status = PARENT_NOT_FOUND;
- Event::pre_process();
- return;
+ if (!_parent) {
+ return Event::pre_process_done(PARENT_NOT_FOUND);
}
GraphObjectImpl* object = _engine.engine_store()->find_object(_path);
if (!object) {
- _status = NOT_FOUND;
- Event::pre_process();
- return;
+ return Event::pre_process_done(NOT_FOUND);
}
if (object->parent_patch() != _parent
&& object->parent()->parent_patch() != _parent) {
- _status = INVALID_PARENT_PATH;
- Event::pre_process();
- return;
+ return Event::pre_process_done(INVALID_PARENT_PATH);
}
// Only one of these will succeed
@@ -146,14 +139,12 @@ DisconnectAll::pre_process()
if (!_deleting && _parent->enabled())
_compiled_patch = _parent->compile();
- Event::pre_process();
+ return Event::pre_process_done(SUCCESS);
}
void
DisconnectAll::execute(ProcessContext& context)
{
- Event::execute(context);
-
if (_status == SUCCESS) {
for (Impls::iterator i = _impls.begin(); i != _impls.end(); ++i) {
(*i)->execute(context,
diff --git a/src/server/events/DisconnectAll.hpp b/src/server/events/DisconnectAll.hpp
index 9006fd9d..1446d962 100644
--- a/src/server/events/DisconnectAll.hpp
+++ b/src/server/events/DisconnectAll.hpp
@@ -56,7 +56,7 @@ public:
~DisconnectAll();
- void pre_process();
+ bool pre_process();
void execute(ProcessContext& context);
void post_process();
diff --git a/src/server/events/Get.cpp b/src/server/events/Get.cpp
index 80fc34e8..6e0aafda 100644
--- a/src/server/events/Get.cpp
+++ b/src/server/events/Get.cpp
@@ -48,20 +48,21 @@ Get::Get(Engine& engine,
{
}
-void
+bool
Get::pre_process()
{
_lock.acquire();
if (_uri == "ingen:plugins") {
_plugins = _engine.node_factory()->plugins();
+ return Event::pre_process_done(SUCCESS);
} else if (Raul::Path::is_valid(_uri.str())) {
_object = _engine.engine_store()->find_object(Raul::Path(_uri.str()));
+ return Event::pre_process_done(_object ? SUCCESS : NOT_FOUND);
} else {
_plugin = _engine.node_factory()->plugin(_uri);
+ return Event::pre_process_done(_plugin ? SUCCESS : NOT_FOUND);
}
-
- Event::pre_process();
}
static void
@@ -84,12 +85,9 @@ send_node(Interface* client, const NodeImpl* node)
PluginImpl* const plugin = node->plugin_impl();
if (plugin->type() == Plugin::Patch) {
send_patch(client, (PatchImpl*)node);
- } else if (plugin->uri().length() == 0) {
- Raul::error((Raul::fmt("Node %1%'s plugin has no URI\n")
- % node->path()));
} else {
client->put(node->path(), node->properties());
- for (size_t j=0; j < node->num_ports(); ++j) {
+ for (size_t j = 0; j < node->num_ports(); ++j) {
send_port(client, node->port_impl(j));
}
}
diff --git a/src/server/events/Get.hpp b/src/server/events/Get.hpp
index 146c2b39..f1b5003d 100644
--- a/src/server/events/Get.hpp
+++ b/src/server/events/Get.hpp
@@ -44,7 +44,8 @@ public:
SampleCount timestamp,
const Raul::URI& uri);
- void pre_process();
+ bool pre_process();
+ void execute(ProcessContext& context) {}
void post_process();
private:
diff --git a/src/server/events/Move.cpp b/src/server/events/Move.cpp
index 3874fcf1..84deba05 100644
--- a/src/server/events/Move.cpp
+++ b/src/server/events/Move.cpp
@@ -49,27 +49,22 @@ Move::~Move()
{
}
-void
+bool
Move::pre_process()
{
Glib::RWLock::WriterLock lock(_engine.engine_store()->lock());
if (!_old_path.parent().is_parent_of(_new_path)) {
- _status = PARENT_DIFFERS;
- Event::pre_process();
- return;
+ return Event::pre_process_done(PARENT_DIFFERS);
}
+
_store_iterator = _engine.engine_store()->find(_old_path);
- if (_store_iterator == _engine.engine_store()->end()) {
- _status = NOT_FOUND;
- Event::pre_process();
- return;
+ if (_store_iterator == _engine.engine_store()->end()) {
+ return Event::pre_process_done(NOT_FOUND);
}
- if (_engine.engine_store()->find_object(_new_path)) {
- _status = EXISTS;
- Event::pre_process();
- return;
+ if (_engine.engine_store()->find_object(_new_path)) {
+ return Event::pre_process_done(EXISTS);
}
SharedPtr< Raul::Table< Raul::Path, SharedPtr<GraphObject> > > removed
@@ -93,14 +88,12 @@ Move::pre_process()
_engine.engine_store()->add(*removed.get());
- Event::pre_process();
+ return Event::pre_process_done(SUCCESS);
}
void
Move::execute(ProcessContext& context)
{
- Event::execute(context);
-
SharedPtr<PortImpl> port = PtrCast<PortImpl>(_store_iterator->second);
if (port && port->parent()->parent() == NULL) {
EnginePort* eport = _engine.driver()->engine_port(context, _new_path);
diff --git a/src/server/events/Move.hpp b/src/server/events/Move.hpp
index 1b35e9bd..2e21b190 100644
--- a/src/server/events/Move.hpp
+++ b/src/server/events/Move.hpp
@@ -53,7 +53,7 @@ public:
~Move();
- void pre_process();
+ bool pre_process();
void execute(ProcessContext& context);
void post_process();
diff --git a/src/server/events/SetMetadata.cpp b/src/server/events/SetMetadata.cpp
index 26757426..7bd3e7a5 100644
--- a/src/server/events/SetMetadata.cpp
+++ b/src/server/events/SetMetadata.cpp
@@ -101,7 +101,7 @@ SetMetadata::~SetMetadata()
delete _create_event;
}
-void
+bool
SetMetadata::pre_process()
{
typedef Properties::const_iterator iterator;
@@ -116,9 +116,7 @@ SetMetadata::pre_process()
: static_cast<Shared::ResourceImpl*>(_engine.node_factory()->plugin(_subject));
if (!_object && (!is_graph_object || !_create)) {
- _status = NOT_FOUND;
- Event::pre_process();
- return;
+ return Event::pre_process_done(NOT_FOUND);
}
const Ingen::Shared::URIs& uris = _engine.world()->uris();
@@ -129,19 +127,15 @@ SetMetadata::pre_process()
Shared::ResourceImpl::type(uris, _properties, is_patch, is_node, is_port, is_output);
if (is_patch) {
- uint32_t poly = 1;
- iterator p = _properties.find(uris.ingen_polyphony);
- if (p != _properties.end() && p->second.is_valid() && p->second.type() == uris.forge.Int)
- poly = p->second.get_int32();
- _create_event = new CreatePatch(_engine, _request_client, _request_id, _time,
- path, poly, _properties);
+ _create_event = new CreatePatch(
+ _engine, _request_client, _request_id, _time, path, _properties);
} else if (is_node) {
- const iterator p = _properties.find(uris.ingen_prototype);
- _create_event = new CreateNode(_engine, _request_client, _request_id, _time,
- path, p->second.get_uri(), _properties);
+ _create_event = new CreateNode(
+ _engine, _request_client, _request_id, _time, path, _properties);
} else if (is_port) {
- _create_event = new CreatePort(_engine, _request_client, _request_id, _time,
- path, is_output, _properties);
+ _create_event = new CreatePort(
+ _engine, _request_client, _request_id, _time,
+ path, is_output, _properties);
}
if (_create_event) {
_create_event->pre_process();
@@ -177,7 +171,7 @@ SetMetadata::pre_process()
_object->remove_property(key, value);
}
- for (Properties::iterator p = _properties.begin(); p != _properties.end(); ++p) {
+ for (Properties::const_iterator p = _properties.begin(); p != _properties.end(); ++p) {
const Raul::URI& key = p->first;
const Resource::Property& value = p->second;
SpecialType op = NONE;
@@ -252,32 +246,34 @@ SetMetadata::pre_process()
}
}
- if (_status != SUCCESS) {
+ if (_status != NOT_PREPARED) {
break;
}
_types.push_back(op);
}
- Event::pre_process();
+ return Event::pre_process_done(_status == NOT_PREPARED ? SUCCESS : _status);
}
void
SetMetadata::execute(ProcessContext& context)
{
- if (_status != SUCCESS) {
- Event::execute(context);
+ if (_status) {
return;
}
const Ingen::Shared::URIs& uris = _engine.world()->uris();
if (_create_event) {
+ _create_event->set_time(_time);
_create_event->execute(context);
}
- for (SetEvents::iterator i = _set_events.begin(); i != _set_events.end(); ++i)
+ for (SetEvents::iterator i = _set_events.begin(); i != _set_events.end(); ++i) {
+ (*i)->set_time(_time);
(*i)->execute(context);
+ }
GraphObjectImpl* const object = dynamic_cast<GraphObjectImpl*>(_object);
NodeImpl* const node = dynamic_cast<NodeImpl*>(_object);
@@ -289,8 +285,9 @@ SetMetadata::execute(ProcessContext& context)
const Raul::Atom& value = p->second;
switch (*t) {
case ENABLE_BROADCAST:
- if (port)
+ if (port) {
port->broadcast(value.get_bool());
+ }
break;
case ENABLE:
if (value.get_bool()) {
@@ -303,15 +300,14 @@ SetMetadata::execute(ProcessContext& context)
_patch->disable(context);
}
break;
- case POLYPHONIC:
- {
- PatchImpl* parent = reinterpret_cast<PatchImpl*>(object->parent());
- if (value.get_bool())
- object->apply_poly(context, *_engine.maid(), parent->internal_poly());
- else
- object->apply_poly(context, *_engine.maid(), 1);
+ case POLYPHONIC: {
+ PatchImpl* parent = reinterpret_cast<PatchImpl*>(object->parent());
+ if (value.get_bool()) {
+ object->apply_poly(context, *_engine.maid(), parent->internal_poly());
+ } else {
+ object->apply_poly(context, *_engine.maid(), 1);
}
- break;
+ } break;
case POLYPHONY:
if (_patch->internal_poly() != static_cast<uint32_t>(value.get_int32()) &&
!_patch->apply_internal_poly(context,
@@ -340,8 +336,6 @@ SetMetadata::execute(ProcessContext& context)
break;
}
}
-
- Event::execute(context);
}
void
diff --git a/src/server/events/SetMetadata.hpp b/src/server/events/SetMetadata.hpp
index 84957e02..223339da 100644
--- a/src/server/events/SetMetadata.hpp
+++ b/src/server/events/SetMetadata.hpp
@@ -78,7 +78,7 @@ public:
~SetMetadata();
- void pre_process();
+ bool pre_process();
void execute(ProcessContext& context);
void post_process();
diff --git a/src/server/events/SetPortValue.cpp b/src/server/events/SetPortValue.cpp
index b4b26ccf..9eb57d55 100644
--- a/src/server/events/SetPortValue.cpp
+++ b/src/server/events/SetPortValue.cpp
@@ -69,19 +69,20 @@ SetPortValue::~SetPortValue()
{
}
-void
+bool
SetPortValue::pre_process()
{
- if (_queued) {
- if (_port == NULL)
- _port = _engine.engine_store()->find_port(_port_path);
- if (_port == NULL)
- _status = PORT_NOT_FOUND;
+ if (_queued && !_port) {
+ _port = _engine.engine_store()->find_port(_port_path);
+ }
+
+ if (!_port) {
+ return Event::pre_process_done(PORT_NOT_FOUND);
}
// Port is a message context port, set its value and
// call the plugin's message run function once
- if (_port && _port->parent_node()->context() == Context::MESSAGE) {
+ if (_port->parent_node()->context() == Context::MESSAGE) {
apply(_engine.message_context());
_engine.message_context().run(
_engine.message_context(),
@@ -89,20 +90,18 @@ SetPortValue::pre_process()
_engine.driver()->frame_time() + _engine.driver()->block_length());
}
- if (_port) {
- _port->set_value(_value);
- _port->set_property(_engine.world()->uris().ingen_value, _value);
- }
+ // Set value metadata (does not affect buffers)
+ _port->set_value(_value);
+ _port->set_property(_engine.world()->uris().ingen_value, _value);
_binding = _engine.control_bindings()->port_binding(_port);
- Event::pre_process();
+ return Event::pre_process_done(SUCCESS);
}
void
SetPortValue::execute(ProcessContext& context)
{
- Event::execute(context);
assert(_time >= context.start() && _time <= context.end());
if (_port && _port->parent_node()->context() == Context::MESSAGE)
diff --git a/src/server/events/SetPortValue.hpp b/src/server/events/SetPortValue.hpp
index a6166060..4d97ee99 100644
--- a/src/server/events/SetPortValue.hpp
+++ b/src/server/events/SetPortValue.hpp
@@ -59,7 +59,7 @@ public:
~SetPortValue();
- void pre_process();
+ bool pre_process();
void execute(ProcessContext& context);
void post_process();
diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp
index 2cc12846..c9c6907e 100644
--- a/src/server/ingen_lv2.cpp
+++ b/src/server/ingen_lv2.cpp
@@ -232,7 +232,7 @@ public:
/** AtomSink::write implementation called by the PostProcessor in the main
* thread to write responses to the UI.
*/
- void write(const LV2_Atom* atom) {
+ bool write(const LV2_Atom* atom) {
// Called from post-processor in main thread
while (_to_ui.write(lv2_atom_total_size(atom), atom) == 0) {
// Overflow, wait until ring is drained next cycle
@@ -240,6 +240,7 @@ public:
_to_ui_overflow_sem.wait();
_to_ui_overflow = false;
}
+ return true;
}
void consume_from_ui() {
diff --git a/src/server/wscript b/src/server/wscript
index 8f505983..c1ea75e9 100644
--- a/src/server/wscript
+++ b/src/server/wscript
@@ -12,7 +12,6 @@ def build(bld):
EdgeImpl.cpp
Engine.cpp
EngineStore.cpp
- Event.cpp
EventWriter.cpp
GraphObjectImpl.cpp
InputPort.cpp