summaryrefslogtreecommitdiffstats
path: root/src/server
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2017-03-19 09:13:46 +0100
committerDavid Robillard <d@drobilla.net>2017-03-19 09:13:46 +0100
commitf062189c8219041fad45cfd340c367e5c4796933 (patch)
tree346222e8dc724e2a1d8ebc2a3aacc2bb1d8b4698 /src/server
parent1a31907d1ad2e9c8ed0cdced09e81f7a7ec07504 (diff)
downloadingen-f062189c8219041fad45cfd340c367e5c4796933.tar.gz
ingen-f062189c8219041fad45cfd340c367e5c4796933.tar.bz2
ingen-f062189c8219041fad45cfd340c367e5c4796933.zip
Shrink status bar text and fix initial DSP load display
Diffstat (limited to 'src/server')
-rw-r--r--src/server/Engine.cpp44
-rw-r--r--src/server/Engine.hpp38
-rw-r--r--src/server/Load.hpp57
-rw-r--r--src/server/events/Get.cpp23
4 files changed, 97 insertions, 65 deletions
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 <http://drobilla.net/>
+ Copyright 2007-2017 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
@@ -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<uint64_t>::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<Raul::RingBuffer*> _notifications;
std::vector<RunContext*> _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 <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
+ 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 <http://www.gnu.org/licenses/>.
+*/
+
+#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<uint64_t>::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 <http://drobilla.net/>
+ Copyright 2007-2017 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
@@ -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());
}