add xrun counter to status-bar (currently no reset)
authorRobin Gareus <robin@gareus.org>
Wed, 29 Apr 2015 01:10:27 +0000 (03:10 +0200)
committerRobin Gareus <robin@gareus.org>
Wed, 29 Apr 2015 01:10:27 +0000 (03:10 +0200)
gtk2_ardour/ardour_ui.cc
gtk2_ardour/ardour_ui.h
gtk2_ardour/ardour_ui_ed.cc

index 5a91bc6dfcae11805718e1cc06977fce1a1b7d6b..2f38aec72f1b317ced33c7040d27ea37d9782e3a 100644 (file)
@@ -434,8 +434,12 @@ ARDOUR_UI::engine_running ()
                first_time_engine_run = false;
        } 
        
+       if (_session) {
+               _session->reset_xrun_count ();
+       }
        update_disk_space ();
        update_cpu_load ();
+       update_xrun_count ();
        update_sample_rate (AudioEngine::instance()->sample_rate());
        update_timecode_format ();
 }
@@ -1179,6 +1183,7 @@ void
 ARDOUR_UI::every_second ()
 {
        update_cpu_load ();
+       update_xrun_count ();
        update_buffer_load ();
        update_disk_space ();
        update_timecode_format ();
@@ -1348,6 +1353,28 @@ ARDOUR_UI::update_cpu_load ()
           should also be changed.
        */
 
+       if (_session) {
+               const unsigned int x = _session->get_xrun_count ();
+               if (x > 9999) {
+                       snprintf (buf, sizeof (buf), _("X: <span foreground=\"%s\">&gt;10K</span>"), X_("red"));
+               } else {
+                       snprintf (buf, sizeof (buf), _("X: <span foreground=\"%s\">%u</span>"), x > 0 ? X_("red") : X_("green"), x);
+               }
+       } else {
+               snprintf (buf, sizeof (buf), _("X: <span foreground=\"%s\">?</span>"), X_("yellow"));
+       }
+       xrun_label.set_markup (buf);
+}
+
+void
+ARDOUR_UI::update_xrun_count ()
+{
+       char buf[64];
+
+       /* If this text is changed, the set_size_request_to_display_given_text call in ARDOUR_UI::resize_text_widgets
+          should also be changed.
+       */
+
        double const c = AudioEngine::instance()->get_dsp_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);
index 23764842eb63e8135ca10d5f5ec91754c38bfbdb..33a5f6e3ee0dc95da7713bd4374f5e89f9183402 100644 (file)
@@ -552,6 +552,9 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
        Gtk::Label   cpu_load_label;
        void update_cpu_load ();
 
+       Gtk::Label   xrun_label;
+       void update_xrun_count ();
+
        Gtk::Label   buffer_load_label;
        void update_buffer_load ();
 
index 7c3db7a7e3d6bab572dc6bf46c497e8dd250cb4e..ad0f4aa8d036793bb4cd5e7936d4cc509c34b01c 100644 (file)
@@ -495,6 +495,8 @@ ARDOUR_UI::build_menu_bar ()
        timecode_format_label.set_use_markup ();
        cpu_load_label.set_name ("CPULoad");
        cpu_load_label.set_use_markup ();
+       xrun_label.set_name ("XrunLabel");
+       xrun_label.set_use_markup ();
        buffer_load_label.set_name ("BufferLoad");
        buffer_load_label.set_use_markup ();
        sample_rate_label.set_name ("SampleRate");
@@ -523,6 +525,7 @@ ARDOUR_UI::build_menu_bar ()
 
        hbox->pack_end (wall_clock_label, false, false, 2);
        hbox->pack_end (disk_space_label, false, false, 4);
+       hbox->pack_end (xrun_label, false, false, 4);
        hbox->pack_end (cpu_load_label, false, false, 4);
        hbox->pack_end (buffer_load_label, false, false, 4);
        hbox->pack_end (sample_rate_label, false, false, 4);
@@ -539,6 +542,7 @@ ARDOUR_UI::build_menu_bar ()
 #endif
        _status_bar_visibility.add (&disk_space_label,      X_("Disk"),      _("Disk Space"), disk_space);
        _status_bar_visibility.add (&cpu_load_label,        X_("DSP"),       _("DSP"), true);
+       _status_bar_visibility.add (&xrun_label,            X_("XRun"),      _("X-run"), true);
        _status_bar_visibility.add (&buffer_load_label,     X_("Buffers"),   _("Buffers"), true);
        _status_bar_visibility.add (&sample_rate_label,     X_("Audio"),     _("Audio"), true);
        _status_bar_visibility.add (&timecode_format_label, X_("TCFormat"),  _("Timecode Format"), true);
@@ -660,6 +664,7 @@ ARDOUR_UI::resize_text_widgets ()
 {
        set_size_request_to_display_given_text (cpu_load_label, "DSP: 100.0%", 2, 2);
        set_size_request_to_display_given_text (buffer_load_label, "Buffers: p:100% c:100%", 2, 2);
+       set_size_request_to_display_given_text (xrun_label, "X: 9999", 2, 2);
 }
 
 void