1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
/*
* Copyright (C) 2017 Robin Gareus <robin@gareus.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "ardour_ui.h"
#include "dsp_load_gauge.h"
#include "ardour/audioengine.h"
#include "pbd/i18n.h"
#define PADDING 3
DspLoadGauge::DspLoadGauge ()
: ArdourGauge ("00.0%")
, _dsp_load (0)
, _xrun_count (0)
, _xrun_while_recording (false)
{
}
void
DspLoadGauge::set_xrun_count (const unsigned int xruns)
{
if (xruns == _xrun_count) {
return;
}
_xrun_count = xruns;
update ();
}
void
DspLoadGauge::set_dsp_load (const double load)
{
if (load == _dsp_load) {
return;
}
_dsp_load = load;
char buf[64];
if (_xrun_count > 0) {
snprintf (buf, sizeof (buf), "DSP: %.1f%% (%d)", _dsp_load, _xrun_count);
} else {
snprintf (buf, sizeof (buf), "DSP: %.1f%%", _dsp_load);
}
update (std::string (buf));
}
float
DspLoadGauge::level () const {
return (_dsp_load / 100.f);
}
bool
DspLoadGauge::alert () const
{
bool ret = false;
//xrun while recording
ret |= _xrun_while_recording;
//engine OFF
ret |= !ARDOUR::AudioEngine::instance()->running();
return ret;
}
ArdourGauge::Status
DspLoadGauge::indicator () const
{
if (_dsp_load > 90) {
return ArdourGauge::Level_CRIT;
} else if (_dsp_load > 75) {
return ArdourGauge::Level_WARN;
} else {
return ArdourGauge::Level_OK;
}
}
std::string
DspLoadGauge::tooltip_text ()
{
char buf[64];
//xruns
if (_xrun_count == UINT_MAX) {
snprintf (buf, sizeof (buf), _("DSP: %.1f%% X: ?\nClick to clear xruns."), _dsp_load);
} else if (_xrun_count > 9999) {
snprintf (buf, sizeof (buf), _("DSP: %.1f%% X: >10k\nClick to clear xruns."), _dsp_load);
} else {
snprintf (buf, sizeof (buf), _("DSP: %.1f%% X: %u\nClick to clear xruns."), _dsp_load, _xrun_count);
}
return buf;
}
bool
DspLoadGauge::on_button_release_event (GdkEventButton *ev)
{
ARDOUR::Session* s = ARDOUR_UI::instance ()->the_session ();
if (s) {
s->reset_xrun_count ();
_xrun_while_recording = false;
queue_draw();
}
return true;
}
|