From f062189c8219041fad45cfd340c367e5c4796933 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 19 Mar 2017 09:13:46 +0100 Subject: Shrink status bar text and fix initial DSP load display --- src/URIs.cpp | 3 +-- src/gui/App.cpp | 10 ++------- src/gui/App.hpp | 3 +-- src/server/Engine.cpp | 44 +++++++++++++++++------------------- src/server/Engine.hpp | 38 +++++-------------------------- src/server/Load.hpp | 57 +++++++++++++++++++++++++++++++++++++++++++++++ src/server/events/Get.cpp | 23 ++++++++++--------- 7 files changed, 101 insertions(+), 77 deletions(-) create mode 100644 src/server/Load.hpp (limited to 'src') diff --git a/src/URIs.cpp b/src/URIs.cpp index 1c0a6b23..47cf64c9 100644 --- a/src/URIs.cpp +++ b/src/URIs.cpp @@ -1,6 +1,6 @@ /* This file is part of Ingen. - Copyright 2007-2016 David Robillard + Copyright 2007-2017 David Robillard 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 @@ -101,7 +101,6 @@ URIs::URIs(Forge& f, URIMap* map, LilvWorld* lworld) , ingen_head (forge, map, lworld, INGEN__head) , ingen_incidentTo (forge, map, lworld, INGEN__incidentTo) , ingen_loadedBundle (forge, map, lworld, INGEN__loadedBundle) - , ingen_maxEventLoad (forge, map, lworld, INGEN__maxEventLoad) , ingen_maxRunLoad (forge, map, lworld, INGEN__maxRunLoad) , ingen_meanRunLoad (forge, map, lworld, INGEN__meanRunLoad) , ingen_minRunLoad (forge, map, lworld, INGEN__minRunLoad) diff --git a/src/gui/App.cpp b/src/gui/App.cpp index cc2ab74a..d303348a 100644 --- a/src/gui/App.cpp +++ b/src/gui/App.cpp @@ -1,6 +1,6 @@ /* This file is part of Ingen. - Copyright 2007-2016 David Robillard + Copyright 2007-2017 David Robillard 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 @@ -78,7 +78,6 @@ App::App(Ingen::World* world) , _sample_rate(48000) , _block_length(1024) , _n_threads(1) - , _max_event_load(0.0f) , _mean_run_load(0.0f) , _min_run_load(0.0f) , _max_run_load(0.0f) @@ -309,8 +308,6 @@ App::property_change(const Raul::URI& subject, _block_length = value.get(); } else if (key == uris().ingen_numThreads && value.type() == forge().Int) { _n_threads = value.get(); - } else if (key == uris().ingen_maxEventLoad && value.type() == forge().Float) { - _max_event_load = value.get(); } else if (key == uris().ingen_minRunLoad && value.type() == forge().Float) { _min_run_load = value.get(); } else if (key == uris().ingen_meanRunLoad && value.type() == forge().Float) { @@ -344,15 +341,12 @@ fraction_label(float f) std::string App::status_text() const { - return (fmt("Audio: %2.1f kHz / %.1f ms Load: %s events + %s DSP: %s ≤ %s ≤ %s") + return (fmt("%2.1f kHz / %.1f ms, %s, %s DSP") % (_sample_rate / 1e3f) % (_block_length * 1e3f / (float)_sample_rate) - % fraction_label(_max_event_load) % ((_n_threads == 1) ? "1 thread" : (fmt("%1% threads") % _n_threads).str()) - % fraction_label(_min_run_load) - % fraction_label(_mean_run_load) % fraction_label(_max_run_load)).str(); } diff --git a/src/gui/App.hpp b/src/gui/App.hpp index 3dc09ff9..4967513c 100644 --- a/src/gui/App.hpp +++ b/src/gui/App.hpp @@ -1,6 +1,6 @@ /* This file is part of Ingen. - Copyright 2007-2016 David Robillard + Copyright 2007-2017 David Robillard 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 @@ -171,7 +171,6 @@ protected: int32_t _sample_rate; int32_t _block_length; int32_t _n_threads; - float _max_event_load; float _mean_run_load; float _min_run_load; float _max_run_load; diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp index 647fa6e6..27ca83e4 100644 --- a/src/server/Engine.cpp +++ b/src/server/Engine.cpp @@ -330,29 +330,27 @@ Engine::quit() _quit_flag = true; } -bool -Engine::main_iteration() +Properties +Engine::load_properties() const { const Ingen::URIs& uris = world()->uris(); + return { { uris.ingen_meanRunLoad, + uris.forge.make(floorf(_run_load.mean) / 100.0f) }, + { uris.ingen_minRunLoad, + uris.forge.make(_run_load.min / 100.0f) }, + { uris.ingen_maxRunLoad, + uris.forge.make(_run_load.max / 100.0f) } }; +} + +bool +Engine::main_iteration() +{ _post_processor->process(); _maid->cleanup(); - if (_event_load.changed) { - _broadcaster->set_property(Raul::URI("ingen:/engine"), - uris.ingen_maxEventLoad, - uris.forge.make(_event_load.max / 100.0f)); - _event_load.changed = false; - } - if (_run_load.changed) { - _broadcaster->put(Raul::URI("ingen:/engine"), - { { uris.ingen_meanRunLoad, - uris.forge.make(floorf(_run_load.mean) / 100.0f) }, - { uris.ingen_minRunLoad, - uris.forge.make(_run_load.min / 100.0f) }, - { uris.ingen_maxRunLoad, - uris.forge.make(_run_load.max / 100.0f) } }); + _broadcaster->put(Raul::URI("ingen:/engine"), load_properties()); _run_load.changed = false; } @@ -472,7 +470,12 @@ Engine::run(uint32_t sample_count) // Process events that came in during the last cycle // (Aiming for jitter-free 1 block event latency, ideally) const unsigned n_processed_events = process_events(); - const uint64_t t_events = current_time(ctx); + + // Reset load if graph structure has changed + if (_reset_load_flag) { + _run_load = Load(); + _reset_load_flag = false; + } // Run root graph if (_root_graph) { @@ -490,12 +493,7 @@ Engine::run(uint32_t sample_count) // Update load for this cycle if (ctx.duration() > 0) { - _event_load.update(t_events - _cycle_start_time, ctx.duration()); - _run_load.update(current_time(ctx) - t_events, ctx.duration()); - if (_reset_load_flag) { - _run_load = Load(); - _reset_load_flag = false; - } + _run_load.update(current_time(ctx) - _cycle_start_time, ctx.duration()); } return n_processed_events; diff --git a/src/server/Engine.hpp b/src/server/Engine.hpp index 084e995d..9b0afc2f 100644 --- a/src/server/Engine.hpp +++ b/src/server/Engine.hpp @@ -1,6 +1,6 @@ /* This file is part of Ingen. - Copyright 2007-2016 David Robillard + Copyright 2007-2017 David Robillard 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 @@ -25,13 +25,15 @@ #include "ingen/Clock.hpp" #include "ingen/EngineBase.hpp" #include "ingen/Interface.hpp" +#include "ingen/Properties.hpp" #include "ingen/ingen.h" #include "ingen/types.hpp" #include "raul/Noncopyable.hpp" #include "Event.hpp" -#include "RunContext.hpp" #include "EventWriter.hpp" +#include "Load.hpp" +#include "RunContext.hpp" namespace Raul { class Maid; } @@ -165,38 +167,11 @@ public: bool atomic_bundles() const { return _atomic_bundles; } bool activated() const { return _activated; } + Properties load_properties() const; + private: Ingen::World* _world; - struct Load { - void update(uint64_t time, uint64_t available) { - const uint64_t load = time * 100 / available; - if (load < min) { - min = load; - changed = true; - } - if (load > max) { - max = load; - changed = true; - } - if (++n == 1) { - mean = load; - } else { - const float a = mean + ((float)load - mean) / (float)++n; - if (a != mean) { - changed = floorf(a) != floorf(mean); - mean = a; - } - } - } - - uint64_t min = std::numeric_limits::max(); - uint64_t max = 0; - float mean = 0.0f; - uint64_t n = 0; - bool changed = false; - }; - Raul::Maid* _maid; BlockFactory* _block_factory; Broadcaster* _broadcaster; @@ -219,7 +194,6 @@ private: std::vector _notifications; std::vector _run_contexts; uint64_t _cycle_start_time; - Load _event_load; Load _run_load; Clock _clock; diff --git a/src/server/Load.hpp b/src/server/Load.hpp new file mode 100644 index 00000000..ed9ee406 --- /dev/null +++ b/src/server/Load.hpp @@ -0,0 +1,57 @@ +/* + This file is part of Ingen. + Copyright 2007-2017 David Robillard + + 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 + Software Foundation, either version 3 of the License, or any later version. + + Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Affero General Public License for details. + + You should have received a copy of the GNU Affero General Public License + along with Ingen. If not, see . +*/ + +#ifndef INGEN_ENGINE_LOAD_HPP +#define INGEN_ENGINE_LOAD_HPP + +namespace Ingen { +namespace Server { + +struct Load +{ + void update(uint64_t time, uint64_t available) { + const uint64_t load = time * 100 / available; + if (load < min) { + min = load; + changed = true; + } + if (load > max) { + max = load; + changed = true; + } + if (++n == 1) { + mean = load; + changed = true; + } else { + const float a = mean + ((float)load - mean) / (float)++n; + if (a != mean) { + changed = floorf(a) != floorf(mean); + mean = a; + } + } + } + + uint64_t min = std::numeric_limits::max(); + uint64_t max = 0; + float mean = 0.0f; + uint64_t n = 0; + bool changed = false; +}; + +} // namespace Server +} // namespace Ingen + +#endif // INGEN_ENGINE_LOAD_HPP diff --git a/src/server/events/Get.cpp b/src/server/events/Get.cpp index 5988f0e0..7bc2cb6f 100644 --- a/src/server/events/Get.cpp +++ b/src/server/events/Get.cpp @@ -1,6 +1,6 @@ /* This file is part of Ingen. - Copyright 2007-2016 David Robillard + Copyright 2007-2017 David Robillard 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 @@ -88,15 +88,18 @@ Get::post_process() _engine.broadcaster()->send_plugins_to(_request_client.get(), _plugins); } else if (_uri == "ingen:/engine") { // TODO: Keep a proper RDF model of the engine - URIs& uris = _engine.world()->uris(); - _request_client->put( - Raul::URI("ingen:/engine"), - { { uris.param_sampleRate, - uris.forge.make(int32_t(_engine.sample_rate())) }, - { uris.bufsz_maxBlockLength, - uris.forge.make(int32_t(_engine.block_length())) }, - { uris.ingen_numThreads, - uris.forge.make(int32_t(_engine.n_threads())) } }); + URIs& uris = _engine.world()->uris(); + Properties props = { + { uris.param_sampleRate, + uris.forge.make(int32_t(_engine.sample_rate())) }, + { uris.bufsz_maxBlockLength, + uris.forge.make(int32_t(_engine.block_length())) }, + { uris.ingen_numThreads, + uris.forge.make(int32_t(_engine.n_threads())) } }; + + const Properties load_props = _engine.load_properties(); + props.insert(load_props.begin(), load_props.end()); + _request_client->put(Raul::URI("ingen:/engine"), props); } else { _response.send(_request_client.get()); } -- cgit v1.2.1