[Summary] Show HD usage and remained time. Pixel hunting.

[Reviewed] GZharun
This commit is contained in:
nikolay 2014-08-20 14:10:16 +03:00
parent 8a6be6cb75
commit c84f46fe68
6 changed files with 113 additions and 8 deletions

View file

@ -208,7 +208,11 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir)
, error_log_button (_("Errors"))
, _status_bar_visibility (X_("status-bar"))
, _feedback_exists (false)
, _dsp_load_adjustment (0)
, _dsp_load_adjustment (0)
, _hd_load_adjustment (0)
, _dsp_load_label(0)
, _hd_load_label(0)
, _hd_remained_time_label(0)
, editor (0)
, mixer (0)
//, meterbridge (0)
@ -431,6 +435,7 @@ ARDOUR_UI::engine_running ()
}
update_disk_space ();
update_disk_usage ();
update_cpu_load ();
update_sample_rate (EngineStateController::instance()->get_current_sample_rate() );
update_timecode_format ();
@ -1085,6 +1090,7 @@ ARDOUR_UI::every_second ()
update_cpu_load ();
update_buffer_load ();
update_disk_space ();
update_disk_usage ();
update_timecode_format ();
if (nsm && nsm->is_active ()) {
@ -1229,6 +1235,10 @@ ARDOUR_UI::update_cpu_load ()
snprintf (buf, sizeof (buf), _("DSP: <span foreground=\"%s\">%5.1f%%</span>"), c >= 90 ? X_("red") : X_("green"), c);
cpu_load_label.set_markup (buf);
_dsp_load_adjustment->set_value (c);
stringstream ss;
ss << (int)c;
_dsp_load_label->set_text ( ss.str() + "%" );
}
void
@ -1272,6 +1282,8 @@ ARDOUR_UI::count_recenabled_streams (Route& route)
void
ARDOUR_UI::update_disk_space()
{
string result;
if (_session == 0) {
return;
}
@ -1288,9 +1300,11 @@ ARDOUR_UI::update_disk_space()
if (!opt_frames) {
/* Available space is unknown */
snprintf (buf, sizeof (buf), "%s", _("Disk: <span foreground=\"green\">Unknown</span>"));
result = "Unknown";
} else if (opt_frames.get_value_or (0) == max_framecnt) {
snprintf (buf, sizeof (buf), "%s", _("Disk: <span foreground=\"green\">24hrs+</span>"));
} else {
result = "24hrs+";
} else {
rec_enabled_streams = 0;
_session->foreach_route (this, &ARDOUR_UI::count_recenabled_streams);
@ -1298,7 +1312,9 @@ ARDOUR_UI::update_disk_space()
if (rec_enabled_streams) {
frames /= rec_enabled_streams;
}
} else {
frames /= _session->nroutes ();
}
int hrs;
int mins;
@ -1308,7 +1324,8 @@ ARDOUR_UI::update_disk_space()
if (hrs > 24) {
snprintf (buf, sizeof (buf), "%s", _("Disk: <span foreground=\"green\">&gt;24 hrs</span>"));
} else {
result =">24hrs";
} else {
frames -= hrs * fr * 3600;
mins = frames / (fr * 60);
frames -= mins * fr * 60;
@ -1322,10 +1339,29 @@ ARDOUR_UI::update_disk_space()
low ? X_("red") : X_("green"),
hrs, mins, secs
);
stringstream ss;
ss << hrs << "h " << mins << "m ";
result = ss.str();
}
}
disk_space_label.set_markup (buf);
_hd_remained_time_label->set_text(result);
}
void
ARDOUR_UI::update_disk_usage ()
{
if (_session == 0) {
return;
}
int disk_usage_percentage = _session->get_disk_usage_percentage ();
_hd_load_adjustment->set_value (disk_usage_percentage);
stringstream ss;
ss << disk_usage_percentage;
_hd_load_label->set_text ( ss.str() + "%" );
}
void
@ -2198,6 +2234,7 @@ ARDOUR_UI::map_transport_state ()
editor->get_waves_button ("transport_loop_button").set_active (false);
}
update_disk_space ();
update_disk_usage ();
}
}
@ -2938,7 +2975,7 @@ ARDOUR_UI::get_session_parameters (bool quit_on_cancel, bool should_be_new, stri
continue;
}
int pos = full_session_name.rfind(suffix);
size_t pos = full_session_name.rfind(suffix);
// if not *.ardour file was choosen
if( !(pos == full_session_name.size() - suffix.size()) )

