diff options
Diffstat (limited to 'src/server/LV2Block.cpp')
-rw-r--r-- | src/server/LV2Block.cpp | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/src/server/LV2Block.cpp b/src/server/LV2Block.cpp index 026b7d06..c5cd73dc 100644 --- a/src/server/LV2Block.cpp +++ b/src/server/LV2Block.cpp @@ -14,12 +14,13 @@ along with Ingen. If not, see <http://www.gnu.org/licenses/>. */ +#include "LV2Block.hpp" + #include "Buffer.hpp" #include "BufferFactory.hpp" #include "Engine.hpp" #include "GraphImpl.hpp" #include "InputPort.hpp" -#include "LV2Block.hpp" #include "LV2Plugin.hpp" #include "OutputPort.hpp" #include "PortImpl.hpp" @@ -36,6 +37,7 @@ #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" @@ -55,8 +57,7 @@ #include <string> #include <utility> -namespace ingen { -namespace server { +namespace ingen::server { /** Partially construct a LV2Block. * @@ -70,7 +71,6 @@ LV2Block::LV2Block(LV2Plugin* plugin, SampleRate srate) : BlockImpl(plugin, symbol, polyphonic, parent, srate) , _lv2_plugin(plugin) - , _worker_iface(nullptr) { assert(_lv2_plugin); } @@ -271,7 +271,7 @@ LV2Block::instantiate(BufferFactory& bufs, const LilvState* state) is_morph = true; LilvNodes* types = lilv_port_get_value( plug, id, uris.morph_supportsType); - LILV_FOREACH(nodes, i, types) { + LILV_FOREACH (nodes, i, types) { const LilvNode* type = lilv_nodes_get(types, i); if (lilv_node_equals(type, uris.lv2_CVPort)) { port_type = PortType::CV; @@ -302,7 +302,7 @@ LV2Block::instantiate(BufferFactory& bufs, const LilvState* state) if (!buffer_type) { LilvNodes* types = lilv_port_get_value( plug, id, uris.atom_bufferType); - LILV_FOREACH(nodes, i, types) { + LILV_FOREACH (nodes, i, types) { const LilvNode* type = lilv_nodes_get(types, i); if (lilv_node_is_uri(type)) { buffer_type = world.uri_map().map_uri( @@ -327,7 +327,7 @@ LV2Block::instantiate(BufferFactory& bufs, const LilvState* state) if (port_type == PortType::ATOM) { // Get default value, and its length LilvNodes* defaults = lilv_port_get_value(plug, id, uris.lv2_default); - LILV_FOREACH(nodes, i, defaults) { + LILV_FOREACH (nodes, i, defaults) { const LilvNode* d = lilv_nodes_get(defaults, i); if (lilv_node_is_string(d)) { const char* str_val = lilv_node_as_string(d); @@ -347,10 +347,10 @@ LV2Block::instantiate(BufferFactory& bufs, const LilvState* state) // Get minimum size, if set in data LilvNodes* sizes = lilv_port_get_value(plug, id, uris.rsz_minimumSize); - LILV_FOREACH(nodes, i, sizes) { + 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); } } @@ -415,7 +415,7 @@ LV2Block::instantiate(BufferFactory& bufs, const LilvState* state) nullptr }; for (int p = 0; preds[p]; ++p) { LilvNodes* values = lilv_port_get_value(plug, id, preds[p]); - LILV_FOREACH(nodes, v, values) { + LILV_FOREACH (nodes, v, values) { const LilvNode* value = lilv_nodes_get(values, v); if (lilv_node_is_uri(value)) { port->add_property(URI(lilv_node_as_uri(preds[p])), @@ -482,7 +482,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(), @@ -497,7 +497,9 @@ LV2Block::save_state(const FilePath& dir) const if (!state) { return false; - } else if (lilv_state_get_num_properties(state.get()) == 0) { + } + + if (lilv_state_get_num_properties(state.get()) == 0) { return false; } @@ -520,7 +522,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(), @@ -588,10 +590,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); @@ -703,7 +705,7 @@ get_port_value(const char* port_symbol, return nullptr; } -boost::optional<Resource> +std::optional<Resource> LV2Block::save_preset(const URI& uri, const Properties& props) { @@ -716,20 +718,20 @@ 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 Properties::const_iterator l = props.find(_uris.rdfs_label); + const auto l = props.find(_uris.rdfs_label); if (l != props.end() && l->second.type() == _uris.atom_String) { lilv_state_set_label(state.get(), l->second.ptr<char>()); } @@ -756,7 +758,7 @@ LV2Block::save_preset(const URI& uri, return {preset}; } - return boost::optional<Resource>(); + return {}; } void @@ -772,5 +774,4 @@ LV2Block::set_port_buffer(uint32_t voice, buf ? buf->port_data(_ports->at(port_num)->type(), offset) : nullptr); } -} // namespace server -} // namespace ingen +} // namespace ingen::server |