summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Mayberry <mojofunk@gmail.com>2014-12-25 22:02:00 +0700
committerTim Mayberry <mojofunk@gmail.com>2015-01-01 19:04:14 +0700
commitb5c9a92a584b70b2af172e7240d4a58b007e0608 (patch)
tree67b84500f6e7a516d684b9b52d4cf6784246240c
parentd606a37204a0603144cd3592bc9825f82e144741 (diff)
Move Timers/Timeouts from ARDOUR_UI into functions in timers.h and use PBD::Timers
-rw-r--r--gtk2_ardour/ardour_ui.cc87
-rw-r--r--gtk2_ardour/ardour_ui.h27
-rw-r--r--gtk2_ardour/ardour_ui_dialogs.cc21
-rw-r--r--gtk2_ardour/automation_controller.cc3
-rw-r--r--gtk2_ardour/editor.cc3
-rw-r--r--gtk2_ardour/gain_meter.cc3
-rw-r--r--gtk2_ardour/generic_pluginui.cc4
-rw-r--r--gtk2_ardour/lv2_plugin_ui.cc14
-rw-r--r--gtk2_ardour/lxvst_plugin_ui.cc4
-rw-r--r--gtk2_ardour/meterbridge.cc3
-rw-r--r--gtk2_ardour/mixer_ui.cc3
-rw-r--r--gtk2_ardour/monitor_section.cc3
-rw-r--r--gtk2_ardour/panner_ui.cc3
-rw-r--r--gtk2_ardour/processor_box.cc3
-rw-r--r--gtk2_ardour/return_ui.cc6
-rw-r--r--gtk2_ardour/route_params_ui.cc3
-rw-r--r--gtk2_ardour/route_ui.cc7
-rw-r--r--gtk2_ardour/send_ui.cc6
-rw-r--r--gtk2_ardour/sfdb_ui.cc3
-rw-r--r--gtk2_ardour/streamview.cc4
-rw-r--r--gtk2_ardour/timers.cc210
-rw-r--r--gtk2_ardour/timers.h42
-rw-r--r--gtk2_ardour/video_monitor.cc8
-rw-r--r--gtk2_ardour/wscript1
24 files changed, 332 insertions, 139 deletions
diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc
index 51f2858bea..1850648218 100644
--- a/gtk2_ardour/ardour_ui.cc
+++ b/gtk2_ardour/ardour_ui.cc
@@ -135,6 +135,7 @@ typedef uint64_t microseconds_t;
#include "startup.h"
#include "theme_manager.h"
#include "time_axis_view_item.h"
+#include "timers.h"
#include "utils.h"
#include "video_server_dialog.h"
#include "add_video_dialog.h"
@@ -151,10 +152,6 @@ using namespace std;
ARDOUR_UI *ARDOUR_UI::theArdourUI = 0;
-sigc::signal<void,bool> ARDOUR_UI::Blink;
-sigc::signal<void> ARDOUR_UI::RapidScreenUpdate;
-sigc::signal<void> ARDOUR_UI::SuperRapidScreenUpdate;
-sigc::signal<void> ARDOUR_UI::FPSUpdate;
sigc::signal<void, framepos_t, bool, framepos_t> ARDOUR_UI::Clock;
sigc::signal<void> ARDOUR_UI::CloseAllDialogs;
@@ -179,7 +176,6 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir)
, _was_dirty (false)
, _mixer_on_top (false)
, first_time_engine_run (true)
- , blink_timeout_tag (-1)
/* transport */
@@ -532,8 +528,6 @@ ARDOUR_UI::post_engine ()
exit (0);
}
- blink_timeout_tag = -1;
-
/* this being a GUI and all, we want peakfiles */
AudioFileSource::set_build_peakfiles (true);
@@ -1009,9 +1003,7 @@ If you still wish to quit, please use the\n\n\
second_connection.disconnect ();
point_one_second_connection.disconnect ();
-#ifndef PLATFORM_WINDOWS
point_zero_something_second_connection.disconnect();
-#endif
fps_connection.disconnect();
}
@@ -1112,7 +1104,7 @@ ARDOUR_UI::ask_about_saving_session (const vector<string>& actions)
}
-gint
+void
ARDOUR_UI::every_second ()
{
update_cpu_load ();
@@ -1132,23 +1124,19 @@ ARDOUR_UI::every_second ()
_was_dirty = false;
}
}
- return TRUE;
}
-gint
+void
ARDOUR_UI::every_point_one_seconds ()
{
shuttle_box->update_speed_display ();
- RapidScreenUpdate(); /* EMIT_SIGNAL */
- return TRUE;
}
-gint
+void
ARDOUR_UI::every_point_zero_something_seconds ()
{
// august 2007: actual update frequency: 25Hz (40ms), not 100Hz
- SuperRapidScreenUpdate(); /* EMIT_SIGNAL */
if (editor_meter && ARDOUR_UI::config()->get_show_editor_meter()) {
float mpeak = editor_meter->update_meters();
if (mpeak > editor_meter_max_peak) {
@@ -1157,17 +1145,6 @@ ARDOUR_UI::every_point_zero_something_seconds ()
}
}
}
- return TRUE;
-}
-
-gint
-ARDOUR_UI::every_fps ()
-{
- FPSUpdate(); /* EMIT_SIGNAL */
-#ifdef PLATFORM_WINDOWS
- every_point_zero_something_seconds();
-#endif
- return TRUE;
}
void
@@ -1199,7 +1176,7 @@ ARDOUR_UI::set_fps_timeout_connection ()
#endif
}
fps_connection.disconnect();
- fps_connection = Glib::signal_timeout().connect (sigc::mem_fun(*this, &ARDOUR_UI::every_fps), interval);
+ Timers::set_fps_interval (interval);
}
void
@@ -2270,9 +2247,21 @@ ARDOUR_UI::map_transport_state ()
}
void
+ARDOUR_UI::blink_handler (bool blink_on)
+{
+ transport_rec_enable_blink (blink_on);
+ solo_blink (blink_on);
+ sync_blink (blink_on);
+ audition_blink (blink_on);
+ feedback_blink (blink_on);
+}
+
+void
ARDOUR_UI::update_clocks ()
{
- if (editor && !editor->dragging_playhead()) {
+ if (!_session) return;
+
+ if (!editor && !editor->dragging_playhead()) {
Clock (_session->audible_frame(), false, editor->get_preferred_edit_position()); /* EMIT_SIGNAL */
}
}
@@ -2281,9 +2270,9 @@ void
ARDOUR_UI::start_clocking ()
{
if (ui_config->get_super_rapid_clock_update()) {
- clock_signal_connection = FPSUpdate.connect (sigc::mem_fun(*this, &ARDOUR_UI::update_clocks));
+ clock_signal_connection = Timers::fps_connect (sigc::mem_fun(*this, &ARDOUR_UI::update_clocks));
} else {
- clock_signal_connection = RapidScreenUpdate.connect (sigc::mem_fun(*this, &ARDOUR_UI::update_clocks));
+ clock_signal_connection = Timers::rapid_connect (sigc::mem_fun(*this, &ARDOUR_UI::update_clocks));
}
}
@@ -2293,42 +2282,6 @@ ARDOUR_UI::stop_clocking ()
clock_signal_connection.disconnect ();
}
-gint
-ARDOUR_UI::_blink (void *arg)
-{
- ((ARDOUR_UI *) arg)->blink ();
- return TRUE;
-}
-
-void
-ARDOUR_UI::blink ()
-{
- Blink (blink_on = !blink_on); /* EMIT_SIGNAL */
-}
-
-void
-ARDOUR_UI::start_blinking ()
-{
- /* Start the blink signal. Everybody with a blinking widget
- uses Blink to drive the widget's state.
- */
-
- if (blink_timeout_tag < 0) {
- blink_on = false;
- blink_timeout_tag = g_timeout_add (240, _blink, this);
- }
-}
-
-void
-ARDOUR_UI::stop_blinking ()
-{
- if (blink_timeout_tag >= 0) {
- g_source_remove (blink_timeout_tag);
- blink_timeout_tag = -1;
- }
-}
-
-
/** Ask the user for the name of a new snapshot and then take it.
*/
diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h
index b4436aced8..a2e492970a 100644
--- a/gtk2_ardour/ardour_ui.h
+++ b/gtk2_ardour/ardour_ui.h
@@ -193,16 +193,6 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
Gtk::HBox& editor_transport_box() { return _editor_transport_box; }
static PublicEditor* _instance;
- static sigc::signal<void,bool> Blink;
-
- /** point_zero_one_seconds -- 10Hz ^= 100ms */
- static sigc::signal<void> RapidScreenUpdate;
-
- /** point_zero_something_seconds -- currently 25Hz ^= 40ms */
- static sigc::signal<void> SuperRapidScreenUpdate;
-
- /** every_fps -- see set_fps_timeout_connection() 25Hz < x < 120Hz */
- static sigc::signal<void> FPSUpdate;
/** Emitted frequently with the audible frame, false, and the edit point as
* parameters respectively.
@@ -370,13 +360,6 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
void use_config ();
- static gint _blink (void *);
- void blink ();
- gint blink_timeout_tag;
- bool blink_on;
- void start_blinking ();
- void stop_blinking ();
-
void about_signal_response(int response);
Gtk::VBox top_packer;
@@ -479,6 +462,9 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
ArdourButton editor_meter_peak_display;
bool editor_meter_peak_button_release (GdkEventButton*);
+ void blink_handler (bool);
+ sigc::connection blink_connection;
+
void solo_blink (bool);
void sync_blink (bool);
void audition_blink (bool);
@@ -562,10 +548,9 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
Gtk::Label format_label;
void update_format ();
- gint every_second ();
- gint every_point_one_seconds ();
- gint every_point_zero_something_seconds ();
- gint every_fps ();
+ void every_second ();
+ void every_point_one_seconds ();
+ void every_point_zero_something_seconds ();
sigc::connection second_connection;
sigc::connection point_one_second_connection;
diff --git a/gtk2_ardour/ardour_ui_dialogs.cc b/gtk2_ardour/ardour_ui_dialogs.cc
index 7c88400979..b9789f3425 100644
--- a/gtk2_ardour/ardour_ui_dialogs.cc
+++ b/gtk2_ardour/ardour_ui_dialogs.cc
@@ -55,6 +55,7 @@
#include "sfdb_ui.h"
#include "theme_manager.h"
#include "time_info_box.h"
+#include "timers.h"
#include <gtkmm2ext/keyboard.h>
@@ -145,11 +146,7 @@ ARDOUR_UI::set_session (Session *s)
setup_session_options ();
- Blink.connect (sigc::mem_fun(*this, &ARDOUR_UI::transport_rec_enable_blink));
- Blink.connect (sigc::mem_fun(*this, &ARDOUR_UI::solo_blink));
- Blink.connect (sigc::mem_fun(*this, &ARDOUR_UI::sync_blink));
- Blink.connect (sigc::mem_fun(*this, &ARDOUR_UI::audition_blink));
- Blink.connect (sigc::mem_fun(*this, &ARDOUR_UI::feedback_blink));
+ blink_connection = Timers::blink_connect (sigc::mem_fun(*this, &ARDOUR_UI::blink_handler));
_session->RecordStateChanged.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::record_state_changed, this), gui_context());
_session->StepEditStatusChange.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::step_edit_status_change, this, _1), gui_context());
@@ -178,15 +175,12 @@ ARDOUR_UI::set_session (Session *s)
Glib::signal_idle().connect (sigc::mem_fun (*this, &ARDOUR_UI::first_idle));
start_clocking ();
- start_blinking ();
map_transport_state ();
- second_connection = Glib::signal_timeout().connect (sigc::mem_fun(*this, &ARDOUR_UI::every_second), 1000);
- point_one_second_connection = Glib::signal_timeout().connect (sigc::mem_fun(*this, &ARDOUR_UI::every_point_one_seconds), 100);
-#ifndef PLATFORM_WINDOWS
- point_zero_something_second_connection = Glib::signal_timeout().connect (sigc::mem_fun(*this, &ARDOUR_UI::every_point_zero_something_seconds), 40);
-#endif
+ second_connection = Timers::second_connect (sigc::mem_fun(*this, &ARDOUR_UI::every_second));
+ point_one_second_connection = Timers::rapid_connect (sigc::mem_fun(*this, &ARDOUR_UI::every_point_one_seconds));
+ point_zero_something_second_connection = Timers::super_rapid_connect (sigc::mem_fun(*this, &ARDOUR_UI::every_point_zero_something_seconds));
set_fps_timeout_connection();
update_format ();
@@ -287,9 +281,7 @@ ARDOUR_UI::unload_session (bool hide_stuff)
second_connection.disconnect ();
point_one_second_connection.disconnect ();
-#ifndef PLATFORM_WINDOWS
point_zero_something_second_connection.disconnect();
-#endif
fps_connection.disconnect();
if (editor_meter) {
@@ -309,12 +301,11 @@ ARDOUR_UI::unload_session (bool hide_stuff)
ARDOUR_UI::instance()->video_timeline->close_session();
}
- stop_blinking ();
stop_clocking ();
/* drop everything attached to the blink signal */
- Blink.clear ();
+ blink_connection.disconnect ();
delete _session;
_session = 0;
diff --git a/gtk2_ardour/automation_controller.cc b/gtk2_ardour/automation_controller.cc
index 6acf37f953..980b38ad65 100644
--- a/gtk2_ardour/automation_controller.cc
+++ b/gtk2_ardour/automation_controller.cc
@@ -34,6 +34,7 @@
#include "automation_controller.h"
#include "gui_thread.h"
#include "note_select_dialog.h"
+#include "timers.h"
#include "i18n.h"
@@ -104,7 +105,7 @@ AutomationController::AutomationController(boost::shared_ptr<Automatable>
_adjustment->signal_value_changed().connect(
sigc::mem_fun(*this, &AutomationController::value_adjusted));
- _screen_update_connection = ARDOUR_UI::RapidScreenUpdate.connect (
+ _screen_update_connection = Timers::rapid_connect (
sigc::mem_fun (*this, &AutomationController::display_effective_value));
ac->Changed.connect (_changed_connection, invalidator (*this), boost::bind (&AutomationController::value_changed, this), gui_context());
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc
index 1077934d82..93bbbd6805 100644
--- a/gtk2_ardour/editor.cc
+++ b/gtk2_ardour/editor.cc
@@ -122,6 +122,7 @@
#include "sfdb_ui.h"
#include "tempo_lines.h"
#include "time_axis_view.h"
+#include "timers.h"
#include "utils.h"
#include "verbose_cursor.h"
@@ -1382,7 +1383,7 @@ Editor::set_session (Session *t)
(static_cast<TimeAxisView*>(*i))->set_samples_per_pixel (samples_per_pixel);
}
- super_rapid_screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect (
+ super_rapid_screen_update_connection = Timers::super_rapid_connect (
sigc::mem_fun (*this, &Editor::super_rapid_screen_update)
);
diff --git a/gtk2_ardour/gain_meter.cc b/gtk2_ardour/gain_meter.cc
index 227d391fc9..619cb349ed 100644
--- a/gtk2_ardour/gain_meter.cc
+++ b/gtk2_ardour/gain_meter.cc
@@ -43,6 +43,7 @@
#include "public_editor.h"
#include "utils.h"
#include "meter_patterns.h"
+#include "timers.h"
#include "ardour/session.h"
#include "ardour/route.h"
@@ -873,7 +874,7 @@ GainMeterBase::gain_automation_state_changed ()
gain_watching.disconnect();
if (x) {
- gain_watching = ARDOUR_UI::RapidScreenUpdate.connect (sigc::mem_fun (*this, &GainMeterBase::effective_gain_display));
+ gain_watching = Timers::rapid_connect (sigc::mem_fun (*this, &GainMeterBase::effective_gain_display));
}
}
diff --git a/gtk2_ardour/generic_pluginui.cc b/gtk2_ardour/generic_pluginui.cc
index b07d6415ea..9dff30186c 100644
--- a/gtk2_ardour/generic_pluginui.cc
+++ b/gtk2_ardour/generic_pluginui.cc
@@ -48,6 +48,7 @@
#include "plugin_ui.h"
#include "gui_thread.h"
#include "automation_controller.h"
+#include "timers.h"
#include "i18n.h"
@@ -939,8 +940,7 @@ GenericPluginUI::start_updating (GdkEventAny*)
{
if (output_controls.size() > 0 ) {
screen_update_connection.disconnect();
- screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect
- (sigc::mem_fun(*this, &GenericPluginUI::output_update));
+ screen_update_connection = Timers::super_rapid_connect (sigc::mem_fun(*this, &GenericPluginUI::output_update));
}
return false;
}
diff --git a/gtk2_ardour/lv2_plugin_ui.cc b/gtk2_ardour/lv2_plugin_ui.cc
index 9f6f650f56..c732aca567 100644
--- a/gtk2_ardour/lv2_plugin_ui.cc
+++ b/gtk2_ardour/lv2_plugin_ui.cc
@@ -21,8 +21,8 @@
#include "ardour/session.h"
#include "pbd/error.h"
-#include "ardour_ui.h"
#include "lv2_plugin_ui.h"
+#include "timers.h"
#include "lv2/lv2plug.in/ns/extensions/ui/ui.h"
@@ -145,7 +145,7 @@ LV2PluginUI::start_updating(GdkEventAny*)
{
if (!_output_ports.empty()) {
_screen_update_connection.disconnect();
- _screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect
+ _screen_update_connection = Timers::super_rapid_connect
(sigc::mem_fun(*this, &LV2PluginUI::output_update));
}
return false;
@@ -344,7 +344,7 @@ LV2PluginUI::lv2ui_instantiate(const std::string& title)
}
if (_lv2->has_message_output()) {
- _message_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect(
+ _message_update_connection = Timers::super_rapid_connect (
sigc::mem_fun(*this, &LV2PluginUI::update_timeout));
}
}
@@ -444,10 +444,10 @@ LV2PluginUI::on_window_show(const std::string& title)
_screen_update_connection.disconnect();
_message_update_connection.disconnect();
LV2_EXTERNAL_UI_SHOW(_external_ui_ptr);
- _screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect
+ _screen_update_connection = Timers::super_rapid_connect
(sigc::mem_fun(*this, &LV2PluginUI::output_update));
if (_lv2->has_message_output()) {
- _message_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect(
+ _message_update_connection = Timers::super_rapid_connect (
sigc::mem_fun(*this, &LV2PluginUI::update_timeout));
}
return false;
@@ -460,10 +460,10 @@ LV2PluginUI::on_window_show(const std::string& title)
_screen_update_connection.disconnect();
_message_update_connection.disconnect();
LV2_EXTERNAL_UI_SHOW(_external_ui_ptr);
- _screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect
+ _screen_update_connection = Timers::super_rapid_connect
(sigc::mem_fun(*this, &LV2PluginUI::output_update));
if (_lv2->has_message_output()) {
- _message_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect(
+ _message_update_connection = Timers::super_rapid_connect (
sigc::mem_fun(*this, &LV2PluginUI::update_timeout));
}
return false;
diff --git a/gtk2_ardour/lxvst_plugin_ui.cc b/gtk2_ardour/lxvst_plugin_ui.cc
index e3335d4990..17dc89255a 100644
--- a/gtk2_ardour/lxvst_plugin_ui.cc
+++ b/gtk2_ardour/lxvst_plugin_ui.cc
@@ -20,7 +20,7 @@
#include "ardour/lxvst_plugin.h"
#include "ardour/linux_vst_support.h"
#include "lxvst_plugin_ui.h"
-#include "ardour_ui.h"
+#include "timers.h"
#include <gdk/gdkx.h>
#define LXVST_H_FIDDLE 40
@@ -49,7 +49,7 @@ bool
LXVSTPluginUI::start_updating (GdkEventAny*)
{
_screen_update_connection.disconnect();
- _screen_update_connection = ARDOUR_UI::instance()->RapidScreenUpdate.connect (mem_fun(*this, &LXVSTPluginUI::resize_callback));
+ _screen_update_connection = Timers::rapid_connect (mem_fun(*this, &LXVSTPluginUI::resize_callback));
return false;
}
diff --git a/gtk2_ardour/meterbridge.cc b/gtk2_ardour/meterbridge.cc
index bb5c4b8eca..8eee194a39 100644
--- a/gtk2_ardour/meterbridge.cc
+++ b/gtk2_ardour/meterbridge.cc
@@ -54,6 +54,7 @@
#include "gui_thread.h"
#include "global_signals.h"
#include "meter_patterns.h"
+#include "timers.h"
#include "i18n.h"
@@ -555,7 +556,7 @@ Meterbridge::get_state (void)
gint
Meterbridge::start_updating ()
{
- fast_screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect (sigc::mem_fun(*this, &Meterbridge::fast_update_strips));
+ fast_screen_update_connection = Timers::super_rapid_connect (sigc::mem_fun(*this, &Meterbridge::fast_update_strips));
return 0;
}
diff --git a/gtk2_ardour/mixer_ui.cc b/gtk2_ardour/mixer_ui.cc
index e20f78a61b..2080df2b1b 100644
--- a/gtk2_ardour/mixer_ui.cc
+++ b/gtk2_ardour/mixer_ui.cc
@@ -57,6 +57,7 @@
#include "actions.h"
#include "gui_thread.h"
#include "mixer_group_tabs.h"
+#include "timers.h"
#include "i18n.h"
@@ -884,7 +885,7 @@ Mixer_UI::hide_strip (MixerStrip* ms)
gint
Mixer_UI::start_updating ()
{
- fast_screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect (sigc::mem_fun(*this, &Mixer_UI::fast_update_strips));
+ fast_screen_update_connection = Timers::super_rapid_connect (sigc::mem_fun(*this, &Mixer_UI::fast_update_strips));
return 0;
}
diff --git a/gtk2_ardour/monitor_section.cc b/gtk2_ardour/monitor_section.cc
index 1a18c4bc47..f664fdbe09 100644
--- a/gtk2_ardour/monitor_section.cc
+++ b/gtk2_ardour/monitor_section.cc
@@ -37,6 +37,7 @@
#include "gui_thread.h"
#include "monitor_section.h"
#include "public_editor.h"
+#include "timers.h"
#include "volume_controller.h"
#include "utils.h"
@@ -104,7 +105,7 @@ MonitorSection::MonitorSection (Session* s)
rude_audition_button.set_name ("rude audition");
rude_audition_button.show ();
- ARDOUR_UI::Blink.connect (sigc::mem_fun (*this, &MonitorSection::do_blink));
+ Timers::blink_connect (sigc::mem_fun (*this, &MonitorSection::do_blink));
rude_solo_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MonitorSection::cancel_solo), false);
UI::instance()->set_tip (rude_solo_button, _("When active, something is soloed.\nClick to de-solo everything"));
diff --git a/gtk2_ardour/panner_ui.cc b/gtk2_ardour/panner_ui.cc
index f35c79d4fe..d376b6e8ff 100644
--- a/gtk2_ardour/panner_ui.cc
+++ b/gtk2_ardour/panner_ui.cc
@@ -32,6 +32,7 @@
#include "panner2d.h"
#include "gui_thread.h"
#include "stereo_panner.h"
+#include "timers.h"
#include "mono_panner.h"
#include "i18n.h"
@@ -576,7 +577,7 @@ PannerUI::pan_automation_state_changed ()
pan_watching.disconnect();
if (x) {
- pan_watching = ARDOUR_UI::RapidScreenUpdate.connect (sigc::mem_fun (*this, &PannerUI::effective_pan_display));
+ pan_watching = Timers::rapid_connect (sigc::mem_fun (*this, &PannerUI::effective_pan_display));
}
}
diff --git a/gtk2_ardour/processor_box.cc b/gtk2_ardour/processor_box.cc
index 361945d5e0..ab656007f2 100644
--- a/gtk2_ardour/processor_box.cc
+++ b/gtk2_ardour/processor_box.cc
@@ -76,6 +76,7 @@
#include "return_ui.h"
#include "route_processor_selection.h"
#include "send_ui.h"
+#include "timers.h"
#include "i18n.h"
@@ -550,7 +551,7 @@ ProcessorEntry::Control::Control (boost::shared_ptr<AutomationControl> c, string
c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ());
}
- ARDOUR_UI::RapidScreenUpdate.connect (sigc::mem_fun (*this, &Control::control_changed));
+ Timers::rapid_connect (sigc::mem_fun (*this, &Control::control_changed));
control_changed ();
set_tooltip ();
diff --git a/gtk2_ardour/return_ui.cc b/gtk2_ardour/return_ui.cc
index 16c4720577..b6412bbe7a 100644
--- a/gtk2_ardour/return_ui.cc
+++ b/gtk2_ardour/return_ui.cc
@@ -25,8 +25,8 @@
#include "return_ui.h"
#include "io_selector.h"
-#include "ardour_ui.h"
#include "gui_thread.h"
+#include "timers.h"
#include "i18n.h"
@@ -62,8 +62,8 @@ ReturnUI::ReturnUI (Gtk::Window* parent, boost::shared_ptr<Return> r, Session* s
_gpm.setup_meters ();
_gpm.set_fader_name (X_("ReturnUIFader"));
- // screen_update_connection = ARDOUR_UI::instance()->RapidScreenUpdate.connect (sigc::mem_fun (*this, &ReturnUI::update));
- fast_screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect (sigc::mem_fun (*this, &ReturnUI::fast_update));
+ // screen_update_connection = Timers::rapid_connect (sigc::mem_fun (*this, &ReturnUI::update));
+ fast_screen_update_connection = Timers::super_rapid_connect (sigc::mem_fun (*this, &ReturnUI::fast_update));
}
ReturnUI::~ReturnUI ()
diff --git a/gtk2_ardour/route_params_ui.cc b/gtk2_ardour/route_params_ui.cc
index be5b6663f0..82e6f10a15 100644
--- a/gtk2_ardour/route_params_ui.cc
+++ b/gtk2_ardour/route_params_ui.cc
@@ -46,6 +46,7 @@
#include "return_ui.h"
#include "route_params_ui.h"
#include "send_ui.h"
+#include "timers.h"
#include "i18n.h"
@@ -642,7 +643,7 @@ RouteParams_UI::update_title ()
void
RouteParams_UI::start_updating ()
{
- update_connection = ARDOUR_UI::instance()->RapidScreenUpdate.connect
+ update_connection = Timers::rapid_connect
(sigc::mem_fun(*this, &RouteParams_UI::update_views));
}
diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc
index 2d353eb6b1..a59e4cd475 100644
--- a/gtk2_ardour/route_ui.cc
+++ b/gtk2_ardour/route_ui.cc
@@ -46,6 +46,7 @@
#include "automation_time_axis.h"
#include "route_time_axis.h"
#include "group_tabs.h"
+#include "timers.h"
#include "ardour/audio_track.h"
#include "ardour/audioengine.h"
@@ -147,7 +148,7 @@ RouteUI::init ()
UI::instance()->set_tip (rec_enable_button, _("Enable recording on this track"), "");
if (ARDOUR_UI::config()->get_blink_rec_arm()) {
- rec_blink_connection = ARDOUR_UI::instance()->Blink.connect (sigc::mem_fun (*this, &RouteUI::blink_rec_display));
+ rec_blink_connection = Timers::blink_connect (sigc::mem_fun (*this, &RouteUI::blink_rec_display));
}
show_sends_button = manage (new ArdourButton);
@@ -1924,7 +1925,7 @@ RouteUI::parameter_changed (string const & p)
} else if (p == "blink-rec-arm") {
if (ARDOUR_UI::config()->get_blink_rec_arm()) {
rec_blink_connection.disconnect ();
- rec_blink_connection = ARDOUR_UI::instance()->Blink.connect (sigc::mem_fun (*this, &RouteUI::blink_rec_display));
+ rec_blink_connection = Timers::blink_connect (sigc::mem_fun (*this, &RouteUI::blink_rec_display));
} else {
rec_blink_connection.disconnect ();
RouteUI::blink_rec_display(false);
@@ -2220,7 +2221,7 @@ RouteUI::bus_send_display_changed (boost::shared_ptr<Route> send_to)
{
if (_route == send_to) {
show_sends_button->set_active (true);
- send_blink_connection = ARDOUR_UI::instance()->Blink.connect (sigc::mem_fun (*this, &RouteUI::send_blink));
+ send_blink_connection = Timers::blink_connect (sigc::mem_fun (*this, &RouteUI::send_blink));
} else {
show_sends_button->set_active (false);
send_blink_connection.disconnect ();
diff --git a/gtk2_ardour/send_ui.cc b/gtk2_ardour/send_ui.cc
index d571d018b7..af23518c3a 100644
--- a/gtk2_ardour/send_ui.cc
+++ b/gtk2_ardour/send_ui.cc
@@ -26,7 +26,7 @@
#include "send_ui.h"
#include "io_selector.h"
-#include "ardour_ui.h"
+#include "timers.h"
#include "gui_thread.h"
#include "i18n.h"
@@ -80,9 +80,9 @@ SendUI::SendUI (Gtk::Window* parent, boost::shared_ptr<Send> s, Session* session
_gpm.setup_meters ();
_gpm.set_fader_name (X_("SendUIFader"));
- // screen_update_connection = ARDOUR_UI::instance()->RapidScreenUpdate.connect (
+ // screen_update_connection = Timers::rapid_connect (
// sigc::mem_fun (*this, &SendUI::update));
- fast_screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect (
+ fast_screen_update_connection = Timers::super_rapid_connect (
sigc::mem_fun (*this, &SendUI::fast_update));
}
diff --git a/gtk2_ardour/sfdb_ui.cc b/gtk2_ardour/sfdb_ui.cc
index 8e89ccf4b3..d6ba793c2f 100644
--- a/gtk2_ardour/sfdb_ui.cc
+++ b/gtk2_ardour/sfdb_ui.cc
@@ -68,6 +68,7 @@
#include "gain_meter.h"
#include "main_clock.h"
#include "public_editor.h"
+#include "timers.h"
#include "sfdb_freesound_mootcher.h"
@@ -856,7 +857,7 @@ SoundFileBrowser::remove_gain_meter ()
void
SoundFileBrowser::start_metering ()
{
- metering_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect (sigc::mem_fun(*this, &SoundFileBrowser::meter));
+ metering_connection = Timers::super_rapid_connect (sigc::mem_fun(*this, &SoundFileBrowser::meter));
}
void
diff --git a/gtk2_ardour/streamview.cc b/gtk2_ardour/streamview.cc
index 18953aee09..24c28d7957 100644
--- a/gtk2_ardour/streamview.cc
+++ b/gtk2_ardour/streamview.cc
@@ -41,6 +41,7 @@
#include "selection.h"
#include "public_editor.h"
#include "ardour_ui.h"
+#include "timers.h"
#include "rgb_macros.h"
#include "gui_thread.h"
#include "utils.h"
@@ -434,8 +435,7 @@ StreamView::create_rec_box(framepos_t frame_pos, double width)
rec_rects.push_back (recbox);
screen_update_connection.disconnect();
- screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect(
- sigc::mem_fun(*this, &StreamView::update_rec_box));
+ screen_update_connection = Timers::rapid_connect (sigc::mem_fun(*this, &StreamView::update_rec_box));
rec_updating = true;
rec_active = true;
diff --git a/gtk2_ardour/timers.cc b/gtk2_ardour/timers.cc
new file mode 100644
index 0000000000..13f2cfdbd7
--- /dev/null
+++ b/gtk2_ardour/timers.cc
@@ -0,0 +1,210 @@
+/*
+ Copyright (C) 2014 Tim Mayberry
+
+ 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "timers.h"
+
+#include "pbd/timer.h"
+#include "pbd/debug.h"
+#include "pbd/compose.h"
+
+#include "debug.h"
+
+namespace {
+
+class StandardTimer : public PBD::StandardTimer
+{
+public:
+ StandardTimer (unsigned int interval)
+ : PBD::StandardTimer(interval)
+ { }
+
+ virtual bool on_elapsed () {
+ DEBUG_TIMING_ADD_ELAPSED(PBD::DEBUG::GUITiming, timing_interval_data);
+ DEBUG_TIMING_START(PBD::DEBUG::GUITiming, timing_exec_data);
+
+ bool ret_val = PBD::StandardTimer::on_elapsed ();
+
+ DEBUG_TIMING_ADD_ELAPSED(PBD::DEBUG::GUITiming, timing_exec_data);
+ DEBUG_TIMING_START(PBD::DEBUG::GUITiming, timing_interval_data);
+ return ret_val;
+ }
+
+#ifndef NDEBUG
+ PBD::TimingData timing_interval_data;
+ PBD::TimingData timing_exec_data;
+#endif
+};
+
+class BlinkTimer : public PBD::BlinkTimer
+{
+public:
+ BlinkTimer (unsigned int interval)
+ : PBD::BlinkTimer(interval)
+ { }
+
+ virtual bool on_elapsed () {
+ DEBUG_TIMING_ADD_ELAPSED(PBD::DEBUG::GUITiming, timing_interval_data);
+ DEBUG_TIMING_START(PBD::DEBUG::GUITiming, timing_exec_data);
+
+ bool ret_val = PBD::BlinkTimer::on_elapsed ();
+
+ DEBUG_TIMING_ADD_ELAPSED(PBD::DEBUG::GUITiming, timing_exec_data);
+ DEBUG_TIMING_START(PBD::DEBUG::GUITiming, timing_interval_data);
+ return ret_val;
+ }
+
+#ifndef NDEBUG
+ PBD::TimingData timing_interval_data;
+ PBD::TimingData timing_exec_data;
+#endif
+};
+
+
+class UITimers
+{
+
+public:
+
+ UITimers ()
+ : blink(240)
+ , second(1000)
+ , rapid(100)
+ , super_rapid(40)
+ , fps(40)
+ {
+#ifndef NDEBUG
+ second.connect (sigc::mem_fun (*this, &UITimers::on_second_timer));
+#endif
+ }
+
+ BlinkTimer blink;
+ StandardTimer second;
+ StandardTimer rapid;
+ StandardTimer super_rapid;
+ StandardTimer fps;
+
+#ifndef NDEBUG
+ std::vector<uint64_t> rapid_eps_count;
+ std::vector<uint64_t> super_rapid_eps_count;
+ std::vector<uint64_t> fps_eps_count;
+
+private:
+
+ void debug_rapid_timer () {
+ DEBUG_TRACE(PBD::DEBUG::GUITiming, string_compose ("Rapid Connections: %1\n", rapid.connection_count ()));
+
+ rapid_eps_count.push_back (rapid.timing_exec_data.size());
+
+ DEBUG_TRACE(PBD::DEBUG::GUITiming, string_compose ("Rapid Exec Totals: %1", PBD::timing_summary (rapid_eps_count)));
+
+ DEBUG_TRACE(PBD::DEBUG::GUITiming, string_compose ("Rapid Interval: %1", rapid.timing_interval_data.summary()));
+ DEBUG_TRACE(PBD::DEBUG::GUITiming, string_compose ("Rapid Exec: %1", rapid.timing_exec_data.summary()));
+ DEBUG_TIMING_RESET(PBD::DEBUG::GUITiming, rapid.timing_interval_data);
+ DEBUG_TIMING_RESET(PBD::DEBUG::GUITiming, rapid.timing_exec_data);
+ }
+
+ void debug_super_rapid_timer () {
+ // we don't use this timer on windows so don't display empty data for it
+#ifndef PLATFORM_WINDOWS
+
+ DEBUG_TRACE(PBD::DEBUG::GUITiming, string_compose ("Super Rapid Connections: %1\n", super_rapid.connection_count ()));
+
+ super_rapid_eps_count.push_back (super_rapid.timing_exec_data.size());
+
+ DEBUG_TRACE(PBD::DEBUG::GUITiming, string_compose ("Super Rapid Exec Totals: %1", PBD::timing_summary (super_rapid_eps_count)));
+ DEBUG_TRACE(PBD::DEBUG::GUITiming, string_compose ("Super Rapid Interval: %1", super_rapid.timing_interval_data.summary()));
+ DEBUG_TRACE(PBD::DEBUG::GUITiming, string_compose ("Super Rapid Exec: %1", super_rapid.timing_exec_data.summary()));
+ DEBUG_TIMING_RESET(PBD::DEBUG::GUITiming, super_rapid.timing_interval_data);
+ DEBUG_TIMING_RESET(PBD::DEBUG::GUITiming, super_rapid.timing_exec_data);
+#endif
+ }
+
+ void debug_fps_timer () {
+ DEBUG_TRACE(PBD::DEBUG::GUITiming, string_compose ("FPS Connections: %1\n", fps.connection_count ()));
+
+ fps_eps_count.push_back (fps.timing_exec_data.size());
+
+ DEBUG_TRACE(PBD::DEBUG::GUITiming, string_compose ("FPS Exec Totals: %1", PBD::timing_summary (fps_eps_count)));
+
+ DEBUG_TRACE(PBD::DEBUG::GUITiming, string_compose ("FPS Interval: %1", fps.timing_interval_data.summary()));
+ DEBUG_TRACE(PBD::DEBUG::GUITiming, string_compose ("FPS Exec: %1", fps.timing_exec_data.summary()));
+ DEBUG_TIMING_RESET(PBD::DEBUG::GUITiming, fps.timing_interval_data);
+ DEBUG_TIMING_RESET(PBD::DEBUG::GUITiming, fps.timing_exec_data);
+ }
+
+ void on_second_timer () {
+ debug_rapid_timer ();
+ debug_super_rapid_timer ();
+ debug_fps_timer ();
+ }
+#endif
+};
+
+UITimers&
+get_timers ()
+{
+ static UITimers timers;
+ return timers;
+}
+
+} // anon namespace
+
+namespace Timers {
+
+sigc::connection
+blink_connect(const sigc::slot<void,bool>& slot)
+{
+ return get_timers().blink.connect (slot);
+}
+
+sigc::connection
+second_connect(const sigc::slot<void>& slot)
+{
+ return get_timers().second.connect (slot);
+}
+
+sigc::connection
+rapid_connect(const sigc::slot<void>& slot)
+{
+ return get_timers().rapid.connect (slot);
+}
+
+sigc::connection
+super_rapid_connect(const sigc::slot<void>& slot)
+{
+#ifdef PLATFORM_WINDOWS
+ return get_timers().fps.connect (slot);
+#else
+ return get_timers().super_rapid.connect (slot);
+#endif
+}
+
+void
+set_fps_interval (unsigned int interval)
+{
+ get_timers().fps.set_interval (interval);
+}
+
+sigc::connection
+fps_connect(const sigc::slot<void>& slot)
+{
+ return get_timers().fps.connect (slot);
+}
+
+} // namespace Timers
diff --git a/gtk2_ardour/timers.h b/gtk2_ardour/timers.h
new file mode 100644
index 0000000000..8854571f5b
--- /dev/null
+++ b/gtk2_ardour/timers.h
@@ -0,0 +1,42 @@
+/*
+ Copyright (C) 2014 Tim Mayberry
+
+ 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#ifndef TIMERS_H
+#define TIMERS_H
+
+#include <sigc++/sigc++.h>
+
+namespace Timers
+{
+
+sigc::connection blink_connect(const sigc::slot<void,bool>& slot);
+
+sigc::connection second_connect(const sigc::slot<void>& slot);
+
+sigc::connection rapid_connect(const sigc::slot<void>& slot);
+
+sigc::connection super_rapid_connect(const sigc::slot<void>& slot);
+
+void set_fps_interval(unsigned int interval);
+
+sigc::connection fps_connect(const sigc::slot<void>& slot);
+
+};
+
+#endif // TIMERS_H
diff --git a/gtk2_ardour/video_monitor.cc b/gtk2_ardour/video_monitor.cc
index be412f6725..ece1856d54 100644
--- a/gtk2_ardour/video_monitor.cc
+++ b/gtk2_ardour/video_monitor.cc
@@ -20,7 +20,7 @@
#include "pbd/file_utils.h"
#include "pbd/convert.h"
#include "gui_thread.h"
-#include "ardour_ui.h"
+#include "timers.h"
#include "utils.h"
#include <stdio.h>
@@ -159,10 +159,10 @@ VideoMonitor::open (std::string filename)
querystate();
state_clk_divide = 0;
/* TODO once every two second or so -- state_clk_divide hack below */
- state_connection = ARDOUR_UI::RapidScreenUpdate.connect (sigc::mem_fun (*this, &VideoMonitor::querystate));
+ state_connection = Timers::rapid_connect (sigc::mem_fun (*this, &VideoMonitor::querystate));
}
sync_by_manual_seek = true;
- clock_connection = ARDOUR_UI::FPSUpdate.connect (sigc::mem_fun (*this, &VideoMonitor::srsupdate));
+ clock_connection = Timers::fps_connect (sigc::mem_fun (*this, &VideoMonitor::srsupdate));
xjadeo_sync_setup();
}
@@ -570,7 +570,7 @@ VideoMonitor::xjadeo_sync_setup ()
process->write_to_stdin("jack connect\n");
} else {
process->write_to_stdin("jack disconnect\n");
- clock_connection = ARDOUR_UI::FPSUpdate.connect (sigc::mem_fun (*this, &VideoMonitor::srsupdate));
+ clock_connection = Timers::fps_connect (sigc::mem_fun (*this, &VideoMonitor::srsupdate));
}
sync_by_manual_seek = my_manual_seek;
}
diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript
index d2aa69226d..047e943581 100644
--- a/gtk2_ardour/wscript
+++ b/gtk2_ardour/wscript
@@ -231,6 +231,7 @@ gtk2_ardour_sources = [
'time_fx_dialog.cc',
'time_info_box.cc',
'time_selection.cc',
+ 'timers.cc',
'track_selection.cc',
'track_view_list.cc',
'transform_dialog.cc',