diff options
Diffstat (limited to 'src/server')
57 files changed, 208 insertions, 210 deletions
diff --git a/src/server/.clang-tidy b/src/server/.clang-tidy index b5c584cf..8bb1a979 100644 --- a/src/server/.clang-tidy +++ b/src/server/.clang-tidy @@ -7,6 +7,7 @@ Checks: > -bugprone-branch-clone, -bugprone-parent-virtual-call, -bugprone-reserved-identifier, + -bugprone-suspicious-realloc-usage, -bugprone-suspicious-string-compare, -cert-dcl37-c, -cert-dcl51-cpp, diff --git a/src/server/ArcImpl.hpp b/src/server/ArcImpl.hpp index 27d7eacb..b1565390 100644 --- a/src/server/ArcImpl.hpp +++ b/src/server/ArcImpl.hpp @@ -17,8 +17,6 @@ #ifndef INGEN_ENGINE_ARC_IMPL_HPP #define INGEN_ENGINE_ARC_IMPL_HPP -// IWYU pragma: no_include "raul/Path.hpp" - #include "BufferRef.hpp" #include "ingen/Arc.hpp" @@ -28,6 +26,8 @@ #include <cstdint> +// IWYU pragma: no_include "raul/Path.hpp" + namespace raul { class Path; // IWYU pragma: keep } // namespace raul diff --git a/src/server/BlockFactory.cpp b/src/server/BlockFactory.cpp index 5c9279d3..4c8dd1d7 100644 --- a/src/server/BlockFactory.cpp +++ b/src/server/BlockFactory.cpp @@ -149,7 +149,7 @@ BlockFactory::load_lv2_plugins() using Types = std::vector<std::shared_ptr<LilvNode>>; Types types; for (unsigned t = PortType::ID::AUDIO; t <= PortType::ID::ATOM; ++t) { - const URI& uri(PortType(static_cast<PortType::ID>(t)).uri()); + const URI uri{PortType(static_cast<PortType::ID>(t)).uri()}; types.push_back(std::shared_ptr<LilvNode>( lilv_new_uri(_world.lilv_world(), uri.c_str()), lilv_node_free)); } diff --git a/src/server/BlockImpl.cpp b/src/server/BlockImpl.cpp index 3fa7a1c3..d4285832 100644 --- a/src/server/BlockImpl.cpp +++ b/src/server/BlockImpl.cpp @@ -25,6 +25,7 @@ #include "lv2/urid/urid.h" #include "raul/Array.hpp" +#include "raul/Maid.hpp" #include "raul/Symbol.hpp" #include <cassert> @@ -200,7 +201,7 @@ BlockImpl::bypass(RunContext& ctx) } // Dumb bypass - for (PortType t : { PortType::AUDIO, PortType::CV, PortType::ATOM }) { + for (const PortType t : { PortType::AUDIO, PortType::CV, PortType::ATOM }) { for (uint32_t i = 0;; ++i) { PortImpl* in = nth_port_by_type(i, true, t); PortImpl* out = nth_port_by_type(i, false, t); diff --git a/src/server/BlockImpl.hpp b/src/server/BlockImpl.hpp index 3f742bfa..ef76e9bf 100644 --- a/src/server/BlockImpl.hpp +++ b/src/server/BlockImpl.hpp @@ -23,7 +23,6 @@ #include "State.hpp" #include "types.hpp" -#include "ingen/Node.hpp" #include "ingen/Properties.hpp" #include "ingen/Resource.hpp" #include "ingen/URI.hpp" @@ -43,7 +42,10 @@ namespace raul { class Symbol; } // namespace raul -namespace ingen::server { +namespace ingen { +class Node; + +namespace server { class BufferFactory; class Engine; @@ -215,6 +217,7 @@ protected: bool _enabled{true}; }; -} // namespace ingen::server +} // namespace server +} // namespace ingen #endif // INGEN_ENGINE_BLOCKIMPL_HPP diff --git a/src/server/Broadcaster.cpp b/src/server/Broadcaster.cpp index 1d5cc843..e7406dc6 100644 --- a/src/server/Broadcaster.cpp +++ b/src/server/Broadcaster.cpp @@ -29,7 +29,7 @@ namespace ingen::server { Broadcaster::~Broadcaster() { - std::lock_guard<std::mutex> lock(_clients_mutex); + const std::lock_guard<std::mutex> lock{_clients_mutex}; _clients.clear(); _broadcastees.clear(); } @@ -39,7 +39,7 @@ Broadcaster::~Broadcaster() void Broadcaster::register_client(const std::shared_ptr<Interface>& client) { - std::lock_guard<std::mutex> lock(_clients_mutex); + const std::lock_guard<std::mutex> lock{_clients_mutex}; _clients.insert(client); } @@ -50,7 +50,7 @@ Broadcaster::register_client(const std::shared_ptr<Interface>& client) bool Broadcaster::unregister_client(const std::shared_ptr<Interface>& client) { - std::lock_guard<std::mutex> lock(_clients_mutex); + const std::lock_guard<std::mutex> lock{_clients_mutex}; const size_t erased = _clients.erase(client); _broadcastees.erase(client); return (erased > 0); @@ -71,7 +71,7 @@ Broadcaster::set_broadcast(const std::shared_ptr<Interface>& client, void Broadcaster::send_plugins(const BlockFactory::Plugins& plugins) { - std::lock_guard<std::mutex> lock(_clients_mutex); + const std::lock_guard<std::mutex> lock{_clients_mutex}; for (const auto& c : _clients) { send_plugins_to(c.get(), plugins); } diff --git a/src/server/Broadcaster.hpp b/src/server/Broadcaster.hpp index e4034155..9bae44b1 100644 --- a/src/server/Broadcaster.hpp +++ b/src/server/Broadcaster.hpp @@ -97,7 +97,7 @@ public: send_plugins_to(Interface*, const BlockFactory::Plugins& plugins); void message(const Message& msg) override { - std::lock_guard<std::mutex> lock(_clients_mutex); + const std::lock_guard<std::mutex> lock{_clients_mutex}; for (const auto& c : _clients) { if (c != _ignore_client) { c->message(msg); diff --git a/src/server/ClientUpdate.cpp b/src/server/ClientUpdate.cpp index c96a0d01..c69f5b49 100644 --- a/src/server/ClientUpdate.cpp +++ b/src/server/ClientUpdate.cpp @@ -26,7 +26,6 @@ #include "ingen/Arc.hpp" #include "ingen/Forge.hpp" #include "ingen/Interface.hpp" -#include "ingen/Node.hpp" #include "ingen/URIs.hpp" #include <boost/intrusive/slist.hpp> diff --git a/src/server/CompiledGraph.cpp b/src/server/CompiledGraph.cpp index b453932b..08e558a8 100644 --- a/src/server/CompiledGraph.cpp +++ b/src/server/CompiledGraph.cpp @@ -26,7 +26,6 @@ #include "ingen/Configuration.hpp" #include "ingen/Log.hpp" #include "ingen/World.hpp" -#include "raul/Maid.hpp" #include "raul/Path.hpp" #include <boost/intrusive/slist.hpp> @@ -76,11 +75,11 @@ CompiledGraph::CompiledGraph(GraphImpl* graph) compile_graph(graph); } -raul::managed_ptr<CompiledGraph> -CompiledGraph::compile(raul::Maid& maid, GraphImpl& graph) +std::unique_ptr<CompiledGraph> +CompiledGraph::compile(GraphImpl& graph) { try { - return maid.make_managed<CompiledGraph>(&graph); + return std::unique_ptr<CompiledGraph>(new CompiledGraph(&graph)); } catch (const FeedbackException& e) { Log& log = graph.engine().log(); if (e.node && e.root) { @@ -161,7 +160,7 @@ CompiledGraph::compile_graph(GraphImpl* graph) _master = Task::simplify(std::move(_master)); if (graph->engine().world().conf().option("trace").get<int32_t>()) { - ColorContext ctx(stderr, ColorContext::Color::YELLOW); + const ColorContext ctx{stderr, ColorContext::Color::YELLOW}; dump(graph->path()); } } diff --git a/src/server/CompiledGraph.hpp b/src/server/CompiledGraph.hpp index a5ba66c3..89aab289 100644 --- a/src/server/CompiledGraph.hpp +++ b/src/server/CompiledGraph.hpp @@ -19,7 +19,6 @@ #include "Task.hpp" -#include "raul/Maid.hpp" #include "raul/Noncopyable.hpp" #include <cstddef> @@ -39,17 +38,14 @@ class RunContext; * execute the nodes in order and have nodes always executed before any of * their dependencies. */ -class CompiledGraph : public raul::Maid::Disposable - , public raul::Noncopyable +class CompiledGraph : public raul::Noncopyable { public: - static raul::managed_ptr<CompiledGraph> compile(raul::Maid& maid, GraphImpl& graph); + static std::unique_ptr<CompiledGraph> compile(GraphImpl& graph); void run(RunContext& ctx); private: - friend class raul::Maid; ///< Allow make_managed to construct - CompiledGraph(GraphImpl* graph); using BlockSet = std::set<BlockImpl*>; @@ -72,10 +68,10 @@ private: std::unique_ptr<Task> _master; }; -inline raul::managed_ptr<CompiledGraph> -compile(raul::Maid& maid, GraphImpl& graph) +inline std::unique_ptr<CompiledGraph> +compile(GraphImpl& graph) { - return CompiledGraph::compile(maid, graph); + return CompiledGraph::compile(graph); } } // namespace ingen::server diff --git a/src/server/ControlBindings.cpp b/src/server/ControlBindings.cpp index 265333d4..e8dd3554 100644 --- a/src/server/ControlBindings.cpp +++ b/src/server/ControlBindings.cpp @@ -198,8 +198,9 @@ ControlBindings::port_value_changed(RunContext& ctx, { const ingen::URIs& uris = ctx.engine().world().uris(); if (!!key) { - int16_t value = port_value_to_control( - ctx, port, key.type, value_atom); + const int16_t value = + port_value_to_control(ctx, port, key.type, value_atom); + uint16_t size = 0; uint8_t buf[4]; switch (key.type) { @@ -390,7 +391,7 @@ ControlBindings::set_port_value(RunContext& ctx, // TODO: Set port value property so it is saved port->set_control_value(ctx, ctx.start(), val); - URIs& uris = ctx.engine().world().uris(); + const URIs& uris = ctx.engine().world().uris(); ctx.notify(uris.ingen_value, ctx.start(), port, sizeof(float), _forge.Float, &val); } diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp index 9603fcef..c4c492b7 100644 --- a/src/server/Engine.cpp +++ b/src/server/Engine.cpp @@ -19,7 +19,6 @@ #include "BlockFactory.hpp" #include "Broadcaster.hpp" #include "BufferFactory.hpp" -#include "BufferRef.hpp" #include "ControlBindings.hpp" #include "DirectDriver.hpp" #include "Driver.hpp" diff --git a/src/server/Engine.hpp b/src/server/Engine.hpp index d224d5b5..f0f19740 100644 --- a/src/server/Engine.hpp +++ b/src/server/Engine.hpp @@ -35,9 +35,12 @@ #include <random> #include <vector> +// IWYU pragma: no_include "RunContext.hpp" +// IWYU pragma: no_include "raul/RingBuffer.hpp" + namespace raul { class Maid; -class RingBuffer; +class RingBuffer; // IWYU pragma: keep } // namespace raul namespace ingen { @@ -60,7 +63,7 @@ class GraphImpl; class LV2Options; class PostProcessor; class PreProcessor; -class RunContext; +class RunContext; // IWYU pragma: keep class SocketListener; class Task; class UndoStack; diff --git a/src/server/GraphImpl.cpp b/src/server/GraphImpl.cpp index fedc5df8..0d3c5234 100644 --- a/src/server/GraphImpl.cpp +++ b/src/server/GraphImpl.cpp @@ -30,6 +30,7 @@ #include "ingen/Forge.hpp" #include "ingen/Properties.hpp" +#include "ingen/URI.hpp" #include "ingen/URIs.hpp" #include "ingen/World.hpp" #include "lv2/urid/urid.h" @@ -41,7 +42,6 @@ #include <cstddef> #include <map> #include <memory> -#include <type_traits> #include <unordered_map> namespace ingen::server { @@ -309,13 +309,15 @@ GraphImpl::has_arc(const PortImpl* tail, const PortImpl* dst_port) const return (i != _graph_arcs.end()); } -void -GraphImpl::set_compiled_graph(raul::managed_ptr<CompiledGraph>&& cg) +std::unique_ptr<CompiledGraph> +GraphImpl::swap_compiled_graph(std::unique_ptr<CompiledGraph> cg) { if (_compiled_graph && _compiled_graph != cg) { _engine.reset_load(); } - _compiled_graph = std::move(cg); + + _compiled_graph.swap(cg); + return cg; } uint32_t diff --git a/src/server/GraphImpl.hpp b/src/server/GraphImpl.hpp index 1976fd4d..c5f978fb 100644 --- a/src/server/GraphImpl.hpp +++ b/src/server/GraphImpl.hpp @@ -1,6 +1,6 @@ /* This file is part of Ingen. - Copyright 2007-2015 David Robillard <http://drobilla.net/> + Copyright 2007-2023 David Robillard <http://drobilla.net/> Ingen is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free @@ -23,7 +23,6 @@ #include "server.h" #include "types.hpp" -#include "ingen/Node.hpp" #include "lv2/urid/urid.h" #include "raul/Maid.hpp" @@ -34,6 +33,8 @@ #include <memory> #include <utility> +// IWYU pragma: no_include "CompiledGraph.hpp" + namespace raul { class Symbol; } // namespace raul @@ -46,7 +47,7 @@ namespace ingen::server { class ArcImpl; class BufferFactory; -class CompiledGraph; +class CompiledGraph; // IWYU pragma: keep class Engine; class PortImpl; class RunContext; @@ -180,7 +181,8 @@ public: bool has_arc(const PortImpl* tail, const PortImpl* dst_port) const; /** Set a new compiled graph to run, and return the old one. */ - void set_compiled_graph(raul::managed_ptr<CompiledGraph>&& cg); + [[nodiscard]] std::unique_ptr<CompiledGraph> + swap_compiled_graph(std::unique_ptr<CompiledGraph> cg); const raul::managed_ptr<Ports>& external_ports() { return _ports; } @@ -199,7 +201,7 @@ public: Engine& engine() { return _engine; } private: - using CompiledGraphPtr = raul::managed_ptr<CompiledGraph>; + using CompiledGraphPtr = std::unique_ptr<CompiledGraph>; Engine& _engine; uint32_t _poly_pre; ///< Pre-process thread only diff --git a/src/server/InternalPlugin.cpp b/src/server/InternalPlugin.cpp index e6535ab2..b2f2bae7 100644 --- a/src/server/InternalPlugin.cpp +++ b/src/server/InternalPlugin.cpp @@ -25,6 +25,8 @@ #include "types.hpp" #include "ingen/URIs.hpp" +#include "lilv/lilv.h" +#include "raul/Symbol.hpp" #include <utility> diff --git a/src/server/JackDriver.cpp b/src/server/JackDriver.cpp index eafa0fa7..d991879e 100644 --- a/src/server/JackDriver.cpp +++ b/src/server/JackDriver.cpp @@ -40,6 +40,7 @@ #include "lv2/atom/forge.h" #include "lv2/atom/util.h" #include "raul/Path.hpp" +#include "raul/Semaphore.hpp" #include <jack/midiport.h> #include <jack/transport.h> diff --git a/src/server/LV2Block.cpp b/src/server/LV2Block.cpp index 6dac1eec..c5cd73dc 100644 --- a/src/server/LV2Block.cpp +++ b/src/server/LV2Block.cpp @@ -37,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" @@ -349,7 +350,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 +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(), @@ -521,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(), @@ -589,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); @@ -717,17 +718,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); diff --git a/src/server/LV2Plugin.cpp b/src/server/LV2Plugin.cpp index 25ae9294..1e88952e 100644 --- a/src/server/LV2Plugin.cpp +++ b/src/server/LV2Plugin.cpp @@ -23,6 +23,8 @@ #include "ingen/Log.hpp" #include "ingen/URIs.hpp" #include "ingen/World.hpp" +#include "lilv/lilv.h" +#include "raul/Symbol.hpp" #include <cstdlib> #include <string> @@ -73,7 +75,7 @@ LV2Plugin::symbol() const } while (working.length() > 0) { - size_t last_slash = working.find_last_of('/'); + const size_t last_slash = working.find_last_of('/'); const std::string symbol = working.substr(last_slash+1); if ( (symbol[0] >= 'a' && symbol[0] <= 'z') || (symbol[0] >= 'A' && symbol[0] <= 'Z') ) { diff --git a/src/server/PortImpl.cpp b/src/server/PortImpl.cpp index 307d9b73..c7b20f2b 100644 --- a/src/server/PortImpl.cpp +++ b/src/server/PortImpl.cpp @@ -24,6 +24,7 @@ #include "ThreadManager.hpp" #include "ingen/Forge.hpp" +#include "ingen/Node.hpp" #include "ingen/URIs.hpp" #include "ingen/World.hpp" #include "lv2/atom/atom.h" @@ -289,9 +290,9 @@ PortImpl::set_voice_value(const RunContext& ctx, void PortImpl::update_set_state(const RunContext& ctx, uint32_t v) { - Voice& voice = _voices->at(v); - SetState& state = voice.set_state; - BufferRef buf = voice.buffer; + Voice& voice = _voices->at(v); + SetState& state = voice.set_state; + const BufferRef buf = voice.buffer; switch (state.state) { case SetState::State::SET: break; @@ -458,10 +459,10 @@ PortImpl::monitor(RunContext& ctx, bool send_now) return; } - Forge& forge = ctx.engine().world().forge(); - URIs& uris = ctx.engine().world().uris(); - LV2_URID key = 0; - float val = 0.0f; + const Forge& forge = ctx.engine().world().forge(); + const URIs& uris = ctx.engine().world().uris(); + LV2_URID key = 0; + float val = 0.0f; switch (_type.id()) { case PortType::UNKNOWN: break; diff --git a/src/server/PortImpl.hpp b/src/server/PortImpl.hpp index 07904cff..64c3322f 100644 --- a/src/server/PortImpl.hpp +++ b/src/server/PortImpl.hpp @@ -26,7 +26,6 @@ #include "types.hpp" #include "ingen/Atom.hpp" -#include "ingen/Node.hpp" #include "ingen/URIs.hpp" #include "lv2/urid/urid.h" #include "raul/Array.hpp" diff --git a/src/server/PreProcessContext.hpp b/src/server/PreProcessContext.hpp index 79e8ca68..7c97af3c 100644 --- a/src/server/PreProcessContext.hpp +++ b/src/server/PreProcessContext.hpp @@ -20,8 +20,7 @@ #include "CompiledGraph.hpp" #include "GraphImpl.hpp" -#include "raul/Maid.hpp" - +#include <memory> #include <unordered_set> namespace ingen::server { @@ -64,13 +63,9 @@ public: * This may return null when an atomic bundle is deferring compilation, in * which case the graph is flagged as dirty for later compilation. */ - raul::Maid::managed_ptr<CompiledGraph> - maybe_compile(raul::Maid& maid, GraphImpl& graph) + [[nodiscard]] std::unique_ptr<CompiledGraph> maybe_compile(GraphImpl& graph) { - if (must_compile(graph)) { - return compile(maid, graph); - } - return nullptr; + return must_compile(graph) ? compile(graph) : nullptr; } /** Return all graphs that require compilation after an atomic bundle. */ diff --git a/src/server/PreProcessor.cpp b/src/server/PreProcessor.cpp index 5d719761..f9d7ecb3 100644 --- a/src/server/PreProcessor.cpp +++ b/src/server/PreProcessor.cpp @@ -28,6 +28,7 @@ #include "ingen/AtomWriter.hpp" #include "ingen/Configuration.hpp" #include "ingen/World.hpp" +#include "raul/Semaphore.hpp" #include <cassert> #include <cstdint> @@ -55,7 +56,7 @@ PreProcessor::event(Event* const ev, Event::Mode mode) { // TODO: Probably possible to make this lock-free with CAS ThreadManager::assert_not_thread(THREAD_IS_REAL_TIME); - std::lock_guard<std::mutex> lock(_mutex); + const std::lock_guard<std::mutex> lock{_mutex}; assert(!ev->is_prepared()); assert(!ev->next()); @@ -140,7 +141,7 @@ PreProcessor::process(RunContext& ctx, PostProcessor& dest, size_t limit) if (n_processed > 0) { #ifndef NDEBUG - Engine& engine = ctx.engine(); + const Engine& engine = ctx.engine(); if (engine.world().conf().option("trace").get<int32_t>()) { const uint64_t start = engine.cycle_start_time(ctx); const uint64_t end = engine.current_time(); diff --git a/src/server/RunContext.cpp b/src/server/RunContext.cpp index 2bac3140..95d68f57 100644 --- a/src/server/RunContext.cpp +++ b/src/server/RunContext.cpp @@ -160,9 +160,9 @@ void RunContext::set_priority(int priority) { if (_thread) { - pthread_t pthread = _thread->native_handle(); - const int policy = (priority > 0) ? SCHED_FIFO : SCHED_OTHER; - sched_param sp{}; + const pthread_t pthread = _thread->native_handle(); + const int policy = (priority > 0) ? SCHED_FIFO : SCHED_OTHER; + sched_param sp{}; sp.sched_priority = (priority > 0) ? priority : 0; if (pthread_setschedparam(pthread, policy, &sp)) { _engine.log().error( diff --git a/src/server/Task.hpp b/src/server/Task.hpp index e64d888c..30941f28 100644 --- a/src/server/Task.hpp +++ b/src/server/Task.hpp @@ -44,7 +44,7 @@ public: : _block(block) , _mode(mode) { - assert(!(mode == Mode::SINGLE && !block)); + assert(mode != Mode::SINGLE || block); } Task(const Task&) = delete; diff --git a/src/server/UndoStack.cpp b/src/server/UndoStack.cpp index 395a04cd..abb9fe46 100644 --- a/src/server/UndoStack.cpp +++ b/src/server/UndoStack.cpp @@ -27,7 +27,6 @@ #include <ctime> #include <iterator> -#include <memory> #define NS_RDF "http://www.w3.org/1999/02/22-rdf-syntax-ns#" @@ -41,7 +40,7 @@ UndoStack::start_entry() if (_depth == 0) { time_t now = {}; time(&now); - _stack.emplace_back(Entry(now)); + _stack.emplace_back(now); } return ++_depth; } @@ -188,8 +187,8 @@ UndoStack::write_entry(Sratom* sratom, strftime(time_str, sizeof(time_str), "%FT%T", gmtime(&entry.time)); // entry rdf:type ingen:UndoEntry - SerdNode p = serd_node_from_string(SERD_URI, USTR(INGEN_NS "time")); - SerdNode o = serd_node_from_string(SERD_LITERAL, USTR(time_str)); + SerdNode p = serd_node_from_string(SERD_URI, USTR(INGEN_NS "time")); + const SerdNode o = serd_node_from_string(SERD_LITERAL, USTR(time_str)); serd_writer_write_statement(writer, SERD_ANON_CONT, nullptr, subject, &p, &o, nullptr, nullptr); p = serd_node_from_string(SERD_URI, USTR(INGEN_NS "events")); @@ -245,8 +244,8 @@ UndoStack::save(FILE* stream, const char* name) reinterpret_cast<SerdEndSink>(serd_writer_end_anon), writer); - SerdNode s = serd_node_from_string(SERD_BLANK, USTR(name)); - SerdNode p = serd_node_from_string(SERD_URI, USTR(INGEN_NS "entries")); + const SerdNode s = serd_node_from_string(SERD_BLANK, USTR(name)); + const SerdNode p = serd_node_from_string(SERD_URI, USTR(INGEN_NS "entries")); BlankIDs ids('u'); ListContext ctx(ids, 0, &s, &p); diff --git a/src/server/Worker.cpp b/src/server/Worker.cpp index 5b4da498..cf252d37 100644 --- a/src/server/Worker.cpp +++ b/src/server/Worker.cpp @@ -24,6 +24,8 @@ #include "ingen/Node.hpp" #include "lv2/core/lv2.h" #include "lv2/worker/worker.h" +#include "raul/RingBuffer.hpp" +#include "raul/Semaphore.hpp" #include <cstdlib> #include <memory> @@ -46,8 +48,8 @@ schedule(LV2_Worker_Schedule_Handle handle, uint32_t size, const void* data) { - auto* block = static_cast<LV2Block*>(handle); - Engine& engine = block->parent_graph()->engine(); + auto* block = static_cast<LV2Block*>(handle); + const Engine& engine = block->parent_graph()->engine(); return engine.worker()->request(block, size, data); } @@ -57,8 +59,8 @@ schedule_sync(LV2_Worker_Schedule_Handle handle, uint32_t size, const void* data) { - auto* block = static_cast<LV2Block*>(handle); - Engine& engine = block->parent_graph()->engine(); + auto* block = static_cast<LV2Block*>(handle); + const Engine& engine = block->parent_graph()->engine(); return engine.sync_worker()->request(block, size, data); } @@ -72,7 +74,7 @@ Worker::request(LV2Block* block, return block->work(size, data); } - Engine& engine = block->parent_graph()->engine(); + const Engine& engine = block->parent_graph()->engine(); if (_requests.write_space() < sizeof(MessageHeader) + size) { engine.log().error("Work request ring overflow\n"); return LV2_WORKER_ERR_NO_SPACE; diff --git a/src/server/events/Connect.cpp b/src/server/events/Connect.cpp index 44c734a8..e1854ef2 100644 --- a/src/server/events/Connect.cpp +++ b/src/server/events/Connect.cpp @@ -57,7 +57,7 @@ Connect::~Connect() = default; bool Connect::pre_process(PreProcessContext& ctx) { - std::lock_guard<Store::Mutex> lock(_engine.store()->mutex()); + const std::lock_guard<Store::Mutex> lock{_engine.store()->mutex()}; Node* tail = _engine.store()->get(_msg.tail); if (!tail) { @@ -132,7 +132,7 @@ Connect::pre_process(PreProcessContext& ctx) head_block->providers().insert(tail_block); if (ctx.must_compile(*_graph)) { - if (!(_compiled_graph = compile(*_engine.maid(), *_graph))) { + if (!(_compiled_graph = compile(*_graph))) { head_block->providers().erase(tail_block); tail_block->dependants().erase(head_block); return Event::pre_process_done(Status::COMPILATION_FAILED); @@ -165,7 +165,7 @@ Connect::execute(RunContext& ctx) } _head->connect_buffers(); if (_compiled_graph) { - _graph->set_compiled_graph(std::move(_compiled_graph)); + _compiled_graph = _graph->swap_compiled_graph(std::move(_compiled_graph)); } } } @@ -173,7 +173,7 @@ Connect::execute(RunContext& ctx) void Connect::post_process() { - Broadcaster::Transfer t(*_engine.broadcaster()); + const Broadcaster::Transfer t{*_engine.broadcaster()}; if (respond() == Status::SUCCESS) { _engine.broadcaster()->message(_msg); if (!_tail_remove.empty() || !_tail_add.empty()) { diff --git a/src/server/events/Connect.hpp b/src/server/events/Connect.hpp index a735b68c..4224f109 100644 --- a/src/server/events/Connect.hpp +++ b/src/server/events/Connect.hpp @@ -66,7 +66,7 @@ private: const ingen::Connect _msg; GraphImpl* _graph{nullptr}; InputPort* _head{nullptr}; - raul::managed_ptr<CompiledGraph> _compiled_graph; + std::unique_ptr<CompiledGraph> _compiled_graph; std::shared_ptr<ArcImpl> _arc; raul::managed_ptr<PortImpl::Voices> _voices; Properties _tail_remove; diff --git a/src/server/events/Copy.cpp b/src/server/events/Copy.cpp index f6bcc62a..f6529da3 100644 --- a/src/server/events/Copy.cpp +++ b/src/server/events/Copy.cpp @@ -24,6 +24,7 @@ #include "PreProcessContext.hpp" #include "ingen/Interface.hpp" +#include "ingen/Node.hpp" #include "ingen/Parser.hpp" #include "ingen/Serialiser.hpp" #include "ingen/Status.hpp" @@ -57,7 +58,7 @@ Copy::~Copy() = default; bool Copy::pre_process(PreProcessContext& ctx) { - std::lock_guard<Store::Mutex> lock(_engine.store()->mutex()); + const std::lock_guard<Store::Mutex> lock{_engine.store()->mutex()}; if (uri_is_path(_msg.old_uri)) { // Old URI is a path within the engine @@ -136,7 +137,7 @@ Copy::engine_to_engine(PreProcessContext& ctx) _engine.store()->add(_block); // Compile graph with new block added for insertion in audio thread - _compiled_graph = ctx.maybe_compile(*_engine.maid(), *_parent); + _compiled_graph = ctx.maybe_compile(*_parent); return Event::pre_process_done(Status::SUCCESS); } @@ -163,7 +164,7 @@ Copy::engine_to_filesystem(PreProcessContext&) return Event::pre_process_done(Status::INTERNAL_ERROR); } - std::lock_guard<std::mutex> lock(_engine.world().rdf_mutex()); + const std::lock_guard<std::mutex> lock{_engine.world().rdf_mutex()}; if (ends_with(_msg.new_uri, ".ingen") || ends_with(_msg.new_uri, ".ingen/")) { _engine.world().serialiser()->write_bundle(graph, URI(_msg.new_uri)); @@ -184,7 +185,7 @@ Copy::filesystem_to_engine(PreProcessContext&) return Event::pre_process_done(Status::INTERNAL_ERROR); } - std::lock_guard<std::mutex> lock(_engine.world().rdf_mutex()); + const std::lock_guard<std::mutex> lock{_engine.world().rdf_mutex()}; // Old URI is a filesystem path and new URI is a path within the engine const std::string src_path(_msg.old_uri.path()); @@ -207,14 +208,15 @@ void Copy::execute(RunContext&) { if (_block && _compiled_graph) { - _parent->set_compiled_graph(std::move(_compiled_graph)); + _compiled_graph = + _parent->swap_compiled_graph(std::move(_compiled_graph)); } } void Copy::post_process() { - Broadcaster::Transfer t(*_engine.broadcaster()); + const Broadcaster::Transfer t{*_engine.broadcaster()}; if (respond() == Status::SUCCESS) { _engine.broadcaster()->message(_msg); } diff --git a/src/server/events/Copy.hpp b/src/server/events/Copy.hpp index 8460140a..744a61c2 100644 --- a/src/server/events/Copy.hpp +++ b/src/server/events/Copy.hpp @@ -21,7 +21,6 @@ #include "types.hpp" #include "ingen/Message.hpp" -#include "raul/Maid.hpp" #include <memory> @@ -67,7 +66,7 @@ private: std::shared_ptr<BlockImpl> _old_block{nullptr}; GraphImpl* _parent{nullptr}; BlockImpl* _block{nullptr}; - raul::managed_ptr<CompiledGraph> _compiled_graph; + std::unique_ptr<CompiledGraph> _compiled_graph; }; } // namespace events diff --git a/src/server/events/CreateBlock.cpp b/src/server/events/CreateBlock.cpp index 73834fcb..7f50411c 100644 --- a/src/server/events/CreateBlock.cpp +++ b/src/server/events/CreateBlock.cpp @@ -40,7 +40,6 @@ #include "ingen/URIs.hpp" #include "ingen/World.hpp" #include "ingen/paths.hpp" -#include "raul/Maid.hpp" #include "raul/Path.hpp" #include "raul/Symbol.hpp" @@ -169,7 +168,7 @@ CreateBlock::pre_process(PreProcessContext& ctx) /* Compile graph with new block added for insertion in audio thread TODO: Since the block is not connected at this point, a full compilation could be avoided and the block simply appended. */ - _compiled_graph = ctx.maybe_compile(*_engine.maid(), *_graph); + _compiled_graph = ctx.maybe_compile(*_graph); _update.put_block(_block); @@ -180,14 +179,15 @@ void CreateBlock::execute(RunContext&) { if (_status == Status::SUCCESS && _compiled_graph) { - _graph->set_compiled_graph(std::move(_compiled_graph)); + _compiled_graph = + _graph->swap_compiled_graph(std::move(_compiled_graph)); } } void CreateBlock::post_process() { - Broadcaster::Transfer t(*_engine.broadcaster()); + const Broadcaster::Transfer t{*_engine.broadcaster()}; if (respond() == Status::SUCCESS) { _update.send(*_engine.broadcaster()); } diff --git a/src/server/events/CreateBlock.hpp b/src/server/events/CreateBlock.hpp index 2a7a60ab..e8a49ea0 100644 --- a/src/server/events/CreateBlock.hpp +++ b/src/server/events/CreateBlock.hpp @@ -21,7 +21,6 @@ #include "Event.hpp" #include "types.hpp" -#include "raul/Maid.hpp" #include "raul/Path.hpp" #include <cstdint> @@ -70,7 +69,7 @@ private: ClientUpdate _update; GraphImpl* _graph{nullptr}; BlockImpl* _block{nullptr}; - raul::managed_ptr<CompiledGraph> _compiled_graph; + std::unique_ptr<CompiledGraph> _compiled_graph; }; } // namespace events diff --git a/src/server/events/CreateGraph.cpp b/src/server/events/CreateGraph.cpp index bcc935bb..7a8a973d 100644 --- a/src/server/events/CreateGraph.cpp +++ b/src/server/events/CreateGraph.cpp @@ -35,7 +35,6 @@ #include "ingen/URIs.hpp" #include "ingen/World.hpp" #include "ingen/paths.hpp" -#include "raul/Maid.hpp" #include "raul/Path.hpp" #include "raul/Symbol.hpp" @@ -192,7 +191,7 @@ CreateGraph::pre_process(PreProcessContext& ctx) if (_parent->enabled()) { _graph->enable(); } - _compiled_graph = ctx.maybe_compile(*_engine.maid(), *_parent); + _compiled_graph = ctx.maybe_compile(*_parent); } _graph->activate(*_engine.buffer_factory()); @@ -219,7 +218,8 @@ CreateGraph::execute(RunContext& ctx) if (_graph) { if (_parent) { if (_compiled_graph) { - _parent->set_compiled_graph(std::move(_compiled_graph)); + _compiled_graph = + _parent->swap_compiled_graph(std::move(_compiled_graph)); } } else { _engine.set_root_graph(_graph); @@ -235,7 +235,7 @@ CreateGraph::execute(RunContext& ctx) void CreateGraph::post_process() { - Broadcaster::Transfer t(*_engine.broadcaster()); + const Broadcaster::Transfer t{*_engine.broadcaster()}; if (respond() == Status::SUCCESS) { _update.send(*_engine.broadcaster()); } diff --git a/src/server/events/CreateGraph.hpp b/src/server/events/CreateGraph.hpp index 7fc005ad..b083ae8c 100644 --- a/src/server/events/CreateGraph.hpp +++ b/src/server/events/CreateGraph.hpp @@ -22,7 +22,6 @@ #include "types.hpp" #include "ingen/Properties.hpp" -#include "raul/Maid.hpp" #include "raul/Path.hpp" #include <cstdint> @@ -74,7 +73,7 @@ private: ClientUpdate _update; GraphImpl* _graph{nullptr}; GraphImpl* _parent{nullptr}; - raul::managed_ptr<CompiledGraph> _compiled_graph; + std::unique_ptr<CompiledGraph> _compiled_graph; std::list<std::unique_ptr<Event>> _child_events; }; diff --git a/src/server/events/CreatePort.cpp b/src/server/events/CreatePort.cpp index 7a01d0d9..937842a7 100644 --- a/src/server/events/CreatePort.cpp +++ b/src/server/events/CreatePort.cpp @@ -210,7 +210,7 @@ CreatePort::execute(RunContext& ctx) void CreatePort::post_process() { - Broadcaster::Transfer t(*_engine.broadcaster()); + const Broadcaster::Transfer t{*_engine.broadcaster()}; if (respond() == Status::SUCCESS) { _engine.broadcaster()->put(path_to_uri(_path), _update); } diff --git a/src/server/events/Delete.cpp b/src/server/events/Delete.cpp index b64c81c0..62653752 100644 --- a/src/server/events/Delete.cpp +++ b/src/server/events/Delete.cpp @@ -104,7 +104,7 @@ Delete::pre_process(PreProcessContext& ctx) } // Take a writer lock while we modify the store - std::lock_guard<Store::Mutex> lock(_engine.store()->mutex()); + const std::lock_guard<Store::Mutex> lock{_engine.store()->mutex()}; _engine.store()->remove(iter, _removed_objects); @@ -113,14 +113,14 @@ Delete::pre_process(PreProcessContext& ctx) _disconnect_event = std::make_unique<DisconnectAll>(_engine, parent, _block.get()); _disconnect_event->pre_process(ctx); - _compiled_graph = ctx.maybe_compile(*_engine.maid(), *parent); + _compiled_graph = ctx.maybe_compile(*parent); } else if (_port) { parent->remove_port(*_port); _disconnect_event = std::make_unique<DisconnectAll>(_engine, parent, _port.get()); _disconnect_event->pre_process(ctx); - _compiled_graph = ctx.maybe_compile(*_engine.maid(), *parent); + _compiled_graph = ctx.maybe_compile(*parent); if (parent->enabled()) { _ports_array = parent->build_ports_array(*_engine.maid()); assert(_ports_array->size() == parent->num_ports_non_rt()); @@ -182,14 +182,14 @@ Delete::execute(RunContext& ctx) } if (parent && _compiled_graph) { - parent->set_compiled_graph(std::move(_compiled_graph)); + _compiled_graph = parent->swap_compiled_graph(std::move(_compiled_graph)); } } void Delete::post_process() { - Broadcaster::Transfer t(*_engine.broadcaster()); + const Broadcaster::Transfer t{*_engine.broadcaster()}; if (respond() == Status::SUCCESS && (_block || _port)) { if (_block) { _block->deactivate(); diff --git a/src/server/events/Delete.hpp b/src/server/events/Delete.hpp index 840b8415..87cde2c7 100644 --- a/src/server/events/Delete.hpp +++ b/src/server/events/Delete.hpp @@ -17,7 +17,6 @@ #ifndef INGEN_EVENTS_DELETE_HPP #define INGEN_EVENTS_DELETE_HPP -#include "BlockImpl.hpp" #include "ControlBindings.hpp" #include "Event.hpp" #include "GraphImpl.hpp" @@ -41,6 +40,7 @@ class Interface; namespace server { +class BlockImpl; class CompiledGraph; class DuplexPort; class Engine; @@ -80,7 +80,7 @@ private: std::shared_ptr<DuplexPort> _port; ///< Non-null iff a port EnginePort* _engine_port{nullptr}; raul::managed_ptr<GraphImpl::Ports> _ports_array; ///< New (external) ports for Graph - raul::managed_ptr<CompiledGraph> _compiled_graph; ///< Graph's new process order + std::unique_ptr<CompiledGraph> _compiled_graph; ///< Graph's new process order std::unique_ptr<DisconnectAll> _disconnect_event; Store::Objects _removed_objects; IndexChanges _port_index_changes; diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp index 0b8cab39..11a0b0ff 100644 --- a/src/server/events/Delta.cpp +++ b/src/server/events/Delta.cpp @@ -45,7 +45,6 @@ #include "ingen/World.hpp" #include "ingen/paths.hpp" #include "lilv/lilv.h" -#include "raul/Maid.hpp" #include "raul/Path.hpp" #include <algorithm> @@ -213,7 +212,7 @@ Delta::pre_process(PreProcessContext& ctx) return Event::pre_process_done(Status::FAILURE); } - std::lock_guard<Store::Mutex> lock(_engine.store()->mutex()); + const std::lock_guard<Store::Mutex> lock{_engine.store()->mutex()}; _object = is_graph_object ? static_cast<ingen::Resource*>(_engine.store()->get(uri_to_path(_subject))) @@ -225,7 +224,7 @@ Delta::pre_process(PreProcessContext& ctx) } if (is_graph_object && !_object) { - raul::Path path(uri_to_path(_subject)); + const raul::Path path{uri_to_path(_subject)}; bool is_graph = false; bool is_block = false; @@ -397,7 +396,7 @@ Delta::pre_process(PreProcessContext& ctx) op = SpecialType::ENABLE; // FIXME: defer until all other data has been processed if (value.get<int32_t>() && !_graph->enabled()) { - if (!(_compiled_graph = compile(*_engine.maid(), *_graph))) { + if (!(_compiled_graph = compile(*_graph))) { _status = Status::COMPILATION_FAILED; } } @@ -516,7 +515,7 @@ Delta::execute(RunContext& ctx) if (_graph) { if (value.get<int32_t>()) { if (_compiled_graph) { - _graph->set_compiled_graph(std::move(_compiled_graph)); + _compiled_graph = _graph->swap_compiled_graph(std::move(_compiled_graph)); } _graph->enable(); } else { @@ -594,7 +593,7 @@ Delta::post_process() _state.reset(); } - Broadcaster::Transfer t(*_engine.broadcaster()); + const Broadcaster::Transfer t{*_engine.broadcaster()}; if (_create_event) { _create_event->post_process(); diff --git a/src/server/events/Delta.hpp b/src/server/events/Delta.hpp index 35357a26..ed04f8c9 100644 --- a/src/server/events/Delta.hpp +++ b/src/server/events/Delta.hpp @@ -27,13 +27,13 @@ #include "ingen/Properties.hpp" #include "ingen/Resource.hpp" #include "ingen/URI.hpp" -#include "raul/Maid.hpp" #include <cstdint> #include <memory> #include <optional> #include <vector> +// IWYU pragma: no_include "CompiledGraph.hpp" // IWYU pragma: no_include <algorithm> namespace ingen { @@ -45,7 +45,7 @@ struct SetProperty; namespace server { -class CompiledGraph; +class CompiledGraph; // IWYU pragma: keep class Engine; class GraphImpl; class PreProcessContext; @@ -117,7 +117,7 @@ private: ClientUpdate _update; ingen::Resource* _object{nullptr}; GraphImpl* _graph{nullptr}; - raul::managed_ptr<CompiledGraph> _compiled_graph; + std::unique_ptr<CompiledGraph> _compiled_graph; ControlBindings::Binding* _binding{nullptr}; StatePtr _state; Resource::Graph _context; diff --git a/src/server/events/Disconnect.cpp b/src/server/events/Disconnect.cpp index ef0cbd0b..e0db262a 100644 --- a/src/server/events/Disconnect.cpp +++ b/src/server/events/Disconnect.cpp @@ -117,7 +117,7 @@ Disconnect::Impl::Impl(Engine& e, bool Disconnect::pre_process(PreProcessContext& ctx) { - std::lock_guard<Store::Mutex> lock(_engine.store()->mutex()); + const std::lock_guard<Store::Mutex> lock{_engine.store()->mutex()}; if (_msg.tail.parent().parent() != _msg.head.parent().parent() && _msg.tail.parent() != _msg.head.parent().parent() @@ -171,7 +171,7 @@ Disconnect::pre_process(PreProcessContext& ctx) dynamic_cast<PortImpl*>(tail), dynamic_cast<InputPort*>(head)); - _compiled_graph = ctx.maybe_compile(*_engine.maid(), *_graph); + _compiled_graph = ctx.maybe_compile(*_graph); return Event::pre_process_done(Status::SUCCESS); } @@ -208,7 +208,8 @@ Disconnect::execute(RunContext& ctx) if (_status == Status::SUCCESS) { if (_impl->execute(ctx, true)) { if (_compiled_graph) { - _graph->set_compiled_graph(std::move(_compiled_graph)); + _compiled_graph = + _graph->swap_compiled_graph(std::move(_compiled_graph)); } } else { _status = Status::NOT_FOUND; @@ -219,7 +220,7 @@ Disconnect::execute(RunContext& ctx) void Disconnect::post_process() { - Broadcaster::Transfer t(*_engine.broadcaster()); + const Broadcaster::Transfer t{*_engine.broadcaster()}; if (respond() == Status::SUCCESS) { _engine.broadcaster()->message(_msg); } diff --git a/src/server/events/Disconnect.hpp b/src/server/events/Disconnect.hpp index 71ad4204..ad3d07b0 100644 --- a/src/server/events/Disconnect.hpp +++ b/src/server/events/Disconnect.hpp @@ -83,7 +83,7 @@ private: const ingen::Disconnect _msg; GraphImpl* _graph{nullptr}; std::unique_ptr<Impl> _impl; - raul::managed_ptr<CompiledGraph> _compiled_graph; + std::unique_ptr<CompiledGraph> _compiled_graph; }; } // namespace events diff --git a/src/server/events/DisconnectAll.cpp b/src/server/events/DisconnectAll.cpp index 957c6a6f..5f0e9a5e 100644 --- a/src/server/events/DisconnectAll.cpp +++ b/src/server/events/DisconnectAll.cpp @@ -32,7 +32,6 @@ #include "ingen/Node.hpp" #include "ingen/Status.hpp" #include "ingen/Store.hpp" -#include "raul/Maid.hpp" #include <memory> #include <mutex> @@ -130,7 +129,7 @@ DisconnectAll::pre_process(PreProcessContext& ctx) } if (!_deleting && ctx.must_compile(*_parent)) { - if (!(_compiled_graph = compile(*_engine.maid(), *_parent))) { + if (!(_compiled_graph = compile(*_parent))) { return Event::pre_process_done(Status::COMPILATION_FAILED); } } @@ -149,14 +148,14 @@ DisconnectAll::execute(RunContext& ctx) } if (_compiled_graph) { - _parent->set_compiled_graph(std::move(_compiled_graph)); + _compiled_graph = _parent->swap_compiled_graph(std::move(_compiled_graph)); } } void DisconnectAll::post_process() { - Broadcaster::Transfer t(*_engine.broadcaster()); + const Broadcaster::Transfer t{*_engine.broadcaster()}; if (respond() == Status::SUCCESS) { _engine.broadcaster()->message(_msg); } diff --git a/src/server/events/DisconnectAll.hpp b/src/server/events/DisconnectAll.hpp index 70da5dd6..aeb180de 100644 --- a/src/server/events/DisconnectAll.hpp +++ b/src/server/events/DisconnectAll.hpp @@ -22,7 +22,6 @@ #include "types.hpp" #include "ingen/Message.hpp" -#include "raul/Maid.hpp" #include <list> #include <memory> @@ -79,7 +78,7 @@ private: BlockImpl* _block; PortImpl* _port; Impls _impls; - raul::managed_ptr<CompiledGraph> _compiled_graph; + std::unique_ptr<CompiledGraph> _compiled_graph; bool _deleting; }; diff --git a/src/server/events/Get.cpp b/src/server/events/Get.cpp index f4cbb49d..9efef123 100644 --- a/src/server/events/Get.cpp +++ b/src/server/events/Get.cpp @@ -50,7 +50,7 @@ Get::Get(Engine& engine, bool Get::pre_process(PreProcessContext&) { - std::lock_guard<Store::Mutex> lock(_engine.store()->mutex()); + const std::lock_guard<Store::Mutex> lock{_engine.store()->mutex()}; const auto& uri = _msg.subject; if (uri == "ingen:/plugins") { @@ -96,7 +96,7 @@ Get::execute(RunContext&) void Get::post_process() { - Broadcaster::Transfer t(*_engine.broadcaster()); + const Broadcaster::Transfer t{*_engine.broadcaster()}; if (respond() == Status::SUCCESS && _request_client) { if (_msg.subject == "ingen:/plugins") { _engine.broadcaster()->send_plugins_to(_request_client.get(), _plugins); diff --git a/src/server/events/Mark.cpp b/src/server/events/Mark.cpp index 97acdbbb..87bc1035 100644 --- a/src/server/events/Mark.cpp +++ b/src/server/events/Mark.cpp @@ -84,7 +84,7 @@ Mark::pre_process(PreProcessContext& ctx) ctx.set_in_bundle(false); if (!ctx.dirty_graphs().empty()) { for (GraphImpl* g : ctx.dirty_graphs()) { - auto cg = compile(*_engine.maid(), *g); + auto cg = compile(*g); if (cg) { _compiled_graphs.emplace(g, std::move(cg)); } @@ -101,7 +101,7 @@ void Mark::execute(RunContext&) { for (auto& g : _compiled_graphs) { - g.first->set_compiled_graph(std::move(g.second)); + g.second = g.first->swap_compiled_graph(std::move(g.second)); } } diff --git a/src/server/events/Mark.hpp b/src/server/events/Mark.hpp index ea130eda..eb99c5a9 100644 --- a/src/server/events/Mark.hpp +++ b/src/server/events/Mark.hpp @@ -20,13 +20,11 @@ #include "Event.hpp" #include "types.hpp" -// IWYU pragma: no_include "CompiledGraph.hpp" - -#include "raul/Maid.hpp" - #include <map> #include <memory> +// IWYU pragma: no_include "CompiledGraph.hpp" + namespace ingen { class Interface; @@ -75,8 +73,7 @@ public: private: enum class Type { BUNDLE_BEGIN, BUNDLE_END }; - using CompiledGraphs = - std::map<GraphImpl*, raul::managed_ptr<CompiledGraph>>; + using CompiledGraphs = std::map<GraphImpl*, std::unique_ptr<CompiledGraph>>; CompiledGraphs _compiled_graphs; Type _type; diff --git a/src/server/events/Move.cpp b/src/server/events/Move.cpp index ea05d34c..3af0ce6c 100644 --- a/src/server/events/Move.cpp +++ b/src/server/events/Move.cpp @@ -46,7 +46,7 @@ Move::Move(Engine& engine, bool Move::pre_process(PreProcessContext&) { - std::lock_guard<Store::Mutex> lock(_engine.store()->mutex()); + const std::lock_guard<Store::Mutex> lock{_engine.store()->mutex()}; if (!_msg.old_path.parent().is_parent_of(_msg.new_path)) { return Event::pre_process_done(Status::PARENT_DIFFERS, _msg.new_path); @@ -78,7 +78,7 @@ Move::execute(RunContext&) void Move::post_process() { - Broadcaster::Transfer t(*_engine.broadcaster()); + const Broadcaster::Transfer t{*_engine.broadcaster()}; if (respond() == Status::SUCCESS) { _engine.broadcaster()->message(_msg); } diff --git a/src/server/events/SetPortValue.cpp b/src/server/events/SetPortValue.cpp index 8b599354..04da7338 100644 --- a/src/server/events/SetPortValue.cpp +++ b/src/server/events/SetPortValue.cpp @@ -54,7 +54,7 @@ SetPortValue::SetPortValue(Engine& engine, bool SetPortValue::pre_process(PreProcessContext&) { - ingen::URIs& uris = _engine.world().uris(); + const ingen::URIs& uris = _engine.world().uris(); if (_port->is_output()) { return Event::pre_process_done(Status::DIRECTION_MISMATCH, _port->path()); } @@ -92,8 +92,8 @@ SetPortValue::apply(RunContext& ctx) return; } - ingen::URIs& uris = _engine.world().uris(); - Buffer* buf = _port->buffer(0).get(); + const ingen::URIs& uris = _engine.world().uris(); + Buffer* buf = _port->buffer(0).get(); if (_buffer) { if (_port->user_buffer(ctx)) { @@ -127,7 +127,7 @@ SetPortValue::apply(RunContext& ctx) void SetPortValue::post_process() { - Broadcaster::Transfer t(*_engine.broadcaster()); + const Broadcaster::Transfer t{*_engine.broadcaster()}; if (respond() == Status::SUCCESS && !_activity) { _engine.broadcaster()->set_property( _port->uri(), diff --git a/src/server/ingen_engine.cpp b/src/server/ingen_engine.cpp index fd4a8ced..db1794de 100644 --- a/src/server/ingen_engine.cpp +++ b/src/server/ingen_engine.cpp @@ -14,8 +14,6 @@ along with Ingen. If not, see <http://www.gnu.org/licenses/>. */ -// IWYU pragma: no_include "ingen/Atom.hpp" - #include "Engine.hpp" #include "util.hpp" @@ -24,6 +22,8 @@ #include <memory> +// IWYU pragma: no_include "ingen/Atom.hpp" + namespace ingen { struct EngineModule : public Module { diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp index 851a83fb..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" @@ -512,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,11 +532,11 @@ ingen_instantiate(const LV2_Descriptor* descriptor, 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) { @@ -567,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); @@ -580,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); @@ -602,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); @@ -703,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); @@ -713,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}); @@ -749,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*>( @@ -784,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); diff --git a/src/server/ingen_portaudio.cpp b/src/server/ingen_portaudio.cpp index 0199413f..6de5a40c 100644 --- a/src/server/ingen_portaudio.cpp +++ b/src/server/ingen_portaudio.cpp @@ -14,8 +14,6 @@ along with Ingen. If not, see <http://www.gnu.org/licenses/>. */ -// IWYU pragma: no_include "ingen/FilePath.hpp" - #include "Engine.hpp" #include "PortAudioDriver.hpp" @@ -25,6 +23,8 @@ #include <memory> +// IWYU pragma: no_include "ingen/FilePath.hpp" + namespace ingen::server { class Driver; diff --git a/src/server/internals/Controller.cpp b/src/server/internals/Controller.cpp index 898bd55b..ec400075 100644 --- a/src/server/internals/Controller.cpp +++ b/src/server/internals/Controller.cpp @@ -14,7 +14,6 @@ along with Ingen. If not, see <http://www.gnu.org/licenses/>. */ -#include "BlockImpl.hpp" #include "Buffer.hpp" #include "BufferFactory.hpp" #include "BufferRef.hpp" diff --git a/src/server/internals/Note.cpp b/src/server/internals/Note.cpp index dd202451..94598fb7 100644 --- a/src/server/internals/Note.cpp +++ b/src/server/internals/Note.cpp @@ -19,7 +19,6 @@ #include "BlockImpl.hpp" #include "Buffer.hpp" #include "BufferFactory.hpp" -#include "BufferRef.hpp" #include "InputPort.hpp" #include "InternalPlugin.hpp" #include "OutputPort.hpp" diff --git a/src/server/internals/Time.cpp b/src/server/internals/Time.cpp index ee97ac84..d8f1ddef 100644 --- a/src/server/internals/Time.cpp +++ b/src/server/internals/Time.cpp @@ -16,7 +16,6 @@ #include "internals/Time.hpp" -#include "BlockImpl.hpp" #include "Buffer.hpp" #include "BufferFactory.hpp" #include "BufferRef.hpp" @@ -72,8 +71,8 @@ TimeNode::TimeNode(InternalPlugin* plugin, void TimeNode::run(RunContext& ctx) { - BufferRef buf = _notify_port->buffer(0); - auto* seq = buf->get<LV2_Atom_Sequence>(); + const BufferRef buf = _notify_port->buffer(0); + auto* const 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 519b6d9f..9b3b8f98 100644 --- a/src/server/internals/Trigger.cpp +++ b/src/server/internals/Trigger.cpp @@ -16,7 +16,6 @@ #include "internals/Trigger.hpp" -#include "BlockImpl.hpp" #include "Buffer.hpp" #include "BufferFactory.hpp" #include "BufferRef.hpp" diff --git a/src/server/meson.build b/src/server/meson.build index c2e5b761..c1fccf5e 100644 --- a/src/server/meson.build +++ b/src/server/meson.build @@ -6,6 +6,25 @@ ########## server_sources = files( + 'events/Connect.cpp', + 'events/Copy.cpp', + 'events/CreateBlock.cpp', + 'events/CreateGraph.cpp', + 'events/CreatePort.cpp', + 'events/Delete.cpp', + 'events/Delta.cpp', + 'events/Disconnect.cpp', + 'events/DisconnectAll.cpp', + 'events/Get.cpp', + 'events/Mark.cpp', + 'events/Move.cpp', + 'events/SetPortValue.cpp', + 'events/Undo.cpp', + 'internals/BlockDelay.cpp', + 'internals/Controller.cpp', + 'internals/Note.cpp', + 'internals/Time.cpp', + 'internals/Trigger.cpp', 'ArcImpl.cpp', 'BlockFactory.cpp', 'BlockImpl.cpp', @@ -33,26 +52,7 @@ server_sources = files( 'Task.cpp', 'UndoStack.cpp', 'Worker.cpp', - 'events/Connect.cpp', - 'events/Copy.cpp', - 'events/CreateBlock.cpp', - 'events/CreateGraph.cpp', - 'events/CreatePort.cpp', - 'events/Delete.cpp', - 'events/Delta.cpp', - 'events/Disconnect.cpp', - 'events/DisconnectAll.cpp', - 'events/Get.cpp', - 'events/Mark.cpp', - 'events/Move.cpp', - 'events/SetPortValue.cpp', - 'events/Undo.cpp', 'ingen_engine.cpp', - 'internals/BlockDelay.cpp', - 'internals/Controller.cpp', - 'internals/Note.cpp', - 'internals/Time.cpp', - 'internals/Trigger.cpp', 'mix.cpp', ) |