summaryrefslogtreecommitdiffstats
path: root/src/server
diff options
context:
space:
mode:
Diffstat (limited to 'src/server')
-rw-r--r--src/server/Engine.cpp6
-rw-r--r--src/server/Engine.hpp26
-rw-r--r--src/server/LV2Options.hpp84
3 files changed, 103 insertions, 13 deletions
diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp
index deb1ff50..4a1afb86 100644
--- a/src/server/Engine.cpp
+++ b/src/server/Engine.cpp
@@ -35,6 +35,7 @@
#include "Event.hpp"
#include "EventWriter.hpp"
#include "GraphImpl.hpp"
+#include "LV2Options.hpp"
#include "PostProcessor.hpp"
#include "PreProcessor.hpp"
#include "ProcessContext.hpp"
@@ -55,10 +56,11 @@ Engine::Engine(Ingen::World* world)
, _broadcaster(new Broadcaster())
, _buffer_factory(new BufferFactory(*this, world->uris()))
, _control_bindings(NULL)
+ , _event_writer(new EventWriter(*this))
, _maid(new Raul::Maid())
+ , _options(new LV2Options(*this))
, _pre_processor(new PreProcessor())
, _post_processor(new PostProcessor(*this))
- , _event_writer(new EventWriter(*this))
, _root_graph(NULL)
, _worker(new Worker(world->log(), event_queue_size()))
, _process_context(*this)
@@ -72,6 +74,7 @@ Engine::Engine(Ingen::World* world)
_control_bindings = new ControlBindings(*this);
_world->lv2_features().add_feature(_worker->schedule_feature());
+ _world->lv2_features().add_feature(_options);
}
Engine::~Engine()
@@ -179,6 +182,7 @@ Engine::activate()
ThreadManager::single_threaded = true;
_buffer_factory->set_block_length(_driver->block_length());
+ _options->set(*this);
_pre_processor->start();
diff --git a/src/server/Engine.hpp b/src/server/Engine.hpp
index 2d49bde0..692fbee8 100644
--- a/src/server/Engine.hpp
+++ b/src/server/Engine.hpp
@@ -42,6 +42,7 @@ class Driver;
class Event;
class EventWriter;
class GraphImpl;
+class LV2Options;
class PostProcessor;
class PreProcessor;
class ProcessContext;
@@ -92,7 +93,7 @@ public:
Ingen::World* world() const { return _world; }
EventWriter* interface() const { return _event_writer; }
- BlockFactory* block_factory() const { return _block_factory; }
+ BlockFactory* block_factory() const { return _block_factory; }
Broadcaster* broadcaster() const { return _broadcaster; }
BufferFactory* buffer_factory() const { return _buffer_factory; }
ControlBindings* control_bindings() const { return _control_bindings; }
@@ -112,17 +113,18 @@ public:
private:
Ingen::World* _world;
- BlockFactory* _block_factory;
- Broadcaster* _broadcaster;
- BufferFactory* _buffer_factory;
- ControlBindings* _control_bindings;
- SharedPtr<Driver> _driver;
- Raul::Maid* _maid;
- PreProcessor* _pre_processor;
- PostProcessor* _post_processor;
- EventWriter* _event_writer;
- GraphImpl* _root_graph;
- Worker* _worker;
+ BlockFactory* _block_factory;
+ Broadcaster* _broadcaster;
+ BufferFactory* _buffer_factory;
+ ControlBindings* _control_bindings;
+ SharedPtr<Driver> _driver;
+ EventWriter* _event_writer;
+ Raul::Maid* _maid;
+ SharedPtr<LV2Options> _options;
+ PreProcessor* _pre_processor;
+ PostProcessor* _post_processor;
+ GraphImpl* _root_graph;
+ Worker* _worker;
ProcessContext _process_context;
diff --git a/src/server/LV2Options.hpp b/src/server/LV2Options.hpp
new file mode 100644
index 00000000..fd3801f1
--- /dev/null
+++ b/src/server/LV2Options.hpp
@@ -0,0 +1,84 @@
+/*
+ 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/>.
+*/
+
+#ifndef INGEN_ENGINE_LV2OPTIONS_HPP
+#define INGEN_ENGINE_LV2OPTIONS_HPP
+
+#include "ingen/LV2Features.hpp"
+#include "lv2/lv2plug.in/ns/ext/options/options.h"
+
+#include "BlockImpl.hpp"
+#include "BufferFactory.hpp"
+#include "Driver.hpp"
+#include "Engine.hpp"
+
+namespace Ingen {
+namespace Server {
+
+struct LV2Options : public Ingen::LV2Features::Feature {
+ LV2Options(Engine& engine)
+ : _block_length(0)
+ , _seq_size(0)
+ {
+ set(engine);
+ }
+
+ static void delete_feature(LV2_Feature* feature) {
+ free(feature->data);
+ free(feature);
+ }
+
+ void set(Engine& engine) {
+ if (engine.driver()) {
+ _block_length = engine.driver()->block_length();
+ _seq_size = engine.buffer_factory()->default_size(
+ engine.world()->uris().atom_Sequence);
+ }
+ }
+
+ SharedPtr<LV2_Feature> feature(World* w, Node* n) {
+ BlockImpl* block = dynamic_cast<BlockImpl*>(n);
+ if (!block) {
+ return SharedPtr<LV2_Feature>();
+ }
+ Engine& engine = block->parent_graph()->engine();
+ URIs& uris = engine.world()->uris();
+ const LV2_Options_Option options[] = {
+ { uris.bufsz_minBlockLength, sizeof(int32_t), uris.atom_Int,
+ &_block_length },
+ { uris.bufsz_maxBlockLength, sizeof(int32_t), uris.atom_Int,
+ &_block_length },
+ { uris.bufsz_sequenceSize, sizeof(int32_t), uris.atom_Int,
+ &_seq_size },
+ { 0, 0, 0, NULL }
+ };
+
+ LV2_Feature* f = (LV2_Feature*)malloc(sizeof(LV2_Feature));
+ f->URI = LV2_OPTIONS__options;
+ f->data = malloc(sizeof(options));
+ memcpy(f->data, options, sizeof(options));
+ return SharedPtr<LV2_Feature>(f, &delete_feature);
+ }
+
+private:
+ int32_t _block_length;
+ int32_t _seq_size;
+};
+
+} // namespace Server
+} // namespace Ingen
+
+#endif // INGEN_ENGINE_LV2OPTIONS_HPP