From d3561e8cf1d5a289ff2ce4a26e4a970437a812d5 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 29 Nov 2020 16:55:25 +0100 Subject: Remove flaky DSP load meter This never worked particularly well, and the underlying API is more or less useless with Jack 2. So, just replace it with a dropout counter. --- src/JackDbusDriver.cpp | 47 -------------------------- src/JackDbusDriver.hpp | 3 -- src/JackDriver.cpp | 34 +------------------ src/JackDriver.hpp | 3 -- src/Patchage.cpp | 21 ++++++++---- src/Patchage.hpp | 3 +- src/patchage.ui | 89 ++++++++++++++++++-------------------------------- 7 files changed, 47 insertions(+), 153 deletions(-) (limited to 'src') diff --git a/src/JackDbusDriver.cpp b/src/JackDbusDriver.cpp index d3caee3..4ab7b8c 100644 --- a/src/JackDbusDriver.cpp +++ b/src/JackDbusDriver.cpp @@ -59,7 +59,6 @@ JackDriver::JackDriver(ILog& log, EventSink emit_event) , _log(log) , _dbus_error() , _dbus_connection(nullptr) - , _max_dsp_load(0.0f) , _server_responding(false) , _server_started(false) , _graph_version(0) @@ -859,52 +858,6 @@ JackDriver::reset_xruns() dbus_message_unref(reply_ptr); } -float -JackDriver::get_max_dsp_load() -{ - DBusMessage* reply_ptr = nullptr; - double load = 0.0; - - if (_server_responding && !_server_started) { - return 0.0; - } - - if (!call(true, - JACKDBUS_IFACE_CONTROL, - "GetLoad", - &reply_ptr, - DBUS_TYPE_INVALID)) { - return 0.0; - } - - if (!dbus_message_get_args(reply_ptr, - &_dbus_error, - DBUS_TYPE_DOUBLE, - &load, - DBUS_TYPE_INVALID)) { - dbus_message_unref(reply_ptr); - dbus_error_free(&_dbus_error); - error_msg("Decoding reply of GetLoad failed"); - return 0.0; - } - - dbus_message_unref(reply_ptr); - - load /= 100.0; // convert from percent to [0..1] - - if (load > static_cast(_max_dsp_load)) { - _max_dsp_load = static_cast(load); - } - - return _max_dsp_load; -} - -void -JackDriver::reset_max_dsp_load() -{ - _max_dsp_load = 0.0; -} - PortType JackDriver::patchage_port_type(const dbus_uint32_t dbus_port_type) const { diff --git a/src/JackDbusDriver.hpp b/src/JackDbusDriver.hpp index 99bd791..42c70ef 100644 --- a/src/JackDbusDriver.hpp +++ b/src/JackDbusDriver.hpp @@ -54,8 +54,6 @@ public: uint32_t get_xruns(); void reset_xruns(); - float get_max_dsp_load(); - void reset_max_dsp_load(); float sample_rate(); uint32_t buffer_size(); @@ -97,7 +95,6 @@ private: ILog& _log; DBusError _dbus_error; DBusConnection* _dbus_connection; - float _max_dsp_load; bool _server_responding; bool _server_started; diff --git a/src/JackDriver.cpp b/src/JackDriver.cpp index aca6b65..b30d45f 100644 --- a/src/JackDriver.cpp +++ b/src/JackDriver.cpp @@ -359,9 +359,6 @@ JackDriver::jack_xrun_cb(void* const jack_driver) auto* const me = static_cast(jack_driver); ++me->_xruns; - me->_xrun_delay = jack_get_xrun_delayed_usecs(me->_client); - - jack_reset_max_delayed_usecs(me->_client); return 0; } @@ -388,36 +385,7 @@ JackDriver::buffer_size() void JackDriver::reset_xruns() { - _xruns = 0; - _xrun_delay = 0; -} - -float -JackDriver::get_max_dsp_load() -{ - if (!_client) { - return 0.0f; - } - - const float max_delay = jack_get_max_delayed_usecs(_client); - const float rate = sample_rate(); - const float size = buffer_size(); - const float period = size / rate * 1000000; // usec - - if (max_delay > period) { - jack_reset_max_delayed_usecs(_client); - return 1.0f; - } - - return max_delay / period; -} - -void -JackDriver::reset_max_dsp_load() -{ - if (_client) { - jack_reset_max_delayed_usecs(_client); - } + _xruns = 0; } bool diff --git a/src/JackDriver.hpp b/src/JackDriver.hpp index f3fcaf0..d93b491 100644 --- a/src/JackDriver.hpp +++ b/src/JackDriver.hpp @@ -56,8 +56,6 @@ public: uint32_t get_xruns() const { return _xruns; } void reset_xruns(); - float get_max_dsp_load(); - void reset_max_dsp_load(); uint32_t sample_rate() { return jack_get_sample_rate(_client); } uint32_t buffer_size(); @@ -92,7 +90,6 @@ private: jack_client_t* _client = nullptr; jack_nframes_t _buffer_size = 0u; uint32_t _xruns = 0u; - float _xrun_delay = 0.0f; bool _is_activated : 1; }; diff --git a/src/Patchage.cpp b/src/Patchage.cpp index 01eda37..7ce1f07 100644 --- a/src/Patchage.cpp +++ b/src/Patchage.cpp @@ -154,7 +154,7 @@ Patchage::Patchage(Options options) , INIT_WIDGET(_menu_normal_font_size) , INIT_WIDGET(_toolbar) , INIT_WIDGET(_clear_load_but) - , INIT_WIDGET(_xrun_progress) + , INIT_WIDGET(_dropouts_label) , INIT_WIDGET(_buf_size_combo) , INIT_WIDGET(_latency_label) , INIT_WIDGET(_legend_alignment) @@ -430,10 +430,16 @@ Patchage::update_load() { #if defined(PATCHAGE_LIBJACK) || defined(HAVE_JACK_DBUS) if (_jack_driver->is_attached()) { - char buf[8]; - snprintf(buf, sizeof(buf), "%u", _jack_driver->get_xruns()); - _xrun_progress->set_text(std::string(buf) + " Dropouts"); - _xrun_progress->set_fraction(_jack_driver->get_max_dsp_load()); + const auto xruns = _jack_driver->get_xruns(); + if (xruns > 0u) { + _dropouts_label->set_text(fmt::format(" Dropouts: {}", xruns)); + _dropouts_label->show(); + _clear_load_but->show(); + } else { + _dropouts_label->set_text(" Dropouts: 0"); + _dropouts_label->hide(); + _clear_load_but->hide(); + } } #endif @@ -549,9 +555,10 @@ void Patchage::clear_load() { #if defined(PATCHAGE_LIBJACK) || defined(HAVE_JACK_DBUS) - _xrun_progress->set_fraction(0.0); + _dropouts_label->set_text(" Dropouts: 0"); + _dropouts_label->hide(); + _clear_load_but->hide(); _jack_driver->reset_xruns(); - _jack_driver->reset_max_dsp_load(); #endif } diff --git a/src/Patchage.hpp b/src/Patchage.hpp index a6cfec0..c48ff05 100644 --- a/src/Patchage.hpp +++ b/src/Patchage.hpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -195,7 +194,7 @@ protected: Widget _menu_normal_font_size; Widget _toolbar; Widget _clear_load_but; - Widget _xrun_progress; + Widget _dropouts_label; Widget _buf_size_combo; Widget _latency_label; Widget _legend_alignment; diff --git a/src/patchage.ui b/src/patchage.ui index b82cb44..d86fb80 100644 --- a/src/patchage.ui +++ b/src/patchage.ui @@ -329,51 +329,6 @@ False 1 True - - - True - False - True - Clear the dropout indicator - Clear dropout indicator. - gtk-clear - - - False - True - - - - - True - False - - - True - False - 0 - - - True - False - True - Drouput (XRun) Indicator - -The bar represents the percentage of available time used for audio processing (i.e. the DSP load). If the bar reaches 100%, a dropout will occur. - Load and dropout gauge. The bar shows the percentage of available time used for audio processing. If it reaches 100%, a dropout will occur. - True - 0.10000000149 - 0 Dropouts - 100 - - - - - - - False - - True @@ -389,25 +344,13 @@ The bar represents the percentage of available time used for audio processing (i True False - - - True - False - / - - - False - False - 0 - - True True True Jack buffer length in frames - Jack buffer length in frames + Jack buffer length in frames. 1 @@ -437,6 +380,36 @@ The bar represents the percentage of available time used for audio processing (i False + + + True + False + + + False + False + Dropouts: 0 + + + + + False + + + + + False + False + True + Clear the dropout indicator + Clear dropout indicator. + gtk-clear + + + False + True + + True -- cgit v1.2.1