diff options
Diffstat (limited to 'src/server/Engine.cpp')
-rw-r--r-- | src/server/Engine.cpp | 94 |
1 files changed, 45 insertions, 49 deletions
diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp index c72d98df..4d753bbc 100644 --- a/src/server/Engine.cpp +++ b/src/server/Engine.cpp @@ -1,6 +1,6 @@ /* This file is part of Ingen. - Copyright 2007-2017 David Robillard <http://drobilla.net/> + Copyright 2007-2024 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 @@ -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" @@ -39,31 +38,32 @@ #include "events/CreateGraph.hpp" #include "ingen_config.h" -#ifdef HAVE_SOCKET +#if USE_SOCKET #include "SocketListener.hpp" #endif -#include "ingen/Atom.hpp" -#include "ingen/AtomReader.hpp" -#include "ingen/ColorContext.hpp" -#include "ingen/Configuration.hpp" -#include "ingen/Forge.hpp" -#include "ingen/Interface.hpp" -#include "ingen/LV2Features.hpp" -#include "ingen/Log.hpp" -#include "ingen/Resource.hpp" -#include "ingen/Store.hpp" -#include "ingen/StreamWriter.hpp" -#include "ingen/Tee.hpp" -#include "ingen/URI.hpp" -#include "ingen/URIs.hpp" -#include "ingen/World.hpp" -#include "ingen/memory.hpp" -#include "lv2/buf-size/buf-size.h" -#include "lv2/state/state.h" -#include "raul/Maid.hpp" -#include "raul/Path.hpp" -#include "raul/RingBuffer.hpp" +#include <ingen/Atom.hpp> +#include <ingen/AtomReader.hpp> +#include <ingen/Clock.hpp> +#include <ingen/ColorContext.hpp> +#include <ingen/Configuration.hpp> +#include <ingen/Forge.hpp> +#include <ingen/Interface.hpp> +#include <ingen/LV2Features.hpp> +#include <ingen/Log.hpp> +#include <ingen/Properties.hpp> +#include <ingen/Resource.hpp> +#include <ingen/Store.hpp> +#include <ingen/StreamWriter.hpp> +#include <ingen/Tee.hpp> +#include <ingen/URI.hpp> +#include <ingen/URIs.hpp> +#include <ingen/World.hpp> +#include <lv2/buf-size/buf-size.h> +#include <lv2/state/state.h> +#include <raul/Maid.hpp> +#include <raul/Path.hpp> +#include <raul/RingBuffer.hpp> #include <algorithm> #include <cmath> @@ -72,11 +72,11 @@ #include <limits> #include <map> #include <memory> +#include <string> #include <thread> #include <utility> -namespace ingen { -namespace server { +namespace ingen::server { thread_local unsigned ThreadManager::flags(0); bool ThreadManager::single_threaded(true); @@ -99,25 +99,22 @@ Engine::Engine(ingen::World& world) , _interface(_event_writer) , _atom_interface( new AtomReader(world.uri_map(), world.uris(), world.log(), *_interface)) - , _root_graph(nullptr) - , _cycle_start_time(0) , _rand_engine(reinterpret_cast<uintptr_t>(this)) - , _uniform_dist(0.0f, 1.0f) - , _quit_flag(false) - , _reset_load_flag(false) , _atomic_bundles(world.conf().option("atomic-bundles").get<int32_t>()) - , _activated(false) { if (!world.store()) { world.set_store(std::make_shared<ingen::Store>()); } for (int i = 0; i < world.conf().option("threads").get<int32_t>(); ++i) { + const bool is_threaded = (i > 0); _notifications.emplace_back( - make_unique<raul::RingBuffer>(uint32_t(24 * event_queue_size()))); + std::make_unique<raul::RingBuffer>(24U * event_queue_size())); _run_contexts.emplace_back( - make_unique<RunContext>( - *this, _notifications.back().get(), unsigned(i), i > 0)); + std::make_unique<RunContext>(*this, + _notifications.back().get(), + static_cast<unsigned>(i), + is_threaded)); } _world.lv2_features().add_feature(_worker->schedule_feature()); @@ -188,8 +185,8 @@ Engine::~Engine() void Engine::listen() { -#ifdef HAVE_SOCKET - _listener = make_unique<SocketListener>(*this); +#if USE_SOCKET + _listener = std::make_unique<SocketListener>(*this); #endif } @@ -245,12 +242,11 @@ Engine::emit_notifications(FrameTime end) bool Engine::pending_notifications() { - for (const auto& ctx : _run_contexts) { - if (ctx->pending_notifications()) { - return true; - } - } - return false; + return std::any_of(_run_contexts.begin(), + _run_contexts.end(), + [](const auto& ctx) { + return ctx->pending_notifications(); + }); } bool @@ -304,16 +300,17 @@ Engine::block_length() const return _driver->block_length(); } -size_t +uint32_t Engine::sequence_size() const { return _driver->seq_size(); } -size_t +uint32_t Engine::event_queue_size() const { - return _world.conf().option("queue-size").get<int32_t>(); + return static_cast<uint32_t>( + std::max(0, _world.conf().option("queue-size").get<int32_t>())); } void @@ -387,7 +384,7 @@ Engine::reset_load() } void -Engine::init(double sample_rate, uint32_t block_length, size_t seq_size) +Engine::init(double sample_rate, uint32_t block_length, uint32_t seq_size) { set_driver(std::make_shared<DirectDriver>( *this, sample_rate, block_length, seq_size)); @@ -538,5 +535,4 @@ Engine::unregister_client(const std::shared_ptr<Interface>& client) return _broadcaster->unregister_client(client); } -} // namespace server -} // namespace ingen +} // namespace ingen::server |