From 6ec78b5a9eb499646d7fa6ccb306378426008e9d Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 19 Apr 2011 20:17:25 +0000 Subject: Make event queue size a runtime parameter (--queue-size, -q). git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3169 a436a847-0d15-0410-975c-d299462d15a1 --- src/engine/BufferFactory.cpp | 4 +++- src/engine/Context.hpp | 6 ++++-- src/engine/Engine.cpp | 15 +++++++++----- src/engine/Engine.hpp | 22 ++++++++++++-------- src/engine/JackDriver.cpp | 1 - src/engine/MessageContext.hpp | 3 +-- src/engine/QueuedEngineInterface.cpp | 1 - src/engine/QueuedEngineInterface.hpp | 1 - src/engine/ingen_engine.cpp | 3 +-- src/engine/ingen_http.cpp | 1 - src/engine/ingen_lv2.cpp | 2 +- src/engine/ingen_osc.cpp | 3 +-- src/engine/tuning.hpp | 40 ------------------------------------ src/shared/Configuration.cpp | 1 + 14 files changed, 35 insertions(+), 68 deletions(-) delete mode 100644 src/engine/tuning.hpp diff --git a/src/engine/BufferFactory.cpp b/src/engine/BufferFactory.cpp index 9eb51b54..7aac798a 100644 --- a/src/engine/BufferFactory.cpp +++ b/src/engine/BufferFactory.cpp @@ -31,6 +31,8 @@ using namespace Raul; namespace Ingen { namespace Engine { +static const size_t EVENT_BYTES_PER_FRAME = 4; // FIXME + BufferFactory::BufferFactory(Engine& engine, SharedPtr uris) : _engine(engine) @@ -78,7 +80,7 @@ BufferFactory::default_buffer_size(PortType type) case PortType::CONTROL: return sizeof(LV2_Atom) + sizeof(float); case PortType::EVENTS: - return _engine.driver()->block_length() * event_bytes_per_frame; + return _engine.driver()->block_length() * EVENT_BYTES_PER_FRAME; default: return 1024; // Who knows } diff --git a/src/engine/Context.hpp b/src/engine/Context.hpp index 8ef99f1d..5ffb8a93 100644 --- a/src/engine/Context.hpp +++ b/src/engine/Context.hpp @@ -18,8 +18,10 @@ #ifndef INGEN_ENGINE_CONTEXT_HPP #define INGEN_ENGINE_CONTEXT_HPP +#include "shared/World.hpp" + +#include "Engine.hpp" #include "EventSink.hpp" -#include "tuning.hpp" #include "types.hpp" namespace Ingen { @@ -50,7 +52,7 @@ public: Context(Engine& engine, ID id) : _engine(engine) , _id(id) - , _event_sink(engine, event_queue_size) + , _event_sink(engine, engine.event_queue_size()) , _start(0) , _end(0) , _nframes(0) diff --git a/src/engine/Engine.cpp b/src/engine/Engine.cpp index 31f4fc2a..357604ed 100644 --- a/src/engine/Engine.cpp +++ b/src/engine/Engine.cpp @@ -45,7 +45,6 @@ #include "ProcessContext.hpp" #include "QueuedEngineInterface.hpp" #include "ThreadManager.hpp" -#include "tuning.hpp" using namespace std; using namespace Raul; @@ -56,14 +55,14 @@ namespace Engine { bool ThreadManager::single_threaded = true; Engine::Engine(Ingen::Shared::World* a_world) - : _broadcaster(new ClientBroadcaster()) + : _world(a_world) + , _broadcaster(new ClientBroadcaster()) , _buffer_factory(new BufferFactory(*this, a_world->uris())) , _control_bindings(new ControlBindings(*this)) - , _maid(new Raul::Maid(maid_queue_size)) + , _maid(new Raul::Maid(event_queue_size())) , _message_context(new MessageContext(*this)) , _node_factory(new NodeFactory(a_world)) - , _post_processor(new PostProcessor(*this, post_processor_queue_size)) - , _world(a_world) + , _post_processor(new PostProcessor(*this, event_queue_size())) { if (a_world->store()) { assert(PtrCast(a_world->store())); @@ -96,6 +95,12 @@ Engine::engine_store() const return PtrCast(_world->store()); } +size_t +Engine::event_queue_size() const +{ + return world()->conf()->option("queue-size").get_int32(); +} + void Engine::quit() { diff --git a/src/engine/Engine.hpp b/src/engine/Engine.hpp index af8bc48f..ffcd5dc9 100644 --- a/src/engine/Engine.hpp +++ b/src/engine/Engine.hpp @@ -76,6 +76,8 @@ public: void process_events(ProcessContext& context); + Ingen::Shared::World* world() const { return _world; } + ClientBroadcaster* broadcaster() const { return _broadcaster; } BufferFactory* buffer_factory() const { return _buffer_factory; } ControlBindings* control_bindings() const { return _control_bindings; } @@ -84,21 +86,23 @@ public: MessageContext* message_context() const { return _message_context; } NodeFactory* node_factory() const { return _node_factory; } PostProcessor* post_processor() const { return _post_processor; } - Ingen::Shared::World* world() const { return _world; } SharedPtr engine_store() const; + size_t event_queue_size() const; + private: - ClientBroadcaster* _broadcaster; - BufferFactory* _buffer_factory; - ControlBindings* _control_bindings; - SharedPtr _driver; - Raul::Maid* _maid; - MessageContext* _message_context; - NodeFactory* _node_factory; - PostProcessor* _post_processor; Ingen::Shared::World* _world; + ClientBroadcaster* _broadcaster; + BufferFactory* _buffer_factory; + ControlBindings* _control_bindings; + SharedPtr _driver; + Raul::Maid* _maid; + MessageContext* _message_context; + NodeFactory* _node_factory; + PostProcessor* _post_processor; + typedef std::set< SharedPtr > EventSources; EventSources _event_sources; diff --git a/src/engine/JackDriver.cpp b/src/engine/JackDriver.cpp index 9bb81536..6a118778 100644 --- a/src/engine/JackDriver.cpp +++ b/src/engine/JackDriver.cpp @@ -50,7 +50,6 @@ #include "shared/World.hpp" #include "shared/LV2Features.hpp" #include "shared/LV2URIMap.hpp" -#include "tuning.hpp" #include "util.hpp" #define LOG(s) s << "[JackDriver] " diff --git a/src/engine/MessageContext.hpp b/src/engine/MessageContext.hpp index 14cd3999..ccdda448 100644 --- a/src/engine/MessageContext.hpp +++ b/src/engine/MessageContext.hpp @@ -27,7 +27,6 @@ #include "Context.hpp" #include "ProcessContext.hpp" #include "ThreadManager.hpp" -#include "tuning.hpp" namespace Ingen { namespace Engine { @@ -50,7 +49,7 @@ public: : Context(engine, MESSAGE) , Raul::Thread("MessageContext") , _sem(0) - , _requests(message_context_queue_size) + , _requests(engine.event_queue_size()) , _end_time(0) { Thread::set_context(THREAD_MESSAGE); diff --git a/src/engine/QueuedEngineInterface.cpp b/src/engine/QueuedEngineInterface.cpp index 210c6374..8e9363ec 100644 --- a/src/engine/QueuedEngineInterface.cpp +++ b/src/engine/QueuedEngineInterface.cpp @@ -24,7 +24,6 @@ #include "EventSource.hpp" #include "QueuedEngineInterface.hpp" #include "events.hpp" -#include "tuning.hpp" #define LOG(s) s << "[QueuedEngineInterface] " diff --git a/src/engine/QueuedEngineInterface.hpp b/src/engine/QueuedEngineInterface.hpp index 8dbb1548..a2c13040 100644 --- a/src/engine/QueuedEngineInterface.hpp +++ b/src/engine/QueuedEngineInterface.hpp @@ -27,7 +27,6 @@ #include "ingen/Resource.hpp" #include "EventSource.hpp" #include "Request.hpp" -#include "tuning.hpp" #include "types.hpp" namespace Ingen { diff --git a/src/engine/ingen_engine.cpp b/src/engine/ingen_engine.cpp index 7022f567..c31e5e33 100644 --- a/src/engine/ingen_engine.cpp +++ b/src/engine/ingen_engine.cpp @@ -20,7 +20,6 @@ #include "Engine.hpp" #include "QueuedEngineInterface.hpp" #include "util.hpp" -#include "tuning.hpp" using namespace Ingen; @@ -31,7 +30,7 @@ struct IngenEngineModule : public Ingen::Shared::Module { world->set_local_engine(engine); SharedPtr interface( new Engine::QueuedEngineInterface(*engine.get(), - Engine::event_queue_size)); + engine->event_queue_size())); world->set_engine(interface); engine->add_event_source(interface); assert(world->local_engine() == engine); diff --git a/src/engine/ingen_http.cpp b/src/engine/ingen_http.cpp index c758e10b..f7153ca2 100644 --- a/src/engine/ingen_http.cpp +++ b/src/engine/ingen_http.cpp @@ -19,7 +19,6 @@ #include "shared/World.hpp" #include "HTTPEngineReceiver.hpp" #include "Engine.hpp" -#include "tuning.hpp" using namespace std; using namespace Ingen; diff --git a/src/engine/ingen_lv2.cpp b/src/engine/ingen_lv2.cpp index 0c943a7a..c6a250b7 100644 --- a/src/engine/ingen_lv2.cpp +++ b/src/engine/ingen_lv2.cpp @@ -270,7 +270,7 @@ ingen_instantiate(const LV2_Descriptor* descriptor, SharedPtr interface( new Engine::QueuedEngineInterface( *engine.get(), - Engine::event_queue_size)); + engine->event_queue_size())); plugin->world->set_engine(interface); engine->add_event_source(interface); diff --git a/src/engine/ingen_osc.cpp b/src/engine/ingen_osc.cpp index 09428508..252d984e 100644 --- a/src/engine/ingen_osc.cpp +++ b/src/engine/ingen_osc.cpp @@ -19,7 +19,6 @@ #include "shared/World.hpp" #include "OSCEngineReceiver.hpp" #include "Engine.hpp" -#include "tuning.hpp" using namespace std; using namespace Ingen; @@ -30,7 +29,7 @@ struct IngenOSCModule : public Ingen::Shared::Module { SharedPtr interface( new Engine::OSCEngineReceiver( *engine, - Engine::event_queue_size, + engine->event_queue_size(), world->conf()->option("engine-port").get_int32())); engine->add_event_source(interface); } diff --git a/src/engine/tuning.hpp b/src/engine/tuning.hpp deleted file mode 100644 index 8bd8e204..00000000 --- a/src/engine/tuning.hpp +++ /dev/null @@ -1,40 +0,0 @@ -/* This file is part of Ingen. - * Copyright 2007-2011 David Robillard - * - * Ingen is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef INGEN_ENGINE_TUNING_HPP -#define INGEN_ENGINE_TUNING_HPP - -#include -#include - -namespace Ingen { -namespace Engine { - -// FIXME: put this in a Config class - -static const size_t event_queue_size = 1024; -static const size_t pre_processor_queue_size = 1024; -static const size_t post_processor_queue_size = 1024; -static const size_t maid_queue_size = 1024; -static const size_t message_context_queue_size = 1024; - -static const size_t event_bytes_per_frame = 4; - -} // namespace Engine -} // namespace Ingen - -#endif // INGEN_ENGINE_TUNING_HPP diff --git a/src/shared/Configuration.cpp b/src/shared/Configuration.cpp index 3cf07a14..650a1d8b 100644 --- a/src/shared/Configuration.cpp +++ b/src/shared/Configuration.cpp @@ -53,6 +53,7 @@ Configuration::Configuration() .add("load", 'l', "Load patch", Atom::STRING, Atom()) .add("parallelism", 'p', "Number of concurrent process threads", Atom::INT, 1) .add("path", 'L', "Target path for loaded patch", Atom::STRING, Atom()) + .add("queue-size", 'q', "Event queue size", Atom::INT, 1024) .add("run", 'r', "Run script", Atom::STRING, Atom()); } -- cgit v1.2.1