diff options
Diffstat (limited to 'src/server/LV2Block.cpp')
-rw-r--r-- | src/server/LV2Block.cpp | 82 |
1 files changed, 43 insertions, 39 deletions
diff --git a/src/server/LV2Block.cpp b/src/server/LV2Block.cpp index 6dac1eec..ad7b28ae 100644 --- a/src/server/LV2Block.cpp +++ b/src/server/LV2Block.cpp @@ -28,24 +28,27 @@ #include "RunContext.hpp" #include "Worker.hpp" -#include "ingen/Atom.hpp" -#include "ingen/FilePath.hpp" -#include "ingen/Forge.hpp" -#include "ingen/Log.hpp" -#include "ingen/Resource.hpp" -#include "ingen/URI.hpp" -#include "ingen/URIMap.hpp" -#include "ingen/URIs.hpp" -#include "ingen/World.hpp" -#include "lv2/core/lv2.h" -#include "lv2/options/options.h" -#include "lv2/state/state.h" -#include "lv2/urid/urid.h" -#include "lv2/worker/worker.h" -#include "raul/Array.hpp" -#include "raul/Maid.hpp" -#include "raul/Path.hpp" -#include "raul/Symbol.hpp" +#include <ingen/Atom.hpp> +#include <ingen/FilePath.hpp> +#include <ingen/Forge.hpp> +#include <ingen/LV2Features.hpp> +#include <ingen/Log.hpp> +#include <ingen/Properties.hpp> +#include <ingen/Resource.hpp> +#include <ingen/URI.hpp> +#include <ingen/URIMap.hpp> +#include <ingen/URIs.hpp> +#include <ingen/World.hpp> +#include <lilv/lilv.h> +#include <lv2/core/lv2.h> +#include <lv2/options/options.h> +#include <lv2/state/state.h> +#include <lv2/urid/urid.h> +#include <lv2/worker/worker.h> +#include <raul/Array.hpp> +#include <raul/Maid.hpp> +#include <raul/Path.hpp> +#include <raul/Symbol.hpp> #include <algorithm> #include <cassert> @@ -53,6 +56,7 @@ #include <cstdint> #include <map> #include <memory> +#include <optional> #include <string> #include <utility> @@ -109,7 +113,7 @@ LV2Block::make_instance(URIs& uris, } for (uint32_t p = 0; p < num_ports(); ++p) { - PortImpl* const port = _ports->at(p); + const PortImpl* const port = _ports->at(p); Buffer* const buffer = (preparing) ? port->prepared_buffer(voice).get() : port->buffer(voice).get(); @@ -222,7 +226,7 @@ LV2Block::apply_poly(RunContext& ctx, uint32_t poly) /** Instantiate self from LV2 plugin descriptor. * - * Implemented as a seperate function (rather than in the constructor) to + * Implemented as a separate function (rather than in the constructor) to * allow graceful error-catching of broken plugins. * * Returns whether or not plugin was successfully instantiated. If return @@ -349,7 +353,7 @@ LV2Block::instantiate(BufferFactory& bufs, const LilvState* state) LILV_FOREACH (nodes, i, sizes) { const LilvNode* d = lilv_nodes_get(sizes, i); if (lilv_node_is_int(d)) { - uint32_t size_val = lilv_node_as_int(d); + const uint32_t size_val = lilv_node_as_int(d); port_buffer_size = std::max(port_buffer_size, size_val); } } @@ -481,7 +485,7 @@ LV2Block::save_state(const FilePath& dir) const World& world = _lv2_plugin->world(); LilvWorld* lworld = world.lilv_world(); - StatePtr state{ + const StatePtr state{ lilv_state_new_from_instance(_lv2_plugin->lilv_plugin(), const_cast<LV2Block*>(this)->instance(0), &world.uri_map().urid_map(), @@ -521,7 +525,7 @@ LV2Block::duplicate(Engine& engine, const SampleRate rate = engine.sample_rate(); // Get current state - StatePtr state{ + const StatePtr state{ lilv_state_new_from_instance(_lv2_plugin->lilv_plugin(), instance(0), &engine.world().uri_map().urid_map(), @@ -589,10 +593,10 @@ LV2_Worker_Status LV2Block::work(uint32_t size, const void* data) { if (_worker_iface) { - std::lock_guard<std::mutex> lock(_work_mutex); + const std::lock_guard<std::mutex> lock{_work_mutex}; - LV2_Handle inst = lilv_instance_get_handle(instance(0)); - LV2_Worker_Status st = _worker_iface->work(inst, work_respond, this, size, data); + LV2_Handle inst = lilv_instance_get_handle(instance(0)); + const LV2_Worker_Status st = _worker_iface->work(inst, work_respond, this, size, data); if (st) { parent_graph()->engine().log().error( "Error calling %1% work method\n", _path); @@ -692,8 +696,8 @@ get_port_value(const char* port_symbol, uint32_t* size, uint32_t* type) { - auto* const block = static_cast<LV2Block*>(user_data); - auto* const port = block->port_by_symbol(port_symbol); + auto* const block = static_cast<LV2Block*>(user_data); + const auto* const port = block->port_by_symbol(port_symbol); if (port && port->is_input() && port->value().is_valid()) { *size = port->value().size(); @@ -717,17 +721,17 @@ LV2Block::save_preset(const URI& uri, const FilePath dirname = path.parent_path(); const FilePath basename = path.stem(); - StatePtr state{lilv_state_new_from_instance(_lv2_plugin->lilv_plugin(), - instance(0), - lmap, - nullptr, - nullptr, - nullptr, - path.c_str(), - get_port_value, - this, - LV2_STATE_IS_NATIVE, - nullptr)}; + const StatePtr state{lilv_state_new_from_instance(_lv2_plugin->lilv_plugin(), + instance(0), + lmap, + nullptr, + nullptr, + nullptr, + path.c_str(), + get_port_value, + this, + LV2_STATE_IS_NATIVE, + nullptr)}; if (state) { const auto l = props.find(_uris.rdfs_label); |