diff options
author | David Robillard <d@drobilla.net> | 2020-11-29 16:55:25 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-11-29 18:03:31 +0100 |
commit | d3561e8cf1d5a289ff2ce4a26e4a970437a812d5 (patch) | |
tree | 2383de628f8f1afe820fdd81dd5780f585f93717 /src | |
parent | 86ce5ca10998fbeb3e9841cb2307caf00373b946 (diff) | |
download | patchage-d3561e8cf1d5a289ff2ce4a26e4a970437a812d5.tar.gz patchage-d3561e8cf1d5a289ff2ce4a26e4a970437a812d5.tar.bz2 patchage-d3561e8cf1d5a289ff2ce4a26e4a970437a812d5.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/JackDbusDriver.cpp | 47 | ||||
-rw-r--r-- | src/JackDbusDriver.hpp | 3 | ||||
-rw-r--r-- | src/JackDriver.cpp | 34 | ||||
-rw-r--r-- | src/JackDriver.hpp | 3 | ||||
-rw-r--r-- | src/Patchage.cpp | 21 | ||||
-rw-r--r-- | src/Patchage.hpp | 3 | ||||
-rw-r--r-- | src/patchage.ui | 89 |
7 files changed, 47 insertions, 153 deletions
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<double>(_max_dsp_load)) { - _max_dsp_load = static_cast<float>(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<JackDriver*>(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 <gtkmm/menubar.h> #include <gtkmm/menuitem.h> #include <gtkmm/paned.h> -#include <gtkmm/progressbar.h> #include <gtkmm/scrolledwindow.h> #include <gtkmm/textview.h> #include <gtkmm/toolbar.h> @@ -195,7 +194,7 @@ protected: Widget<Gtk::MenuItem> _menu_normal_font_size; Widget<Gtk::Toolbar> _toolbar; Widget<Gtk::ToolButton> _clear_load_but; - Widget<Gtk::ProgressBar> _xrun_progress; + Widget<Gtk::Label> _dropouts_label; Widget<Gtk::ComboBox> _buf_size_combo; Widget<Gtk::Label> _latency_label; Widget<Gtk::Alignment> _legend_alignment; diff --git a/src/patchage.ui b/src/patchage.ui index b82cb44..d86fb80 100644 --- a/src/patchage.ui +++ b/src/patchage.ui @@ -330,51 +330,6 @@ <property name="icon_size">1</property> <property name="icon_size_set">True</property> <child> - <object class="GtkToolButton" id="clear_load_but"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="has_tooltip">True</property> - <property name="tooltip_markup">Clear the dropout indicator</property> - <property name="tooltip_text" translatable="yes">Clear dropout indicator.</property> - <property name="stock_id">gtk-clear</property> - </object> - <packing> - <property name="expand">False</property> - <property name="homogeneous">True</property> - </packing> - </child> - <child> - <object class="GtkToolItem" id="toolitem30"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <child> - <object class="GtkAlignment" id="alignment3"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="yscale">0</property> - <child> - <object class="GtkProgressBar" id="xrun_progress"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="has_tooltip">True</property> - <property name="tooltip_markup">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.</property> - <property name="tooltip_text" translatable="yes">Load and dropout gauge. The bar shows the percentage of available time used for audio processing. If it reaches 100%, a dropout will occur.</property> - <property name="show_text">True</property> - <property name="pulse_step">0.10000000149</property> - <property name="text" translatable="yes">0 Dropouts</property> - <property name="discrete_blocks">100</property> - </object> - </child> - </object> - </child> - </object> - <packing> - <property name="expand">False</property> - </packing> - </child> - <child> <object class="GtkToolItem" id="toolitem28"> <property name="visible">True</property> <property name="can_focus">False</property> @@ -390,24 +345,12 @@ The bar represents the percentage of available time used for audio processing (i <property name="visible">True</property> <property name="can_focus">False</property> <child> - <object class="GtkLabel" id="label10"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes"> / </property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> - </packing> - </child> - <child> <object class="GtkComboBox" id="buf_size_combo"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="has_tooltip">True</property> <property name="tooltip_markup">Jack buffer length in frames</property> - <property name="tooltip_text" translatable="yes">Jack buffer length in frames</property> + <property name="tooltip_text" translatable="yes">Jack buffer length in frames.</property> <property name="border_width">1</property> </object> <packing> @@ -438,6 +381,36 @@ The bar represents the percentage of available time used for audio processing (i </packing> </child> <child> + <object class="GtkToolItem" id="toolitem30"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkLabel" id="dropouts_label"> + <property name="can_focus">False</property> + <property name="visible">False</property> + <property name="label" translatable="yes"> Dropouts: 0</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + </packing> + </child> + <child> + <object class="GtkToolButton" id="clear_load_but"> + <property name="visible">False</property> + <property name="can_focus">False</property> + <property name="has_tooltip">True</property> + <property name="tooltip_markup">Clear the dropout indicator</property> + <property name="tooltip_text" translatable="yes">Clear dropout indicator.</property> + <property name="stock_id">gtk-clear</property> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + <child> <object class="GtkToolItem" id="toolitem1"> <property name="visible">True</property> <property name="can_focus">False</property> |