diff options
Diffstat (limited to 'src/server')
27 files changed, 178 insertions, 88 deletions
diff --git a/src/server/.clang-tidy b/src/server/.clang-tidy index d0448c00..fd06dfb6 100644 --- a/src/server/.clang-tidy +++ b/src/server/.clang-tidy @@ -1,7 +1,6 @@ Checks: > *, -*-avoid-c-arrays, - -*-else-after-return, -*-magic-numbers, -*-named-parameter, -*-narrowing-conversions, diff --git a/src/server/BlockImpl.cpp b/src/server/BlockImpl.cpp index a89df669..ee6b5786 100644 --- a/src/server/BlockImpl.cpp +++ b/src/server/BlockImpl.cpp @@ -207,7 +207,9 @@ BlockImpl::bypass(RunContext& ctx) PortImpl* out = nth_port_by_type(i, false, t); if (!out) { break; // Finished writing all outputs - } else if (in) { + } + + if (in) { // Copy corresponding input to output for (uint32_t v = 0; v < _polyphony; ++v) { out->buffer(v)->copy(ctx, in->buffer(v).get()); diff --git a/src/server/Buffer.cpp b/src/server/Buffer.cpp index 18483d2d..199d858b 100644 --- a/src/server/Buffer.cpp +++ b/src/server/Buffer.cpp @@ -147,7 +147,9 @@ Buffer::copy(const RunContext& ctx, const Buffer* src) { if (!_buf) { return; - } else if (_type == src->type()) { + } + + if (_type == src->type()) { const uint32_t src_size = src->size(); if (src_size <= _capacity) { memcpy(_buf, src->_buf, src_size); @@ -416,7 +418,9 @@ Buffer::update_value_buffer(SampleCount offset) LV2_ATOM_SEQUENCE_FOREACH(seq, ev) { if (ev->time.frames > offset) { break; - } else if (ev->body.type == _value_type) { + } + + if (ev->body.type == _value_type) { latest = ev; } } diff --git a/src/server/Buffer.hpp b/src/server/Buffer.hpp index b1d8fb4d..d10aeb5c 100644 --- a/src/server/Buffer.hpp +++ b/src/server/Buffer.hpp @@ -95,9 +95,12 @@ public: if (is_control()) { return static_cast<const Sample*>( LV2_ATOM_BODY_CONST(get<LV2_Atom_Float>())); - } else if (is_audio()) { + } + + if (is_audio()) { return static_cast<const Sample*>(_buf); } + return nullptr; } @@ -105,9 +108,12 @@ public: inline Sample* samples() { if (is_control()) { return static_cast<Sample*>(LV2_ATOM_BODY(get<LV2_Atom_Float>())); - } else if (is_audio()) { + } + + if (is_audio()) { return static_cast<Sample*>(_buf); } + return nullptr; } @@ -115,9 +121,12 @@ public: inline Sample value_at(SampleCount offset) const { if (is_audio() || is_control()) { return samples()[offset]; - } else if (_value_buffer) { + } + + if (_value_buffer) { return reinterpret_cast<const LV2_Atom_Float*>(value())->body; } + return 0.0f; } diff --git a/src/server/BufferFactory.cpp b/src/server/BufferFactory.cpp index 97a9b933..7c1e0b17 100644 --- a/src/server/BufferFactory.cpp +++ b/src/server/BufferFactory.cpp @@ -100,19 +100,25 @@ BufferFactory::default_size(LV2_URID type) const { if (type == _uris.atom_Float) { return sizeof(LV2_Atom_Float); - } else if (type == _uris.atom_Sound) { + } + + if (type == _uris.atom_Sound) { return audio_buffer_size(_engine.block_length()); - } else if (type == _uris.atom_URID) { + } + + if (type == _uris.atom_URID) { return sizeof(LV2_Atom_URID); - } else if (type == _uris.atom_Sequence) { + } + + if (type == _uris.atom_Sequence) { if (_seq_size == 0) { return _engine.sequence_size(); - } else { - return _seq_size; } - } else { - return 0; + + return _seq_size; } + + return 0; } Buffer* diff --git a/src/server/BufferFactory.hpp b/src/server/BufferFactory.hpp index 5f649e4a..58c5bba2 100644 --- a/src/server/BufferFactory.hpp +++ b/src/server/BufferFactory.hpp @@ -85,13 +85,17 @@ private: inline std::atomic<Buffer*>& free_list(LV2_URID type) { if (type == _uris.atom_Float) { return _free_control; - } else if (type == _uris.atom_Sound) { + } + + if (type == _uris.atom_Sound) { return _free_audio; - } else if (type == _uris.atom_Sequence) { + } + + if (type == _uris.atom_Sequence) { return _free_sequence; - } else { - return _free_object; } + + return _free_object; } static void free_list(Buffer* head); diff --git a/src/server/ControlBindings.cpp b/src/server/ControlBindings.cpp index 60684440..f68c28d8 100644 --- a/src/server/ControlBindings.cpp +++ b/src/server/ControlBindings.cpp @@ -155,9 +155,9 @@ ControlBindings::set_port_binding(RunContext&, binding->port = port; _bindings->insert(*binding); return true; - } else { - return false; } + + return false; } void diff --git a/src/server/DuplexPort.cpp b/src/server/DuplexPort.cpp index ce516b46..0c4c83e6 100644 --- a/src/server/DuplexPort.cpp +++ b/src/server/DuplexPort.cpp @@ -154,9 +154,12 @@ DuplexPort::get_buffers(BufferFactory& bufs, { if (!_is_driver_port && is_output()) { return InputPort::get_buffers(bufs, get, voices, poly, num_in_arcs); - } else if (!_is_driver_port && is_input()) { + } + + if (!_is_driver_port && is_input()) { return PortImpl::get_buffers(bufs, get, voices, poly, num_in_arcs); } + return false; } @@ -165,9 +168,12 @@ DuplexPort::setup_buffers(RunContext& ctx, BufferFactory& bufs, uint32_t poly) { if (!_is_driver_port && is_output()) { return InputPort::setup_buffers(ctx, bufs, poly); - } else if (!_is_driver_port && is_input()) { + } + + if (!_is_driver_port && is_input()) { return PortImpl::setup_buffers(ctx, bufs, poly); } + return false; } diff --git a/src/server/GraphImpl.cpp b/src/server/GraphImpl.cpp index 7f566041..86a70495 100644 --- a/src/server/GraphImpl.cpp +++ b/src/server/GraphImpl.cpp @@ -297,9 +297,9 @@ GraphImpl::remove_arc(const PortImpl* tail, const PortImpl* dst_port) auto arc = std::dynamic_pointer_cast<ArcImpl>(i->second); _arcs.erase(i); return arc; - } else { - return nullptr; } + + return nullptr; } bool diff --git a/src/server/InternalPlugin.cpp b/src/server/InternalPlugin.cpp index 0355ff1e..6c188c5e 100644 --- a/src/server/InternalPlugin.cpp +++ b/src/server/InternalPlugin.cpp @@ -51,21 +51,29 @@ InternalPlugin::instantiate(BufferFactory& bufs, if (uri() == NS_INTERNALS "BlockDelay") { return new internals::BlockDelayNode( this, bufs, symbol, polyphonic, parent, srate); - } else if (uri() == NS_INTERNALS "Controller") { + } + + if (uri() == NS_INTERNALS "Controller") { return new internals::ControllerNode( this, bufs, symbol, polyphonic, parent, srate); - } else if (uri() == NS_INTERNALS "Note") { + } + + if (uri() == NS_INTERNALS "Note") { return new internals::NoteNode( this, bufs, symbol, polyphonic, parent, srate); - } else if (uri() == NS_INTERNALS "Time") { + } + + if (uri() == NS_INTERNALS "Time") { return new internals::TimeNode( this, bufs, symbol, polyphonic, parent, srate); - } else if (uri() == NS_INTERNALS "Trigger") { + } + + if (uri() == NS_INTERNALS "Trigger") { return new internals::TriggerNode( this, bufs, symbol, polyphonic, parent, srate); - } else { - return nullptr; } + + return nullptr; } } // namespace server diff --git a/src/server/JackDriver.cpp b/src/server/JackDriver.cpp index 472379f9..2a9fb321 100644 --- a/src/server/JackDriver.cpp +++ b/src/server/JackDriver.cpp @@ -153,10 +153,10 @@ JackDriver::activate() if (jack_activate(_client)) { _engine.log().error("Could not activate Jack client, aborting\n"); return false; - } else { - _engine.log().info("Activated Jack client `%1%'\n", - world.conf().option("jack-name").ptr<char>()); } + + _engine.log().info("Activated Jack client `%1%'\n", + world.conf().option("jack-name").ptr<char>()); return true; } diff --git a/src/server/LV2Block.cpp b/src/server/LV2Block.cpp index a0e67eb9..73eb85c9 100644 --- a/src/server/LV2Block.cpp +++ b/src/server/LV2Block.cpp @@ -496,7 +496,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; } diff --git a/src/server/LV2Plugin.cpp b/src/server/LV2Plugin.cpp index 7a43ba67..121792c7 100644 --- a/src/server/LV2Plugin.cpp +++ b/src/server/LV2Plugin.cpp @@ -79,9 +79,9 @@ LV2Plugin::symbol() const if ( (symbol[0] >= 'a' && symbol[0] <= 'z') || (symbol[0] >= 'A' && symbol[0] <= 'Z') ) { return raul::Symbol::symbolify(symbol); - } else { - working = working.substr(0, last_slash); } + + working = working.substr(0, last_slash); } return raul::Symbol("lv2_symbol"); @@ -101,9 +101,9 @@ LV2Plugin::instantiate(BufferFactory& bufs, if (!b->instantiate(bufs, state)) { delete b; return nullptr; - } else { - return b; } + + return b; } void diff --git a/src/server/PortAudioDriver.cpp b/src/server/PortAudioDriver.cpp index 68acf552..c6bfcc65 100644 --- a/src/server/PortAudioDriver.cpp +++ b/src/server/PortAudioDriver.cpp @@ -70,7 +70,9 @@ PortAudioDriver::attach() _outputParameters.device = Pa_GetDefaultOutputDevice(); if (_inputParameters.device == paNoDevice) { return pa_error("No default input device", paDeviceUnavailable); - } else if (_outputParameters.device == paNoDevice) { + } + + if (_outputParameters.device == paNoDevice) { return pa_error("No default output device", paDeviceUnavailable); } diff --git a/src/server/PortImpl.cpp b/src/server/PortImpl.cpp index 913c6176..23eb16ee 100644 --- a/src/server/PortImpl.cpp +++ b/src/server/PortImpl.cpp @@ -330,9 +330,13 @@ PortImpl::prepare_poly(BufferFactory& bufs, uint32_t poly) if (_is_driver_port || _parent->is_main() || (_type == PortType::ATOM && !_value.is_valid())) { return false; - } else if (_poly == poly) { + } + + if (_poly == poly) { return true; - } else if (_prepared_voices && _prepared_voices->size() != poly) { + } + + if (_prepared_voices && _prepared_voices->size() != poly) { _prepared_voices.reset(); } @@ -353,7 +357,9 @@ PortImpl::apply_poly(RunContext& ctx, uint32_t poly) if (_parent->is_main() || (_type == PortType::ATOM && !_value.is_valid())) { return false; - } else if (!_prepared_voices) { + } + + if (!_prepared_voices) { return true; } diff --git a/src/server/PreProcessContext.hpp b/src/server/PreProcessContext.hpp index fa7d07c5..72dc64c3 100644 --- a/src/server/PreProcessContext.hpp +++ b/src/server/PreProcessContext.hpp @@ -50,12 +50,14 @@ public: bool must_compile(GraphImpl& graph) { if (!graph.enabled()) { return false; - } else if (_in_bundle) { + } + + if (_in_bundle) { _dirty_graphs.insert(&graph); return false; - } else { - return true; } + + return true; } /** Compile graph and return the result if necessary. diff --git a/src/server/PreProcessor.cpp b/src/server/PreProcessor.cpp index 6922d232..beba06e2 100644 --- a/src/server/PreProcessor.cpp +++ b/src/server/PreProcessor.cpp @@ -110,7 +110,9 @@ PreProcessor::process(RunContext& ctx, PostProcessor& dest, size_t limit) if (_block_state == BlockState::BLOCKED) { break; // Waiting for PRE_UNBLOCKED - } else if (ev->time() < ctx.start()) { + } + + if (ev->time() < ctx.start()) { ev->set_time(ctx.start()); // Too late, nudge to context start } else if (_block_state != BlockState::PROCESSING && ev->time() >= ctx.end()) { diff --git a/src/server/SocketListener.cpp b/src/server/SocketListener.cpp index 445374c4..640d575f 100644 --- a/src/server/SocketListener.cpp +++ b/src/server/SocketListener.cpp @@ -165,10 +165,14 @@ ingen_listen(Engine* engine, raul::Socket* unix_sock, raul::Socket* net_sock) if (ret == -1) { world.log().error("Poll error: %1%\n", strerror(errno)); break; - } else if (ret == 0) { + } + + if (ret == 0) { world.log().warn("Poll returned with no data\n"); continue; - } else if ((pfds[0].revents & POLLHUP) || pfds[1].revents & POLLHUP) { + } + + if ((pfds[0].revents & POLLHUP) || pfds[1].revents & POLLHUP) { break; } diff --git a/src/server/UndoStack.cpp b/src/server/UndoStack.cpp index 3dd4b3b0..858cb11b 100644 --- a/src/server/UndoStack.cpp +++ b/src/server/UndoStack.cpp @@ -87,18 +87,18 @@ UndoStack::ignore_later_event(const LV2_Atom* first, int UndoStack::finish_entry() { - if (--_depth > 0) { - return _depth; - } else if (_stack.back().events.empty()) { - // Disregard empty entry - _stack.pop_back(); - } else if (_stack.size() > 1 && _stack.back().events.size() == 1) { - // This entry and the previous one have one event, attempt to merge - auto i = _stack.rbegin(); - ++i; - if (i->events.size() == 1) { - if (ignore_later_event(i->events[0], _stack.back().events[0])) { - _stack.pop_back(); + if (--_depth == 0) { + if (_stack.back().events.empty()) { + // Disregard empty entry + _stack.pop_back(); + } else if (_stack.size() > 1 && _stack.back().events.size() == 1) { + // This entry and the previous one have one event, attempt to merge + auto i = _stack.rbegin(); + ++i; + if (i->events.size() == 1) { + if (ignore_later_event(i->events[0], _stack.back().events[0])) { + _stack.pop_back(); + } } } } diff --git a/src/server/events/Copy.cpp b/src/server/events/Copy.cpp index 7f92842e..beb5224c 100644 --- a/src/server/events/Copy.cpp +++ b/src/server/events/Copy.cpp @@ -79,19 +79,23 @@ Copy::pre_process(PreProcessContext& ctx) if (uri_is_path(_msg.new_uri)) { // Copy to path within the engine return engine_to_engine(ctx); - } else if (_msg.new_uri.scheme() == "file") { + } + + if (_msg.new_uri.scheme() == "file") { // Copy to filesystem path (i.e. save) return engine_to_filesystem(ctx); - } else { - return Event::pre_process_done(Status::BAD_REQUEST); } - } else if (_msg.old_uri.scheme() == "file") { + + return Event::pre_process_done(Status::BAD_REQUEST); + } + + if (_msg.old_uri.scheme() == "file") { if (uri_is_path(_msg.new_uri)) { return filesystem_to_engine(ctx); - } else { - // Ingen is not your file manager - return Event::pre_process_done(Status::BAD_REQUEST); } + + // Ingen is not your file manager + return Event::pre_process_done(Status::BAD_REQUEST); } return Event::pre_process_done(Status::BAD_URI); diff --git a/src/server/events/CreateBlock.cpp b/src/server/events/CreateBlock.cpp index 6d0dbe3e..23a0d35e 100644 --- a/src/server/events/CreateBlock.cpp +++ b/src/server/events/CreateBlock.cpp @@ -77,9 +77,13 @@ CreateBlock::pre_process(PreProcessContext& ctx) // Check sanity of target path if (_path.is_root()) { return Event::pre_process_done(Status::BAD_URI, _path); - } else if (store->get(_path)) { + } + + if (store->get(_path)) { return Event::pre_process_done(Status::EXISTS, _path); - } else if (!(_graph = dynamic_cast<GraphImpl*>(store->get(_path.parent())))) { + } + + if (!(_graph = dynamic_cast<GraphImpl*>(store->get(_path.parent())))) { return Event::pre_process_done(Status::PARENT_NOT_FOUND, _path.parent()); } @@ -115,8 +119,11 @@ CreateBlock::pre_process(PreProcessContext& ctx) store->get(uri_to_path(prototype))); if (!ancestor) { return Event::pre_process_done(Status::PROTOTYPE_NOT_FOUND, prototype); - } else if (!(_block = ancestor->duplicate( - _engine, raul::Symbol(_path.symbol()), _graph))) { + } + + if (!(_block = ancestor->duplicate(_engine, + raul::Symbol(_path.symbol()), + _graph))) { return Event::pre_process_done(Status::CREATION_FAILED, _path); } diff --git a/src/server/events/CreateGraph.cpp b/src/server/events/CreateGraph.cpp index 367bedfe..dc7c0d7d 100644 --- a/src/server/events/CreateGraph.cpp +++ b/src/server/events/CreateGraph.cpp @@ -167,8 +167,10 @@ CreateGraph::pre_process(PreProcessContext& ctx) if (!ancestor) { return Event::pre_process_done(Status::PROTOTYPE_NOT_FOUND, prototype); - } else if (!(_graph = dynamic_cast<GraphImpl*>( - ancestor->duplicate(_engine, symbol, _parent)))) { + } + + if (!(_graph = dynamic_cast<GraphImpl*>( + ancestor->duplicate(_engine, symbol, _parent)))) { return Event::pre_process_done(Status::CREATION_FAILED, _path); } } else { diff --git a/src/server/events/CreatePort.cpp b/src/server/events/CreatePort.cpp index 5ea9db33..6eee6ed7 100644 --- a/src/server/events/CreatePort.cpp +++ b/src/server/events/CreatePort.cpp @@ -94,9 +94,13 @@ CreatePort::pre_process(PreProcessContext&) { if (_port_type == PortType::UNKNOWN || !_flow) { return Event::pre_process_done(Status::UNKNOWN_TYPE, _path); - } else if (_path.is_root()) { + } + + if (_path.is_root()) { return Event::pre_process_done(Status::BAD_URI, _path); - } else if (_engine.store()->get(_path)) { + } + + if (_engine.store()->get(_path)) { return Event::pre_process_done(Status::EXISTS, _path); } @@ -104,10 +108,14 @@ CreatePort::pre_process(PreProcessContext&) Node* const parent = _engine.store()->get(parent_path); if (!parent) { return Event::pre_process_done(Status::PARENT_NOT_FOUND, parent_path); - } else if (!(_graph = dynamic_cast<GraphImpl*>(parent))) { + } + + if (!(_graph = dynamic_cast<GraphImpl*>(parent))) { return Event::pre_process_done(Status::INVALID_PARENT, parent_path); - } else if (!_graph->parent() && _engine.activated() && - !_engine.driver()->dynamic_ports()) { + } + + if (!_graph->parent() && _engine.activated() && + !_engine.driver()->dynamic_ports()) { return Event::pre_process_done(Status::CREATION_FAILED, _path); } diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp index 2c6a50c8..88826a23 100644 --- a/src/server/events/Delta.cpp +++ b/src/server/events/Delta.cpp @@ -155,12 +155,15 @@ get_file_node(LilvWorld* lworld, const URIs& uris, const Atom& value) { if (value.type() == uris.atom_Path) { return lilv_new_file_uri(lworld, nullptr, value.ptr<char>()); - } else if (uris.forge.is_uri(value)) { + } + + if (uris.forge.is_uri(value)) { const std::string str = uris.forge.str(value, false); if (str.substr(0, 5) == "file:") { return lilv_new_uri(lworld, value.ptr<char>()); } } + return nullptr; } @@ -205,9 +208,9 @@ Delta::pre_process(PreProcessContext& ctx) if ((_preset = block->save_preset(_subject, _properties))) { return Event::pre_process_done(Status::SUCCESS); - } else { - return Event::pre_process_done(Status::FAILURE); } + + return Event::pre_process_done(Status::FAILURE); } std::lock_guard<Store::Mutex> lock(_engine.store()->mutex()); diff --git a/src/server/events/Disconnect.cpp b/src/server/events/Disconnect.cpp index b600df4f..c20ed9a8 100644 --- a/src/server/events/Disconnect.cpp +++ b/src/server/events/Disconnect.cpp @@ -158,7 +158,9 @@ Disconnect::pre_process(PreProcessContext& ctx) if (!_graph) { return Event::pre_process_done(Status::INTERNAL_ERROR, _msg.head); - } else if (!_graph->has_arc(tail, head)) { + } + + if (!_graph->has_arc(tail, head)) { return Event::pre_process_done(Status::NOT_FOUND, _msg.head); } diff --git a/src/server/events/Get.cpp b/src/server/events/Get.cpp index ff801c06..bd59e19d 100644 --- a/src/server/events/Get.cpp +++ b/src/server/events/Get.cpp @@ -58,9 +58,13 @@ Get::pre_process(PreProcessContext&) if (uri == "ingen:/plugins") { _plugins = _engine.block_factory()->plugins(); return Event::pre_process_done(Status::SUCCESS); - } else if (uri == "ingen:/engine") { + } + + if (uri == "ingen:/engine") { return Event::pre_process_done(Status::SUCCESS); - } else if (uri_is_path(uri)) { + } + + if (uri_is_path(uri)) { if ((_object = _engine.store()->get(uri_to_path(uri)))) { const BlockImpl* block = nullptr; const GraphImpl* graph = nullptr; @@ -77,12 +81,14 @@ Get::pre_process(PreProcessContext&) return Event::pre_process_done(Status::SUCCESS); } return Event::pre_process_done(Status::NOT_FOUND, uri); - } else if ((_plugin = _engine.block_factory()->plugin(uri))) { + } + + if ((_plugin = _engine.block_factory()->plugin(uri))) { _response.put_plugin(_plugin); return Event::pre_process_done(Status::SUCCESS); - } else { - return Event::pre_process_done(Status::NOT_FOUND, uri); } + + return Event::pre_process_done(Status::NOT_FOUND, uri); } void diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp index 6f538ddc..c1dd4e95 100644 --- a/src/server/ingen_lv2.cpp +++ b/src/server/ingen_lv2.cpp @@ -495,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; } |