summaryrefslogtreecommitdiffstats
path: root/src/server/ingen_lv2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/ingen_lv2.cpp')
-rw-r--r--src/server/ingen_lv2.cpp76
1 files changed, 36 insertions, 40 deletions
diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp
index d709e41a..45a193c1 100644
--- a/src/server/ingen_lv2.cpp
+++ b/src/server/ingen_lv2.cpp
@@ -15,7 +15,6 @@
*/
#include "Buffer.hpp"
-#include "BufferRef.hpp"
#include "Driver.hpp"
#include "DuplexPort.hpp"
#include "Engine.hpp"
@@ -90,7 +89,8 @@ struct LV2Graph : public Parser::ResourceRecord {
};
/** Ingen LV2 library. */
-class Lib {
+class Lib
+{
public:
explicit Lib(const char* bundle_path);
@@ -124,15 +124,9 @@ public:
*this)
, _from_ui(ui_ring_size(block_length))
, _to_ui(ui_ring_size(block_length))
- , _root_graph(nullptr)
- , _notify_capacity(0)
, _block_length(block_length)
, _seq_size(seq_size)
, _sample_rate(sample_rate)
- , _frame_time(0)
- , _to_ui_overflow_sem(0)
- , _to_ui_overflow(false)
- , _instantiated(false)
{}
bool dynamic_ports() const override { return !_instantiated; }
@@ -151,11 +145,11 @@ public:
lv2_atom_total_size(
static_cast<LV2_Atom*>(lv2_buf)));
- if (graph_port->symbol() == "control") { // TODO: Safe to use index?
+ if (graph_port->symbol() == "control") { // TODO: Safe to use index?
auto* seq = reinterpret_cast<LV2_Atom_Sequence*>(lv2_buf);
bool enqueued = false;
- LV2_ATOM_SEQUENCE_FOREACH(seq, ev)
+ LV2_ATOM_SEQUENCE_FOREACH (seq, ev)
{
if (AtomReader::is_message(uris, &ev->body)) {
enqueued = enqueue_message(&ev->body) || enqueued;
@@ -268,7 +262,7 @@ public:
const URIs& uris = _engine.world().uris();
auto* seq = static_cast<LV2_Atom_Sequence*>(_ports[0]->buffer());
- LV2_ATOM_SEQUENCE_FOREACH(seq, ev) {
+ LV2_ATOM_SEQUENCE_FOREACH (seq, ev) {
if (ev->body.type == uris.atom_Object) {
const LV2_Atom_Object* obj =
reinterpret_cast<LV2_Atom_Object*>(&ev->body);
@@ -365,14 +359,14 @@ public:
if (seq->atom.size + lv2_atom_pad_size(
sizeof(LV2_Atom_Event) + atom.size)
> _notify_capacity) {
- break; // Output port buffer full, resume next time
+ break; // Output port buffer full, resume next time
}
auto* ev = reinterpret_cast<LV2_Atom_Event*>(
reinterpret_cast<uint8_t*>(seq) +
lv2_atom_total_size(&seq->atom));
- ev->time.frames = 0; // TODO: Time?
+ ev->time.frames = 0; // TODO: Time?
ev->body = atom;
_to_ui.skip(sizeof(LV2_Atom));
@@ -413,15 +407,15 @@ private:
AtomWriter _writer;
raul::RingBuffer _from_ui;
raul::RingBuffer _to_ui;
- GraphImpl* _root_graph;
- uint32_t _notify_capacity;
+ GraphImpl* _root_graph{nullptr};
+ uint32_t _notify_capacity{0};
SampleCount _block_length;
size_t _seq_size;
SampleCount _sample_rate;
- SampleCount _frame_time;
- raul::Semaphore _to_ui_overflow_sem;
- bool _to_ui_overflow;
- bool _instantiated;
+ SampleCount _frame_time{0};
+ raul::Semaphore _to_ui_overflow_sem{0};
+ bool _to_ui_overflow{false};
+ bool _instantiated{false};
};
struct IngenPlugin {
@@ -501,7 +495,9 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
if (!map) {
lv2_log_error(&logger, "host did not provide URI map feature\n");
return nullptr;
- } else if (!unmap) {
+ }
+
+ if (!unmap) {
lv2_log_error(&logger, "host did not provide URI unmap feature\n");
return nullptr;
}
@@ -515,7 +511,7 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
nullptr,
true);
- Lib::Graphs graphs = find_graphs(URI(reinterpret_cast<const char*>(manifest_node.buf)));
+ const Lib::Graphs graphs = find_graphs(URI(reinterpret_cast<const char*>(manifest_node.buf)));
serd_node_free(&manifest_node);
const LV2Graph* graph = nullptr;
@@ -533,14 +529,14 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
auto* plugin = new IngenPlugin();
plugin->map = map;
- plugin->world = make_unique<ingen::World>(map, unmap, log);
+ plugin->world = std::make_unique<ingen::World>(map, unmap, log);
plugin->world->load_configuration(plugin->argc, plugin->argv);
- LV2_URID bufsz_max = map->map(map->handle, LV2_BUF_SIZE__maxBlockLength);
- LV2_URID bufsz_seq = map->map(map->handle, LV2_BUF_SIZE__sequenceSize);
- LV2_URID atom_Int = map->map(map->handle, LV2_ATOM__Int);
- int32_t block_length = 0;
- int32_t seq_size = 0;
+ const LV2_URID bufsz_max = map->map(map->handle, LV2_BUF_SIZE__maxBlockLength);
+ const LV2_URID bufsz_seq = map->map(map->handle, LV2_BUF_SIZE__sequenceSize);
+ const LV2_URID atom_Int = map->map(map->handle, LV2_ATOM__Int);
+ int32_t block_length = 0;
+ int32_t seq_size = 0;
if (options) {
for (const LV2_Options_Option* o = options; o->key; ++o) {
if (o->key == bufsz_max && o->type == atom_Int) {
@@ -570,7 +566,7 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
plugin->engine = engine;
plugin->world->set_engine(engine);
- std::shared_ptr<Interface> interface = engine->interface();
+ const std::shared_ptr<Interface> interface = engine->interface();
plugin->world->set_interface(interface);
@@ -583,7 +579,7 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
engine->activate();
ThreadManager::single_threaded = true;
- std::lock_guard<std::mutex> lock(plugin->world->rdf_mutex());
+ const std::lock_guard<std::mutex> lock{plugin->world->rdf_mutex()};
// Locate to time 0 to process initialization events
engine->locate(0, block_length);
@@ -605,7 +601,7 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
/* Register client after loading graph so the to-ui ring does not overflow.
Since we are not yet rolling, it won't be drained, causing a deadlock. */
- std::shared_ptr<Interface> client(&driver->writer(), NullDeleter<Interface>);
+ const std::shared_ptr<Interface> client{&driver->writer(), NullDeleter<Interface>};
interface->set_respondee(client);
engine->register_client(client);
@@ -633,7 +629,7 @@ ingen_activate(LV2_Handle instance)
auto engine = std::static_pointer_cast<Engine>(me->world->engine());
const auto driver = std::static_pointer_cast<LV2Driver>(engine->driver());
engine->activate();
- me->main = make_unique<std::thread>(ingen_lv2_main, engine, driver);
+ me->main = std::make_unique<std::thread>(ingen_lv2_main, engine, driver);
}
static void
@@ -706,9 +702,9 @@ ingen_save(LV2_Handle instance,
return LV2_STATE_ERR_NO_FEATURE;
}
- LV2_URID ingen_file = plugin->map->map(plugin->map->handle, INGEN__file);
- LV2_URID atom_Path = plugin->map->map(plugin->map->handle,
- LV2_ATOM__Path);
+ const LV2_URID ingen_file = plugin->map->map(plugin->map->handle, INGEN__file);
+ const LV2_URID atom_Path = plugin->map->map(plugin->map->handle,
+ LV2_ATOM__Path);
char* real_path = make_path->path(make_path->handle, "main.ttl");
char* state_path = map_path->abstract_path(map_path->handle, real_path);
@@ -716,7 +712,7 @@ ingen_save(LV2_Handle instance,
auto root = plugin->world->store()->find(raul::Path("/"));
{
- std::lock_guard<std::mutex> lock(plugin->world->rdf_mutex());
+ const std::lock_guard<std::mutex> lock{plugin->world->rdf_mutex()};
plugin->world->serialiser()->start_to_file(
root->second->path(), FilePath{real_path});
@@ -752,10 +748,10 @@ ingen_restore(LV2_Handle instance,
return LV2_STATE_ERR_NO_FEATURE;
}
- LV2_URID ingen_file = plugin->map->map(plugin->map->handle, INGEN__file);
- size_t size = 0;
- uint32_t type = 0;
- uint32_t valflags = 0;
+ const LV2_URID ingen_file = plugin->map->map(plugin->map->handle, INGEN__file);
+ size_t size = 0;
+ uint32_t type = 0;
+ uint32_t valflags = 0;
// Get abstract path to graph file
const char* path = static_cast<const char*>(
@@ -787,7 +783,7 @@ ingen_restore(LV2_Handle instance,
#endif
// Load new graph
- std::lock_guard<std::mutex> lock(plugin->world->rdf_mutex());
+ const std::lock_guard<std::mutex> lock{plugin->world->rdf_mutex()};
plugin->world->parser()->parse_file(
*plugin->world, *plugin->world->interface(), real_path);