summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-08-01 15:20:45 +0200
committerDavid Robillard <d@drobilla.net>2020-08-02 01:48:48 +0200
commit4ef41be9596cf997cd80175cfc7de2074a182d0d (patch)
tree33388d991953b7d1fae5a953e0fa08b545e99a41 /src
parentdbb38be5ccda387ef458583b5a85c03b59a5e05c (diff)
downloadingen-4ef41be9596cf997cd80175cfc7de2074a182d0d.tar.gz
ingen-4ef41be9596cf997cd80175cfc7de2074a182d0d.tar.bz2
ingen-4ef41be9596cf997cd80175cfc7de2074a182d0d.zip
Use auto with casts and allocations to remove redundancy
Diffstat (limited to 'src')
-rw-r--r--src/SocketReader.cpp4
-rw-r--r--src/client/PluginUI.cpp15
-rw-r--r--src/gui/GraphBox.cpp8
-rw-r--r--src/gui/GraphCanvas.cpp26
-rw-r--r--src/gui/GraphPortModule.cpp4
-rw-r--r--src/gui/GraphTreeWindow.cpp2
-rw-r--r--src/server/BlockImpl.hpp6
-rw-r--r--src/server/Buffer.cpp6
-rw-r--r--src/server/CompiledGraph.cpp24
-rw-r--r--src/server/JackDriver.cpp16
-rw-r--r--src/server/LV2Options.hpp2
-rw-r--r--src/server/PortAudioDriver.cpp4
-rw-r--r--src/server/UndoStack.hpp2
-rw-r--r--src/server/ingen_jack.cpp6
-rw-r--r--src/server/ingen_lv2.cpp37
-rw-r--r--src/server/ingen_portaudio.cpp2
-rw-r--r--src/server/internals/Controller.cpp9
-rw-r--r--src/server/internals/Note.cpp7
-rw-r--r--src/server/internals/Time.cpp4
-rw-r--r--src/server/internals/Trigger.cpp13
-rw-r--r--src/server/mix.cpp4
21 files changed, 103 insertions, 98 deletions
diff --git a/src/SocketReader.cpp b/src/SocketReader.cpp
index 88aad63f..c94f0287 100644
--- a/src/SocketReader.cpp
+++ b/src/SocketReader.cpp
@@ -97,7 +97,7 @@ SocketReader::write_statement(SocketReader* iface,
size_t
SocketReader::c_recv(void* buf, size_t size, size_t nmemb, void* stream)
{
- SocketReader* self = static_cast<SocketReader*>(stream);
+ auto* self = static_cast<SocketReader*>(stream);
const ssize_t c = recv(self->_socket->fd(), buf, size * nmemb, MSG_WAITALL);
if (c < 0) {
@@ -111,7 +111,7 @@ SocketReader::c_recv(void* buf, size_t size, size_t nmemb, void* stream)
int
SocketReader::c_err(void* stream)
{
- SocketReader* self = static_cast<SocketReader*>(stream);
+ auto* self = static_cast<SocketReader*>(stream);
return self->_socket_error;
}
diff --git a/src/client/PluginUI.cpp b/src/client/PluginUI.cpp
index 6fdf76c5..9c759696 100644
--- a/src/client/PluginUI.cpp
+++ b/src/client/PluginUI.cpp
@@ -52,7 +52,7 @@ lv2_ui_write(SuilController controller,
uint32_t format,
const void* buffer)
{
- PluginUI* const ui = static_cast<PluginUI*>(controller);
+ auto* const ui = static_cast<PluginUI*>(controller);
const URIs& uris = ui->world().uris();
SPtr<const PortModel> port = get_port(ui, port_index);
if (!port) {
@@ -80,9 +80,10 @@ lv2_ui_write(SuilController controller,
Resource::Graph::DEFAULT);
} else if (format == uris.atom_eventTransfer.urid()) {
- const LV2_Atom* atom = static_cast<const LV2_Atom*>(buffer);
- Atom val = ui->world().forge().alloc(
- atom->size, atom->type, LV2_ATOM_BODY_CONST(atom));
+ const auto* atom = static_cast<const LV2_Atom*>(buffer);
+ Atom val = ui->world().forge().alloc(atom->size,
+ atom->type,
+ LV2_ATOM_BODY_CONST(atom));
ui->signal_property_changed()(port->uri(),
uris.ingen_activity,
val,
@@ -97,7 +98,7 @@ lv2_ui_write(SuilController controller,
static uint32_t
lv2_ui_port_index(SuilController controller, const char* port_symbol)
{
- PluginUI* const ui = static_cast<PluginUI*>(controller);
+ auto* const ui = static_cast<PluginUI*>(controller);
const BlockModel::Ports& ports = ui->block()->ports();
for (uint32_t i = 0; i < ports.size(); ++i) {
@@ -114,7 +115,7 @@ lv2_ui_subscribe(SuilController controller,
uint32_t protocol,
const LV2_Feature* const* features)
{
- PluginUI* const ui = static_cast<PluginUI*>(controller);
+ auto* const ui = static_cast<PluginUI*>(controller);
SPtr<const PortModel> port = get_port(ui, port_index);
if (!port) {
return 1;
@@ -135,7 +136,7 @@ lv2_ui_unsubscribe(SuilController controller,
uint32_t protocol,
const LV2_Feature* const* features)
{
- PluginUI* const ui = static_cast<PluginUI*>(controller);
+ auto* const ui = static_cast<PluginUI*>(controller);
SPtr<const PortModel> port = get_port(ui, port_index);
if (!port) {
return 1;
diff --git a/src/gui/GraphBox.cpp b/src/gui/GraphBox.cpp
index 7856932d..e457dfd8 100644
--- a/src/gui/GraphBox.cpp
+++ b/src/gui/GraphBox.cpp
@@ -426,7 +426,7 @@ GraphBox::show_status(const ObjectModel* model)
show_port_status(port, port->value());
} else if ((block = dynamic_cast<const BlockModel*>(model))) {
- const PluginModel* plugin = dynamic_cast<const PluginModel*>(block->plugin());
+ const auto* plugin = dynamic_cast<const PluginModel*>(block->plugin());
if (plugin) {
msg << fmt(" (%1%)", plugin->human_name());
}
@@ -442,7 +442,7 @@ GraphBox::show_port_status(const PortModel* port, const Atom& value)
const BlockModel* parent = dynamic_cast<const BlockModel*>(port->parent().get());
if (parent) {
- const PluginModel* plugin = dynamic_cast<const PluginModel*>(parent->plugin());
+ const auto* plugin = dynamic_cast<const PluginModel*>(parent->plugin());
if (plugin) {
const std::string& human_name = plugin->port_human_name(port->index());
if (!human_name.empty()) {
@@ -681,8 +681,8 @@ GraphBox::event_export_image()
}
}
- Gtk::CheckButton* bg_but = new Gtk::CheckButton("Draw _Background", true);
- Gtk::Alignment* extra = new Gtk::Alignment(1.0, 0.5, 0.0, 0.0);
+ auto* bg_but = new Gtk::CheckButton("Draw _Background", true);
+ auto* extra = new Gtk::Alignment(1.0, 0.5, 0.0, 0.0);
bg_but->set_active(true);
extra->add(*Gtk::manage(bg_but));
extra->show_all();
diff --git a/src/gui/GraphCanvas.cpp b/src/gui/GraphCanvas.cpp
index bb60caa5..969c3849 100644
--- a/src/gui/GraphCanvas.cpp
+++ b/src/gui/GraphCanvas.cpp
@@ -265,12 +265,12 @@ show_module_human_names(GanvNode* node, void* data)
bool b = *static_cast<bool*>(data);
if (GANV_IS_MODULE(node)) {
Ganv::Module* module = Glib::wrap(GANV_MODULE(node));
- NodeModule* nmod = dynamic_cast<NodeModule*>(module);
+ auto* nmod = dynamic_cast<NodeModule*>(module);
if (nmod) {
nmod->show_human_names(b);
}
- GraphPortModule* pmod = dynamic_cast<GraphPortModule*>(module);
+ auto* pmod = dynamic_cast<GraphPortModule*>(module);
if (pmod) {
pmod->show_human_names(b);
}
@@ -292,7 +292,7 @@ ensure_port_labels(GanvNode* node, void* data)
if (GANV_IS_MODULE(node)) {
Ganv::Module* module = Glib::wrap(GANV_MODULE(node));
for (Ganv::Port* p : *module) {
- ingen::gui::Port* port = dynamic_cast<ingen::gui::Port*>(p);
+ auto* port = dynamic_cast<ingen::gui::Port*>(p);
if (port) {
port->ensure_label();
}
@@ -393,7 +393,7 @@ GraphCanvas::get_port_view(const SPtr<PortModel>& port)
// Port on this graph
if (module) {
- GraphPortModule* ppm = dynamic_cast<GraphPortModule*>(module);
+ auto* ppm = dynamic_cast<GraphPortModule*>(module);
return ppm
? *ppm->begin()
: dynamic_cast<Ganv::Port*>(module);
@@ -401,7 +401,7 @@ GraphCanvas::get_port_view(const SPtr<PortModel>& port)
module = dynamic_cast<NodeModule*>(_views[port->parent()]);
if (module) {
for (auto* p : *module) {
- gui::Port* pv = dynamic_cast<gui::Port*>(p);
+ auto* pv = dynamic_cast<gui::Port*>(p);
if (pv && pv->model() == port) {
return pv;
}
@@ -437,7 +437,7 @@ GraphCanvas::disconnection(const SPtr<const ArcModel>& arc)
if (tail && head) {
remove_edge_between(tail, head);
if (arc->head()->is_a(_app.uris().lv2_AudioPort)) {
- gui::Port* const h = dynamic_cast<gui::Port*>(head);
+ auto* const h = dynamic_cast<gui::Port*>(head);
if (h) {
h->activity(_app.forge().make(0.0f)); // Reset peaks
}
@@ -572,12 +572,12 @@ destroy_node(GanvNode* node, void* data)
App* app = static_cast<App*>(data);
Ganv::Module* module = Glib::wrap(GANV_MODULE(node));
- NodeModule* node_module = dynamic_cast<NodeModule*>(module);
+ auto* node_module = dynamic_cast<NodeModule*>(module);
if (node_module) {
app->interface()->del(node_module->block()->uri());
} else {
- GraphPortModule* port_module = dynamic_cast<GraphPortModule*>(module);
+ auto* port_module = dynamic_cast<GraphPortModule*>(module);
if (port_module &&
strcmp(port_module->port()->path().symbol(), "control") &&
strcmp(port_module->port()->path().symbol(), "notify")) {
@@ -612,18 +612,18 @@ GraphCanvas::destroy_selection()
static void
serialise_node(GanvNode* node, void* data)
{
- Serialiser* serialiser = static_cast<Serialiser*>(data);
+ auto* serialiser = static_cast<Serialiser*>(data);
if (!GANV_IS_MODULE(node)) {
return;
}
Ganv::Module* module = Glib::wrap(GANV_MODULE(node));
- NodeModule* node_module = dynamic_cast<NodeModule*>(module);
+ auto* node_module = dynamic_cast<NodeModule*>(module);
if (node_module) {
serialiser->serialise(node_module->block());
} else {
- GraphPortModule* port_module = dynamic_cast<GraphPortModule*>(module);
+ auto* port_module = dynamic_cast<GraphPortModule*>(module);
if (port_module) {
serialiser->serialise(port_module->port());
}
@@ -633,12 +633,12 @@ serialise_node(GanvNode* node, void* data)
static void
serialise_arc(GanvEdge* arc, void* data)
{
- Serialiser* serialiser = static_cast<Serialiser*>(data);
+ auto* serialiser = static_cast<Serialiser*>(data);
if (!GANV_IS_EDGE(arc)) {
return;
}
- gui::Arc* garc = dynamic_cast<gui::Arc*>(Glib::wrap(GANV_EDGE(arc)));
+ auto* garc = dynamic_cast<gui::Arc*>(Glib::wrap(GANV_EDGE(arc)));
if (garc) {
serialiser->serialise_arc(Sord::Node(), garc->model());
}
diff --git a/src/gui/GraphPortModule.cpp b/src/gui/GraphPortModule.cpp
index a80afe57..27babbfd 100644
--- a/src/gui/GraphPortModule.cpp
+++ b/src/gui/GraphPortModule.cpp
@@ -65,8 +65,8 @@ GraphPortModule::GraphPortModule(GraphCanvas& canvas,
GraphPortModule*
GraphPortModule::create(GraphCanvas& canvas, const SPtr<const PortModel>& model)
{
- GraphPortModule* ret = new GraphPortModule(canvas, model);
- Port* port = Port::create(canvas.app(), *ret, model, true);
+ auto* ret = new GraphPortModule(canvas, model);
+ Port* port = Port::create(canvas.app(), *ret, model, true);
ret->set_port(port);
if (model->is_numeric()) {
diff --git a/src/gui/GraphTreeWindow.cpp b/src/gui/GraphTreeWindow.cpp
index dd80c906..f3d77c76 100644
--- a/src/gui/GraphTreeWindow.cpp
+++ b/src/gui/GraphTreeWindow.cpp
@@ -50,7 +50,7 @@ GraphTreeWindow::GraphTreeWindow(BaseObjectType* cobject,
_graphs_treeview->append_column(*name_col);
_graphs_treeview->append_column(*enabled_col);
- Gtk::CellRendererToggle* enabled_renderer = dynamic_cast<Gtk::CellRendererToggle*>(
+ auto* enabled_renderer = dynamic_cast<Gtk::CellRendererToggle*>(
_graphs_treeview->get_column_cell_renderer(1));
enabled_renderer->property_activatable() = true;
diff --git a/src/server/BlockImpl.hpp b/src/server/BlockImpl.hpp
index 54fcd221..9bf3cac9 100644
--- a/src/server/BlockImpl.hpp
+++ b/src/server/BlockImpl.hpp
@@ -145,10 +145,12 @@ public:
virtual PortImpl* port_by_symbol(const char* symbol);
/** Blocks that are connected to this Block's inputs. */
- std::set<BlockImpl*>& providers() { return _providers; }
+ std::set<BlockImpl*>& providers() { return _providers; }
+ const std::set<BlockImpl*>& providers() const { return _providers; }
/** Blocks that are connected to this Block's outputs. */
- std::set<BlockImpl*>& dependants() { return _dependants; }
+ std::set<BlockImpl*>& dependants() { return _dependants; }
+ const std::set<BlockImpl*>& dependants() const { return _dependants; }
/** Flag block as polyphonic.
*
diff --git a/src/server/Buffer.cpp b/src/server/Buffer.cpp
index 509cbc01..5df57ce7 100644
--- a/src/server/Buffer.cpp
+++ b/src/server/Buffer.cpp
@@ -333,8 +333,10 @@ Buffer::append_event(int64_t frames, const LV2_Atom* body)
bool
Buffer::append_event_buffer(const Buffer* buf)
{
- auto* seq = reinterpret_cast<LV2_Atom_Sequence*>(get<LV2_Atom>());
- auto* bseq = reinterpret_cast<const LV2_Atom_Sequence*>(buf->get<LV2_Atom>());
+ auto* seq = reinterpret_cast<LV2_Atom_Sequence*>(get<LV2_Atom>());
+ const auto* bseq =
+ reinterpret_cast<const LV2_Atom_Sequence*>(buf->get<LV2_Atom>());
+
if (seq->atom.type == _factory.uris().atom_Chunk) {
clear(); // Chunk initialized with prepare_output_write(), clear
}
diff --git a/src/server/CompiledGraph.cpp b/src/server/CompiledGraph.cpp
index 9efed05f..b9841191 100644
--- a/src/server/CompiledGraph.cpp
+++ b/src/server/CompiledGraph.cpp
@@ -49,9 +49,9 @@ public:
};
static bool
-has_provider_with_many_dependants(BlockImpl* n)
+has_provider_with_many_dependants(const BlockImpl* n)
{
- for (BlockImpl* p : n->providers()) {
+ for (const auto* p : n->providers()) {
if (p->dependants().size() > 1) {
return true;
}
@@ -84,10 +84,10 @@ CompiledGraph::compile(Raul::Maid& maid, GraphImpl& graph)
}
static size_t
-num_unvisited_dependants(BlockImpl* block)
+num_unvisited_dependants(const BlockImpl* block)
{
size_t count = 0;
- for (BlockImpl* b : block->dependants()) {
+ for (const BlockImpl* b : block->dependants()) {
if (b->get_mark() == BlockImpl::Mark::UNVISITED) {
++count;
}
@@ -96,14 +96,14 @@ num_unvisited_dependants(BlockImpl* block)
}
static size_t
-parallel_depth(BlockImpl* block)
+parallel_depth(const BlockImpl* block)
{
if (has_provider_with_many_dependants(block)) {
return 2;
}
size_t min_provider_depth = std::numeric_limits<size_t>::max();
- for (auto p : block->providers()) {
+ for (const auto* p : block->providers()) {
min_provider_depth = std::min(min_provider_depth, parallel_depth(p));
}
@@ -133,12 +133,12 @@ CompiledGraph::compile_graph(GraphImpl* graph)
// Calculate maximum sequential depth to consume this phase
size_t depth = std::numeric_limits<size_t>::max();
- for (auto i : blocks) {
+ for (const auto* i : blocks) {
depth = std::min(depth, parallel_depth(i));
}
Task par(Task::Mode::PARALLEL);
- for (auto b : blocks) {
+ for (auto* b : blocks) {
assert(num_unvisited_dependants(b) == 0);
Task seq(Task::Mode::SEQUENTIAL);
compile_block(b, seq, depth, predecessors);
@@ -164,7 +164,7 @@ check_feedback(const BlockImpl* root, BlockImpl* provider)
throw FeedbackException(root);
}
- for (auto p : provider->providers()) {
+ for (auto* p : provider->providers()) {
const BlockImpl::Mark mark = p->get_mark();
switch (mark) {
case BlockImpl::Mark::UNVISITED:
@@ -227,12 +227,12 @@ CompiledGraph::compile_block(BlockImpl* n,
if (n->providers().size() < 2) {
// Single provider, prepend it to this sequential task
- for (auto p : n->providers()) {
+ for (auto* p : n->providers()) {
compile_provider(n, p, task, max_depth - 1, k);
}
} else if (has_provider_with_many_dependants(n)) {
// Stop recursion and enqueue providers for the next round
- for (auto p : n->providers()) {
+ for (auto* p : n->providers()) {
if (num_unvisited_dependants(p) == 0) {
k.insert(p);
}
@@ -241,7 +241,7 @@ CompiledGraph::compile_block(BlockImpl* n,
// Multiple providers with only this node as dependant,
// make a new parallel task to execute them
Task par(Task::Mode::PARALLEL);
- for (auto p : n->providers()) {
+ for (auto* p : n->providers()) {
compile_provider(n, p, par, max_depth - 1, k);
}
task.push_front(std::move(par));
diff --git a/src/server/JackDriver.cpp b/src/server/JackDriver.cpp
index 6209174f..d57b208a 100644
--- a/src/server/JackDriver.cpp
+++ b/src/server/JackDriver.cpp
@@ -225,7 +225,7 @@ JackDriver::add_port(RunContext& context, EnginePort* port)
DuplexPort* graph_port = port->graph_port();
if (graph_port->is_a(PortType::AUDIO) || graph_port->is_a(PortType::CV)) {
const SampleCount nframes = context.nframes();
- jack_port_t* jport = static_cast<jack_port_t*>(port->handle());
+ auto* jport = static_cast<jack_port_t*>(port->handle());
void* jbuf = jack_port_get_buffer(jport, nframes);
/* Jack fails to return a buffer if this is too soon after registering
@@ -301,7 +301,7 @@ JackDriver::port_property(const Raul::Path& path,
#ifdef HAVE_JACK_METADATA
EnginePort* eport = get_port(path);
if (eport) {
- const jack_port_t* const jport =
+ const auto* const jport =
static_cast<const jack_port_t*>(eport->handle());
port_property_internal(jport, uri, value);
@@ -357,7 +357,7 @@ JackDriver::pre_process_port(RunContext& context, EnginePort* port)
{
const URIs& uris = context.engine().world().uris();
const SampleCount nframes = context.nframes();
- jack_port_t* jack_port = static_cast<jack_port_t*>(port->handle());
+ auto* jack_port = static_cast<jack_port_t*>(port->handle());
DuplexPort* graph_port = port->graph_port();
Buffer* graph_buf = graph_port->buffer(0).get();
void* jack_buf = jack_port_get_buffer(jack_port, nframes);
@@ -392,7 +392,7 @@ JackDriver::post_process_port(RunContext& context, EnginePort* port) const
{
const URIs& uris = context.engine().world().uris();
const SampleCount nframes = context.nframes();
- jack_port_t* jack_port = static_cast<jack_port_t*>(port->handle());
+ auto* jack_port = static_cast<jack_port_t*>(port->handle());
DuplexPort* graph_port = port->graph_port();
void* jack_buf = port->buffer();
@@ -405,12 +405,12 @@ JackDriver::post_process_port(RunContext& context, EnginePort* port) const
if (graph_port->buffer_type() == uris.atom_Sequence) {
// Copy LV2 MIDI events to Jack MIDI buffer
- Buffer* const graph_buf = graph_port->buffer(0).get();
- LV2_Atom_Sequence* seq = graph_buf->get<LV2_Atom_Sequence>();
+ Buffer* const graph_buf = graph_port->buffer(0).get();
+ auto* seq = graph_buf->get<LV2_Atom_Sequence>();
jack_midi_clear_buffer(jack_buf);
LV2_ATOM_SEQUENCE_FOREACH(seq, ev) {
- const uint8_t* buf =
+ const auto* buf =
static_cast<const uint8_t*>(LV2_ATOM_BODY(&ev->body));
if (ev->body.type == this->_midi_event_type) {
@@ -474,7 +474,7 @@ JackDriver::append_time_events(RunContext& context,
}
// Append position to buffer at offset 0 (start of this cycle)
- LV2_Atom* lpos = static_cast<LV2_Atom*>(pos_buf);
+ auto* lpos = static_cast<LV2_Atom*>(pos_buf);
buffer.append_event(0,
lpos->size,
lpos->type,
diff --git a/src/server/LV2Options.hpp b/src/server/LV2Options.hpp
index 852a30a5..38082b8d 100644
--- a/src/server/LV2Options.hpp
+++ b/src/server/LV2Options.hpp
@@ -51,7 +51,7 @@ public:
{ LV2_OPTIONS_INSTANCE, 0, 0, 0, 0, nullptr }
};
- LV2_Feature* f = static_cast<LV2_Feature*>(malloc(sizeof(LV2_Feature)));
+ auto* f = static_cast<LV2_Feature*>(malloc(sizeof(LV2_Feature)));
f->URI = LV2_OPTIONS__options;
f->data = malloc(sizeof(options));
memcpy(f->data, options, sizeof(options));
diff --git a/src/server/PortAudioDriver.cpp b/src/server/PortAudioDriver.cpp
index de8c36cb..8d4a4c63 100644
--- a/src/server/PortAudioDriver.cpp
+++ b/src/server/PortAudioDriver.cpp
@@ -243,12 +243,12 @@ PortAudioDriver::pre_process_port(RunContext& context,
}
if (port->is_input()) {
- const float* const* const ins =
+ const auto* const* const ins =
static_cast<const float* const*>(inputs);
port->set_buffer(const_cast<float*>(ins[port->driver_index()]));
} else {
- float* const* const outs = static_cast<float* const*>(inputs);
+ auto* const* const outs = static_cast<float* const*>(inputs);
port->set_buffer(outs[port->driver_index()]);
memset(port->buffer(), 0, _block_length * sizeof(float));
diff --git a/src/server/UndoStack.hpp b/src/server/UndoStack.hpp
index 92f32131..26334aeb 100644
--- a/src/server/UndoStack.hpp
+++ b/src/server/UndoStack.hpp
@@ -71,7 +71,7 @@ public:
void push_event(const LV2_Atom* ev) {
const uint32_t size = lv2_atom_total_size(ev);
- LV2_Atom* copy = static_cast<LV2_Atom*>(malloc(size));
+ auto* copy = static_cast<LV2_Atom*>(malloc(size));
memcpy(copy, ev, size);
events.push_front(copy);
}
diff --git a/src/server/ingen_jack.cpp b/src/server/ingen_jack.cpp
index 8421ed94..62fef4e3 100644
--- a/src/server/ingen_jack.cpp
+++ b/src/server/ingen_jack.cpp
@@ -37,9 +37,9 @@ struct IngenJackModule : public ingen::Module {
return;
}
- server::JackDriver* driver = new server::JackDriver(*engine);
- const Atom& s = world.conf().option("jack-server");
- const std::string server_name = s.is_valid() ? s.ptr<char>() : "";
+ auto* driver = new server::JackDriver(*engine);
+ const Atom& s = world.conf().option("jack-server");
+ const std::string server_name = s.is_valid() ? s.ptr<char>() : "";
driver->attach(server_name,
world.conf().option("jack-name").ptr<char>(),
diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp
index 7f6a430e..2bf44762 100644
--- a/src/server/ingen_lv2.cpp
+++ b/src/server/ingen_lv2.cpp
@@ -153,8 +153,7 @@ public:
static_cast<LV2_Atom*>(lv2_buf)));
if (graph_port->symbol() == "control") { // TODO: Safe to use index?
- LV2_Atom_Sequence* seq =
- reinterpret_cast<LV2_Atom_Sequence*>(lv2_buf);
+ auto* seq = reinterpret_cast<LV2_Atom_Sequence*>(lv2_buf);
bool enqueued = false;
LV2_ATOM_SEQUENCE_FOREACH(seq, ev)
@@ -267,9 +266,8 @@ public:
}
void append_time_events(RunContext& context, Buffer& buffer) override {
- const URIs& uris = _engine.world().uris();
- LV2_Atom_Sequence* seq =
- static_cast<LV2_Atom_Sequence*>(_ports[0]->buffer());
+ const URIs& uris = _engine.world().uris();
+ auto* seq = static_cast<LV2_Atom_Sequence*>(_ports[0]->buffer());
LV2_ATOM_SEQUENCE_FOREACH(seq, ev) {
if (ev->body.type == uris.atom_Object) {
@@ -347,9 +345,7 @@ public:
return;
}
- LV2_Atom_Sequence* seq =
- static_cast<LV2_Atom_Sequence*>(_ports[1]->buffer());
-
+ auto* seq = static_cast<LV2_Atom_Sequence*>(_ports[1]->buffer());
if (!seq) {
_engine.log().rt_error("Notify output not connected\n");
return;
@@ -373,8 +369,9 @@ public:
break; // Output port buffer full, resume next time
}
- LV2_Atom_Event* ev = reinterpret_cast<LV2_Atom_Event*>(
- reinterpret_cast<uint8_t*>(seq) + lv2_atom_total_size(&seq->atom));
+ 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->body = atom;
@@ -547,7 +544,7 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
return nullptr;
}
- IngenPlugin* plugin = new IngenPlugin();
+ auto* plugin = new IngenPlugin();
plugin->map = map;
plugin->world = UPtr<ingen::World>(new ingen::World(map, unmap, log));
plugin->world->load_configuration(plugin->argc, plugin->argv);
@@ -593,7 +590,7 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
server::ThreadManager::set_flag(server::THREAD_PRE_PROCESS);
server::ThreadManager::single_threaded = true;
- LV2Driver* driver = new LV2Driver(*engine.get(), block_length, seq_size, rate);
+ auto* driver = new LV2Driver(*engine.get(), block_length, seq_size, rate);
engine->set_driver(SPtr<ingen::server::Driver>(driver));
engine->activate();
@@ -634,7 +631,7 @@ ingen_connect_port(LV2_Handle instance, uint32_t port, void* data)
{
using namespace ingen::server;
- IngenPlugin* me = static_cast<IngenPlugin*>(instance);
+ auto* me = static_cast<IngenPlugin*>(instance);
server::Engine* engine = static_cast<server::Engine*>(me->world->engine().get());
const SPtr<LV2Driver>& driver = static_ptr_cast<LV2Driver>(engine->driver());
if (port < driver->ports().size()) {
@@ -647,7 +644,7 @@ ingen_connect_port(LV2_Handle instance, uint32_t port, void* data)
static void
ingen_activate(LV2_Handle instance)
{
- IngenPlugin* me = static_cast<IngenPlugin*>(instance);
+ auto* me = static_cast<IngenPlugin*>(instance);
SPtr<server::Engine> engine = static_ptr_cast<server::Engine>(me->world->engine());
const SPtr<LV2Driver>& driver = static_ptr_cast<LV2Driver>(engine->driver());
engine->activate();
@@ -657,7 +654,7 @@ ingen_activate(LV2_Handle instance)
static void
ingen_run(LV2_Handle instance, uint32_t sample_count)
{
- IngenPlugin* me = static_cast<IngenPlugin*>(instance);
+ auto* me = static_cast<IngenPlugin*>(instance);
SPtr<server::Engine> engine = static_ptr_cast<server::Engine>(me->world->engine());
const SPtr<LV2Driver>& driver = static_ptr_cast<LV2Driver>(engine->driver());
@@ -670,7 +667,7 @@ ingen_run(LV2_Handle instance, uint32_t sample_count)
static void
ingen_deactivate(LV2_Handle instance)
{
- IngenPlugin* me = static_cast<IngenPlugin*>(instance);
+ auto* me = static_cast<IngenPlugin*>(instance);
me->world->engine()->deactivate();
if (me->main) {
me->main->join();
@@ -681,7 +678,7 @@ ingen_deactivate(LV2_Handle instance)
static void
ingen_cleanup(LV2_Handle instance)
{
- IngenPlugin* me = static_cast<IngenPlugin*>(instance);
+ auto* me = static_cast<IngenPlugin*>(instance);
me->world->set_engine(SPtr<ingen::server::Engine>());
me->world->set_interface(SPtr<ingen::Interface>());
if (me->main) {
@@ -714,7 +711,7 @@ ingen_save(LV2_Handle instance,
uint32_t flags,
const LV2_Feature* const* features)
{
- IngenPlugin* plugin = static_cast<IngenPlugin*>(instance);
+ auto* plugin = static_cast<IngenPlugin*>(instance);
LV2_State_Map_Path* map_path = nullptr;
LV2_State_Make_Path* make_path = nullptr;
@@ -761,7 +758,7 @@ ingen_restore(LV2_Handle instance,
uint32_t flags,
const LV2_Feature* const* features)
{
- IngenPlugin* plugin = static_cast<IngenPlugin*>(instance);
+ auto* plugin = static_cast<IngenPlugin*>(instance);
LV2_State_Map_Path* map_path = nullptr;
get_state_features(features, &map_path, nullptr);
@@ -876,7 +873,7 @@ lv2_lib_descriptor(const char* bundle_path,
Lib* lib = new Lib(bundle_path);
// FIXME: memory leak. I think the LV2_Lib_Descriptor API is botched :(
- LV2_Lib_Descriptor* desc = static_cast<LV2_Lib_Descriptor*>(malloc(desc_size));
+ auto* desc = static_cast<LV2_Lib_Descriptor*>(malloc(desc_size));
desc->handle = lib;
desc->size = desc_size;
desc->cleanup = lib_cleanup;
diff --git a/src/server/ingen_portaudio.cpp b/src/server/ingen_portaudio.cpp
index 09229f91..81f6e65c 100644
--- a/src/server/ingen_portaudio.cpp
+++ b/src/server/ingen_portaudio.cpp
@@ -36,7 +36,7 @@ struct IngenPortAudioModule : public ingen::Module {
return;
}
- server::PortAudioDriver* driver = new server::PortAudioDriver(*engine);
+ auto* driver = new server::PortAudioDriver(*engine);
driver->attach();
engine->set_driver(SPtr<server::Driver>(driver));
}
diff --git a/src/server/internals/Controller.cpp b/src/server/internals/Controller.cpp
index a4f7ef43..4c253cc1 100644
--- a/src/server/internals/Controller.cpp
+++ b/src/server/internals/Controller.cpp
@@ -110,11 +110,12 @@ ControllerNode::ControllerNode(InternalPlugin* plugin,
void
ControllerNode::run(RunContext& context)
{
- const BufferRef midi_in = _midi_in_port->buffer(0);
- LV2_Atom_Sequence* seq = midi_in->get<LV2_Atom_Sequence>();
- const BufferRef midi_out = _midi_out_port->buffer(0);
+ const BufferRef midi_in = _midi_in_port->buffer(0);
+ auto* seq = midi_in->get<LV2_Atom_Sequence>();
+ const BufferRef midi_out = _midi_out_port->buffer(0);
+
LV2_ATOM_SEQUENCE_FOREACH(seq, ev) {
- const uint8_t* buf = static_cast<const uint8_t*>(LV2_ATOM_BODY_CONST(&ev->body));
+ const auto* buf = static_cast<const uint8_t*>(LV2_ATOM_BODY_CONST(&ev->body));
if (ev->body.type == _midi_in_port->bufs().uris().midi_MidiEvent &&
ev->body.size >= 3 &&
lv2_midi_message_type(buf) == LV2_MIDI_MSG_CONTROLLER) {
diff --git a/src/server/internals/Note.cpp b/src/server/internals/Note.cpp
index 0d375eac..b2a22c14 100644
--- a/src/server/internals/Note.cpp
+++ b/src/server/internals/Note.cpp
@@ -164,10 +164,11 @@ NoteNode::apply_poly(RunContext& context, uint32_t poly)
void
NoteNode::run(RunContext& context)
{
- Buffer* const midi_in = _midi_in_port->buffer(0).get();
- LV2_Atom_Sequence* seq = midi_in->get<LV2_Atom_Sequence>();
+ Buffer* const midi_in = _midi_in_port->buffer(0).get();
+ auto* seq = midi_in->get<LV2_Atom_Sequence>();
+
LV2_ATOM_SEQUENCE_FOREACH(seq, ev) {
- const uint8_t* buf =
+ const auto* buf =
static_cast<const uint8_t*>(LV2_ATOM_BODY_CONST(&ev->body));
const FrameTime time =
diff --git a/src/server/internals/Time.cpp b/src/server/internals/Time.cpp
index 3b6f12ba..a771b9a9 100644
--- a/src/server/internals/Time.cpp
+++ b/src/server/internals/Time.cpp
@@ -61,8 +61,8 @@ TimeNode::TimeNode(InternalPlugin* plugin,
void
TimeNode::run(RunContext& context)
{
- BufferRef buf = _notify_port->buffer(0);
- LV2_Atom_Sequence* seq = buf->get<LV2_Atom_Sequence>();
+ BufferRef buf = _notify_port->buffer(0);
+ auto* seq = buf->get<LV2_Atom_Sequence>();
// Initialise output to the empty sequence
seq->atom.type = _notify_port->bufs().uris().atom_Sequence;
diff --git a/src/server/internals/Trigger.cpp b/src/server/internals/Trigger.cpp
index f9c21438..0fe5715c 100644
--- a/src/server/internals/Trigger.cpp
+++ b/src/server/internals/Trigger.cpp
@@ -106,17 +106,18 @@ TriggerNode::TriggerNode(InternalPlugin* plugin,
void
TriggerNode::run(RunContext& context)
{
- const BufferRef midi_in = _midi_in_port->buffer(0);
- LV2_Atom_Sequence* const seq = midi_in->get<LV2_Atom_Sequence>();
- const BufferRef midi_out = _midi_out_port->buffer(0);
+ const BufferRef midi_in = _midi_in_port->buffer(0);
+ auto* const seq = midi_in->get<LV2_Atom_Sequence>();
+ const BufferRef midi_out = _midi_out_port->buffer(0);
// Initialise output to the empty sequence
midi_out->prepare_write(context);
LV2_ATOM_SEQUENCE_FOREACH(seq, ev) {
- const int64_t t = ev->time.frames;
- const uint8_t* buf = static_cast<const uint8_t*>(LV2_ATOM_BODY_CONST(&ev->body));
- bool emit = false;
+ const int64_t t = ev->time.frames;
+ const auto* buf =
+ static_cast<const uint8_t*>(LV2_ATOM_BODY_CONST(&ev->body));
+ bool emit = false;
if (ev->body.type == _midi_in_port->bufs().uris().midi_MidiEvent &&
ev->body.size >= 3) {
const FrameTime time = context.start() + t;
diff --git a/src/server/mix.cpp b/src/server/mix.cpp
index e6f999f4..75d31931 100644
--- a/src/server/mix.cpp
+++ b/src/server/mix.cpp
@@ -27,7 +27,7 @@ namespace server {
static inline bool
is_end(const Buffer* buf, const LV2_Atom_Event* ev)
{
- const LV2_Atom* atom = buf->get<const LV2_Atom>();
+ const auto* atom = buf->get<const LV2_Atom>();
return lv2_atom_sequence_is_end(
static_cast<const LV2_Atom_Sequence_Body*>(LV2_ATOM_BODY_CONST(atom)),
atom->size,
@@ -74,7 +74,7 @@ mix(const RunContext& context,
for (uint32_t i = 0; i < num_srcs; ++i) {
iters[i] = nullptr;
if (srcs[i]->is_sequence()) {
- const LV2_Atom_Sequence* seq = srcs[i]->get<const LV2_Atom_Sequence>();
+ const auto* seq = srcs[i]->get<const LV2_Atom_Sequence>();
iters[i] = lv2_atom_sequence_begin(&seq->body);
if (is_end(srcs[i], iters[i])) {
iters[i] = nullptr;