From e435554efa3f7a6b9dba2320b6c10f49a027dec8 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 31 Aug 2012 18:07:47 +0000 Subject: Implement host side of buf-size via options. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4763 a436a847-0d15-0410-975c-d299462d15a1 --- src/server/LV2Options.hpp | 84 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 src/server/LV2Options.hpp (limited to 'src/server/LV2Options.hpp') 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 + + 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 . +*/ + +#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 feature(World* w, Node* n) { + BlockImpl* block = dynamic_cast(n); + if (!block) { + return SharedPtr(); + } + 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(f, &delete_feature); + } + +private: + int32_t _block_length; + int32_t _seq_size; +}; + +} // namespace Server +} // namespace Ingen + +#endif // INGEN_ENGINE_LV2OPTIONS_HPP -- cgit v1.2.1