2 * Copyright (C) 2017 Robin Gareus <robin@gareus.org>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #include "ardour_ui.h"
20 #include "dsp_load_gauge.h"
22 #include "ardour/audioengine.h"
28 DspLoadGauge::DspLoadGauge ()
32 , _xrun_while_recording (false)
37 DspLoadGauge::set_xrun_count (const unsigned int xruns)
39 if (xruns == _xrun_count) {
47 DspLoadGauge::set_dsp_load (const double load)
49 if (load == _dsp_load) {
55 if (_xrun_count > 0) {
56 snprintf (buf, sizeof (buf), "DSP: %.1f%% (%d)", _dsp_load, _xrun_count);
58 snprintf (buf, sizeof (buf), "DSP: %.1f%%", _dsp_load);
60 update (std::string (buf));
64 DspLoadGauge::level () const {
65 return (_dsp_load / 100.f);
69 DspLoadGauge::alert () const
73 //xrun while recording
74 ret |= _xrun_while_recording;
77 ret |= !ARDOUR::AudioEngine::instance()->running();
83 DspLoadGauge::indicator () const
86 return ArdourGauge::Level_CRIT;
87 } else if (_dsp_load > 75) {
88 return ArdourGauge::Level_WARN;
90 return ArdourGauge::Level_OK;
95 DspLoadGauge::tooltip_text ()
100 if (_xrun_count == UINT_MAX) {
101 snprintf (buf, sizeof (buf), _("DSP: %.1f%% X: ?\nClick to clear xruns."), _dsp_load);
102 } else if (_xrun_count > 9999) {
103 snprintf (buf, sizeof (buf), _("DSP: %.1f%% X: >10k\nClick to clear xruns."), _dsp_load);
105 snprintf (buf, sizeof (buf), _("DSP: %.1f%% X: %u\nClick to clear xruns."), _dsp_load, _xrun_count);
112 DspLoadGauge::on_button_release_event (GdkEventButton *ev)
114 ARDOUR::Session* s = ARDOUR_UI::instance ()->the_session ();
116 s->reset_xrun_count ();
117 _xrun_while_recording = false;