View file

@ -544,6 +544,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
Gtk::Label disk_space_label;
void update_disk_space ();
void update_disk_usage ();
Gtk::Label timecode_format_label;
@ -760,6 +761,10 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
VisibilityGroup _status_bar_visibility;
Gtk::Adjustment* _dsp_load_adjustment;
Gtk::Adjustment* _hd_load_adjustment;
Gtk::Label* _dsp_load_label;
Gtk::Label* _hd_load_label;
Gtk::Label* _hd_remained_time_label;
/** A ProcessThread so that we have some thread-local buffers for use by
* PluginEqGui::impulse_analysis ().

View file

@ -81,6 +81,11 @@ ARDOUR_UI::create_editor ()
try {
editor = new Editor ();
_dsp_load_adjustment = &editor->get_adjustment ("dsp_load_adjustment");
_hd_load_adjustment = &editor->get_adjustment("hd_load_adjustment");
_dsp_load_label = &editor->get_label("dsp_load_label");
_hd_load_label = &editor->get_label("hd_load_label");
_hd_remained_time_label = &editor->get_label("hd_remained_time");
}
catch (failed_constructor& err) {

View file

@ -42,7 +42,8 @@
x="132"
y="6"/>
</Layout>
<Layout box.pack="end" width="114">
<Layout box.pack="end" width="114" height="51">
<icon source="metrics_display.png"/>
<Adjustment id="dsp_load_adjustment"
minvalue="1"
maxvalue="100"
@ -57,9 +58,50 @@
maxposy="3"
readonly="true"
x="28"
y="8"
width="56"
height="5"/>
<Label id="dsp_load_label"
style="generic_control"
text="%"
fgnormal="#ffffff"
winfont ="Arial 8"
macfont ="Helvetica 8"
x="87"
y="8"/>
<icon source="metrics_display.png"
tooltip="--------------------&#xA;This is a mockup&#xA;--------------------"/>
<Adjustment id="hd_load_adjustment"
minvalue="1"
maxvalue="100"
initialvalue="50"
readonly="fals"/>
<Fader adjustment="hd_load_adjustment"
facesource="dsp_load_fader_face.png"
handlesource="dsp_load_fader_handle.png"
minposx="0"
minposy="3"
maxposx="78"
maxposy="3"
readonly="true"
x="28"
y="18"
width="56"
height="5"/>
<Label id="hd_load_label"
style="generic_control"
text="%"
fgnormal="#ffffff"
winfont ="Arial 8"
macfont ="Helvetica 8"
x="87"
y="18"/>
<Label id="hd_remained_time"
style="generic_control"
fgnormal="#ffffff"
winfont ="Arial 8"
macfont ="Helvetica 8"
x="58"
y="33"/>
</Layout>
<EventBox bgnormal="#383838"
width="420"

View file

@ -220,6 +220,7 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
void butler_transport_work ();
void refresh_disk_space ();
float get_disk_usage_percentage();
int load_diskstreams_2X (XMLNode const &, int);

View file

@ -2110,6 +2110,21 @@ Session::refresh_disk_space ()
#endif
}
float
Session::get_disk_usage_percentage ()
{
#if __APPLE__ || (HAVE_SYS_VFS_H && HAVE_SYS_STATVFS_H)
vector<space_and_path>::iterator i = session_dirs.begin();
struct statfs statfsbuf;
statfs (i->path.c_str(), &statfsbuf);
return 100 - (statfsbuf.f_bfree * 100.0)/(statfsbuf.f_blocks);
#elif
return -1;
#endif
}
string
Session::get_best_session_directory_for_new_source ()
{