summaryrefslogtreecommitdiffstats
path: root/src/server/LV2Options.hpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-08-31 18:07:47 +0000
committerDavid Robillard <d@drobilla.net>2012-08-31 18:07:47 +0000
commite435554efa3f7a6b9dba2320b6c10f49a027dec8 (patch)
treed8255e104550ba2acb8ee7665637ead0c0fba096 /src/server/LV2Options.hpp
parent809f4a8793c9d1dbc6e7d5bde41411d1d4b8bec0 (diff)
downloadingen-e435554efa3f7a6b9dba2320b6c10f49a027dec8.tar.gz
ingen-e435554efa3f7a6b9dba2320b6c10f49a027dec8.tar.bz2
ingen-e435554efa3f7a6b9dba2320b6c10f49a027dec8.zip
Implement host side of buf-size via options.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4763 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/server/LV2Options.hpp')
-rw-r--r--src/server/LV2Options.hpp84
1 files changed, 84 insertions, 0 deletions
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