Move Timers/Timeouts from ARDOUR_UI into functions in timers.h and use PBD::Timers

This commit is contained in:
Tim Mayberry 2014-12-25 22:02:00 +07:00
parent d606a37204
commit b5c9a92a58
24 changed files with 332 additions and 139 deletions

View file

@ -135,6 +135,7 @@ typedef uint64_t microseconds_t;
#include "startup.h" #include "startup.h"
#include "theme_manager.h" #include "theme_manager.h"
#include "time_axis_view_item.h" #include "time_axis_view_item.h"
#include "timers.h"
#include "utils.h" #include "utils.h"
#include "video_server_dialog.h" #include "video_server_dialog.h"
#include "add_video_dialog.h" #include "add_video_dialog.h"
@ -151,10 +152,6 @@ using namespace std;
ARDOUR_UI *ARDOUR_UI::theArdourUI = 0; 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, framepos_t, bool, framepos_t> ARDOUR_UI::Clock;
sigc::signal<void> ARDOUR_UI::CloseAllDialogs; sigc::signal<void> ARDOUR_UI::CloseAllDialogs;
@ -179,7 +176,6 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir)
, _was_dirty (false) , _was_dirty (false)
, _mixer_on_top (false) , _mixer_on_top (false)
, first_time_engine_run (true) , first_time_engine_run (true)
, blink_timeout_tag (-1)
/* transport */ /* transport */
@ -532,8 +528,6 @@ ARDOUR_UI::post_engine ()
exit (0); exit (0);
} }
blink_timeout_tag = -1;
/* this being a GUI and all, we want peakfiles */ /* this being a GUI and all, we want peakfiles */
AudioFileSource::set_build_peakfiles (true); AudioFileSource::set_build_peakfiles (true);
@ -1009,9 +1003,7 @@ If you still wish to quit, please use the\n\n\
second_connection.disconnect (); second_connection.disconnect ();
point_one_second_connection.disconnect (); point_one_second_connection.disconnect ();
#ifndef PLATFORM_WINDOWS
point_zero_something_second_connection.disconnect(); point_zero_something_second_connection.disconnect();
#endif
fps_connection.disconnect(); fps_connection.disconnect();
} }
@ -1112,7 +1104,7 @@ ARDOUR_UI::ask_about_saving_session (const vector<string>& actions)
} }
gint void
ARDOUR_UI::every_second () ARDOUR_UI::every_second ()
{ {
update_cpu_load (); update_cpu_load ();
@ -1132,23 +1124,19 @@ ARDOUR_UI::every_second ()
_was_dirty = false; _was_dirty = false;
} }
} }
return TRUE;
} }
gint void
ARDOUR_UI::every_point_one_seconds () ARDOUR_UI::every_point_one_seconds ()
{ {
shuttle_box->update_speed_display (); shuttle_box->update_speed_display ();
RapidScreenUpdate(); /* EMIT_SIGNAL */
return TRUE;
} }
gint void
ARDOUR_UI::every_point_zero_something_seconds () ARDOUR_UI::every_point_zero_something_seconds ()
{ {
// august 2007: actual update frequency: 25Hz (40ms), not 100Hz // august 2007: actual update frequency: 25Hz (40ms), not 100Hz
SuperRapidScreenUpdate(); /* EMIT_SIGNAL */
if (editor_meter && ARDOUR_UI::config()->get_show_editor_meter()) { if (editor_meter && ARDOUR_UI::config()->get_show_editor_meter()) {
float mpeak = editor_meter->update_meters(); float mpeak = editor_meter->update_meters();
if (mpeak > editor_meter_max_peak) { 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 void
@ -1199,7 +1176,7 @@ ARDOUR_UI::set_fps_timeout_connection ()
#endif #endif
} }
fps_connection.disconnect(); fps_connection.disconnect();
fps_connection = Glib::signal_timeout().connect (sigc::mem_fun(*this, &ARDOUR_UI::every_fps), interval); Timers::set_fps_interval (interval);
} }
void void
@ -2269,10 +2246,22 @@ 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 void
ARDOUR_UI::update_clocks () 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 */ Clock (_session->audible_frame(), false, editor->get_preferred_edit_position()); /* EMIT_SIGNAL */
} }
} }
@ -2281,9 +2270,9 @@ void
ARDOUR_UI::start_clocking () ARDOUR_UI::start_clocking ()
{ {
if (ui_config->get_super_rapid_clock_update()) { 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 { } 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 (); 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. /** Ask the user for the name of a new snapshot and then take it.
*/ */

View file

@ -193,16 +193,6 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
Gtk::HBox& editor_transport_box() { return _editor_transport_box; } Gtk::HBox& editor_transport_box() { return _editor_transport_box; }
static PublicEditor* _instance; 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 /** Emitted frequently with the audible frame, false, and the edit point as
* parameters respectively. * parameters respectively.
@ -370,13 +360,6 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
void use_config (); 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); void about_signal_response(int response);
Gtk::VBox top_packer; Gtk::VBox top_packer;
@ -479,6 +462,9 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
ArdourButton editor_meter_peak_display; ArdourButton editor_meter_peak_display;
bool editor_meter_peak_button_release (GdkEventButton*); bool editor_meter_peak_button_release (GdkEventButton*);
void blink_handler (bool);
sigc::connection blink_connection;
void solo_blink (bool); void solo_blink (bool);
void sync_blink (bool); void sync_blink (bool);
void audition_blink (bool); void audition_blink (bool);
@ -562,10 +548,9 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
Gtk::Label format_label; Gtk::Label format_label;
void update_format (); void update_format ();
gint every_second (); void every_second ();
gint every_point_one_seconds (); void every_point_one_seconds ();
gint every_point_zero_something_seconds (); void every_point_zero_something_seconds ();
gint every_fps ();
sigc::connection second_connection; sigc::connection second_connection;
sigc::connection point_one_second_connection; sigc::connection point_one_second_connection;

View file

@ -55,6 +55,7 @@
#include "sfdb_ui.h" #include "sfdb_ui.h"
#include "theme_manager.h" #include "theme_manager.h"
#include "time_info_box.h" #include "time_info_box.h"
#include "timers.h"
#include <gtkmm2ext/keyboard.h> #include <gtkmm2ext/keyboard.h>
@ -145,11 +146,7 @@ ARDOUR_UI::set_session (Session *s)
setup_session_options (); setup_session_options ();
Blink.connect (sigc::mem_fun(*this, &ARDOUR_UI::transport_rec_enable_blink)); blink_connection = Timers::blink_connect (sigc::mem_fun(*this, &ARDOUR_UI::blink_handler));
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));
_session->RecordStateChanged.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::record_state_changed, this), gui_context()); _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()); _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)); Glib::signal_idle().connect (sigc::mem_fun (*this, &ARDOUR_UI::first_idle));
start_clocking (); start_clocking ();
start_blinking ();
map_transport_state (); map_transport_state ();
second_connection = Glib::signal_timeout().connect (sigc::mem_fun(*this, &ARDOUR_UI::every_second), 1000); second_connection = Timers::second_connect (sigc::mem_fun(*this, &ARDOUR_UI::every_second));
point_one_second_connection = Glib::signal_timeout().connect (sigc::mem_fun(*this, &ARDOUR_UI::every_point_one_seconds), 100); point_one_second_connection = Timers::rapid_connect (sigc::mem_fun(*this, &ARDOUR_UI::every_point_one_seconds));
#ifndef PLATFORM_WINDOWS point_zero_something_second_connection = Timers::super_rapid_connect (sigc::mem_fun(*this, &ARDOUR_UI::every_point_zero_something_seconds));
point_zero_something_second_connection = Glib::signal_timeout().connect (sigc::mem_fun(*this, &ARDOUR_UI::every_point_zero_something_seconds), 40);
#endif
set_fps_timeout_connection(); set_fps_timeout_connection();
update_format (); update_format ();
@ -287,9 +281,7 @@ ARDOUR_UI::unload_session (bool hide_stuff)
second_connection.disconnect (); second_connection.disconnect ();
point_one_second_connection.disconnect (); point_one_second_connection.disconnect ();
#ifndef PLATFORM_WINDOWS
point_zero_something_second_connection.disconnect(); point_zero_something_second_connection.disconnect();
#endif
fps_connection.disconnect(); fps_connection.disconnect();
if (editor_meter) { if (editor_meter) {
@ -309,12 +301,11 @@ ARDOUR_UI::unload_session (bool hide_stuff)
ARDOUR_UI::instance()->video_timeline->close_session(); ARDOUR_UI::instance()->video_timeline->close_session();
} }
stop_blinking ();
stop_clocking (); stop_clocking ();
/* drop everything attached to the blink signal */ /* drop everything attached to the blink signal */
Blink.clear (); blink_connection.disconnect ();
delete _session; delete _session;
_session = 0; _session = 0;

View file

@ -34,6 +34,7 @@
#include "automation_controller.h" #include "automation_controller.h"
#include "gui_thread.h" #include "gui_thread.h"
#include "note_select_dialog.h" #include "note_select_dialog.h"
#include "timers.h"
#include "i18n.h" #include "i18n.h"
@ -104,7 +105,7 @@ AutomationController::AutomationController(boost::shared_ptr<Automatable>
_adjustment->signal_value_changed().connect( _adjustment->signal_value_changed().connect(
sigc::mem_fun(*this, &AutomationController::value_adjusted)); 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)); sigc::mem_fun (*this, &AutomationController::display_effective_value));
ac->Changed.connect (_changed_connection, invalidator (*this), boost::bind (&AutomationController::value_changed, this), gui_context()); ac->Changed.connect (_changed_connection, invalidator (*this), boost::bind (&AutomationController::value_changed, this), gui_context());

View file

@ -122,6 +122,7 @@
#include "sfdb_ui.h" #include "sfdb_ui.h"
#include "tempo_lines.h" #include "tempo_lines.h"
#include "time_axis_view.h" #include "time_axis_view.h"
#include "timers.h"
#include "utils.h" #include "utils.h"
#include "verbose_cursor.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); (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) sigc::mem_fun (*this, &Editor::super_rapid_screen_update)
); );

View file

@ -43,6 +43,7 @@
#include "public_editor.h" #include "public_editor.h"
#include "utils.h" #include "utils.h"
#include "meter_patterns.h" #include "meter_patterns.h"
#include "timers.h"
#include "ardour/session.h" #include "ardour/session.h"
#include "ardour/route.h" #include "ardour/route.h"
@ -873,7 +874,7 @@ GainMeterBase::gain_automation_state_changed ()
gain_watching.disconnect(); gain_watching.disconnect();
if (x) { 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));
} }
} }

View file

@ -48,6 +48,7 @@
#include "plugin_ui.h" #include "plugin_ui.h"
#include "gui_thread.h" #include "gui_thread.h"
#include "automation_controller.h" #include "automation_controller.h"
#include "timers.h"
#include "i18n.h" #include "i18n.h"
@ -939,8 +940,7 @@ GenericPluginUI::start_updating (GdkEventAny*)
{ {
if (output_controls.size() > 0 ) { if (output_controls.size() > 0 ) {
screen_update_connection.disconnect(); screen_update_connection.disconnect();
screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect screen_update_connection = Timers::super_rapid_connect (sigc::mem_fun(*this, &GenericPluginUI::output_update));
(sigc::mem_fun(*this, &GenericPluginUI::output_update));
} }
return false; return false;
} }

View file

@ -21,8 +21,8 @@
#include "ardour/session.h" #include "ardour/session.h"
#include "pbd/error.h" #include "pbd/error.h"
#include "ardour_ui.h"
#include "lv2_plugin_ui.h" #include "lv2_plugin_ui.h"
#include "timers.h"
#include "lv2/lv2plug.in/ns/extensions/ui/ui.h" #include "lv2/lv2plug.in/ns/extensions/ui/ui.h"
@ -145,7 +145,7 @@ LV2PluginUI::start_updating(GdkEventAny*)
{ {
if (!_output_ports.empty()) { if (!_output_ports.empty()) {
_screen_update_connection.disconnect(); _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)); (sigc::mem_fun(*this, &LV2PluginUI::output_update));
} }
return false; return false;
@ -344,7 +344,7 @@ LV2PluginUI::lv2ui_instantiate(const std::string& title)
} }
if (_lv2->has_message_output()) { 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)); sigc::mem_fun(*this, &LV2PluginUI::update_timeout));
} }
} }
@ -444,10 +444,10 @@ LV2PluginUI::on_window_show(const std::string& title)
_screen_update_connection.disconnect(); _screen_update_connection.disconnect();
_message_update_connection.disconnect(); _message_update_connection.disconnect();
LV2_EXTERNAL_UI_SHOW(_external_ui_ptr); 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)); (sigc::mem_fun(*this, &LV2PluginUI::output_update));
if (_lv2->has_message_output()) { 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)); sigc::mem_fun(*this, &LV2PluginUI::update_timeout));
} }
return false; return false;
@ -460,10 +460,10 @@ LV2PluginUI::on_window_show(const std::string& title)
_screen_update_connection.disconnect(); _screen_update_connection.disconnect();
_message_update_connection.disconnect(); _message_update_connection.disconnect();
LV2_EXTERNAL_UI_SHOW(_external_ui_ptr); 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)); (sigc::mem_fun(*this, &LV2PluginUI::output_update));
if (_lv2->has_message_output()) { 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)); sigc::mem_fun(*this, &LV2PluginUI::update_timeout));
} }
return false; return false;

View file

@ -20,7 +20,7 @@
#include "ardour/lxvst_plugin.h" #include "ardour/lxvst_plugin.h"
#include "ardour/linux_vst_support.h" #include "ardour/linux_vst_support.h"
#include "lxvst_plugin_ui.h" #include "lxvst_plugin_ui.h"
#include "ardour_ui.h" #include "timers.h"
#include <gdk/gdkx.h> #include <gdk/gdkx.h>
#define LXVST_H_FIDDLE 40 #define LXVST_H_FIDDLE 40
@ -49,7 +49,7 @@ bool
LXVSTPluginUI::start_updating (GdkEventAny*) LXVSTPluginUI::start_updating (GdkEventAny*)
{ {
_screen_update_connection.disconnect(); _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; return false;
} }

View file

@ -54,6 +54,7 @@
#include "gui_thread.h" #include "gui_thread.h"
#include "global_signals.h" #include "global_signals.h"
#include "meter_patterns.h" #include "meter_patterns.h"
#include "timers.h"
#include "i18n.h" #include "i18n.h"
@ -555,7 +556,7 @@ Meterbridge::get_state (void)
gint gint
Meterbridge::start_updating () 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; return 0;
} }

View file

@ -57,6 +57,7 @@
#include "actions.h" #include "actions.h"
#include "gui_thread.h" #include "gui_thread.h"
#include "mixer_group_tabs.h" #include "mixer_group_tabs.h"
#include "timers.h"
#include "i18n.h" #include "i18n.h"
@ -884,7 +885,7 @@ Mixer_UI::hide_strip (MixerStrip* ms)
gint gint
Mixer_UI::start_updating () 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; return 0;
} }

View file

@ -37,6 +37,7 @@
#include "gui_thread.h" #include "gui_thread.h"
#include "monitor_section.h" #include "monitor_section.h"
#include "public_editor.h" #include "public_editor.h"
#include "timers.h"
#include "volume_controller.h" #include "volume_controller.h"
#include "utils.h" #include "utils.h"
@ -104,7 +105,7 @@ MonitorSection::MonitorSection (Session* s)
rude_audition_button.set_name ("rude audition"); rude_audition_button.set_name ("rude audition");
rude_audition_button.show (); 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); 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")); UI::instance()->set_tip (rude_solo_button, _("When active, something is soloed.\nClick to de-solo everything"));

View file

@ -32,6 +32,7 @@
#include "panner2d.h" #include "panner2d.h"
#include "gui_thread.h" #include "gui_thread.h"
#include "stereo_panner.h" #include "stereo_panner.h"
#include "timers.h"
#include "mono_panner.h" #include "mono_panner.h"
#include "i18n.h" #include "i18n.h"
@ -576,7 +577,7 @@ PannerUI::pan_automation_state_changed ()
pan_watching.disconnect(); pan_watching.disconnect();
if (x) { 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));
} }
} }

View file

@ -76,6 +76,7 @@
#include "return_ui.h" #include "return_ui.h"
#include "route_processor_selection.h" #include "route_processor_selection.h"
#include "send_ui.h" #include "send_ui.h"
#include "timers.h"
#include "i18n.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 ()); 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 (); control_changed ();
set_tooltip (); set_tooltip ();

View file

@ -25,8 +25,8 @@
#include "return_ui.h" #include "return_ui.h"
#include "io_selector.h" #include "io_selector.h"
#include "ardour_ui.h"
#include "gui_thread.h" #include "gui_thread.h"
#include "timers.h"
#include "i18n.h" #include "i18n.h"
@ -62,8 +62,8 @@ ReturnUI::ReturnUI (Gtk::Window* parent, boost::shared_ptr<Return> r, Session* s
_gpm.setup_meters (); _gpm.setup_meters ();
_gpm.set_fader_name (X_("ReturnUIFader")); _gpm.set_fader_name (X_("ReturnUIFader"));
// screen_update_connection = ARDOUR_UI::instance()->RapidScreenUpdate.connect (sigc::mem_fun (*this, &ReturnUI::update)); // screen_update_connection = Timers::rapid_connect (sigc::mem_fun (*this, &ReturnUI::update));
fast_screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect (sigc::mem_fun (*this, &ReturnUI::fast_update)); fast_screen_update_connection = Timers::super_rapid_connect (sigc::mem_fun (*this, &ReturnUI::fast_update));
} }
ReturnUI::~ReturnUI () ReturnUI::~ReturnUI ()

View file

@ -46,6 +46,7 @@
#include "return_ui.h" #include "return_ui.h"
#include "route_params_ui.h" #include "route_params_ui.h"
#include "send_ui.h" #include "send_ui.h"
#include "timers.h"
#include "i18n.h" #include "i18n.h"
@ -642,7 +643,7 @@ RouteParams_UI::update_title ()
void void
RouteParams_UI::start_updating () RouteParams_UI::start_updating ()
{ {
update_connection = ARDOUR_UI::instance()->RapidScreenUpdate.connect update_connection = Timers::rapid_connect
(sigc::mem_fun(*this, &RouteParams_UI::update_views)); (sigc::mem_fun(*this, &RouteParams_UI::update_views));
} }

View file

@ -46,6 +46,7 @@
#include "automation_time_axis.h" #include "automation_time_axis.h"
#include "route_time_axis.h" #include "route_time_axis.h"
#include "group_tabs.h" #include "group_tabs.h"
#include "timers.h"
#include "ardour/audio_track.h" #include "ardour/audio_track.h"
#include "ardour/audioengine.h" #include "ardour/audioengine.h"
@ -147,7 +148,7 @@ RouteUI::init ()
UI::instance()->set_tip (rec_enable_button, _("Enable recording on this track"), ""); UI::instance()->set_tip (rec_enable_button, _("Enable recording on this track"), "");
if (ARDOUR_UI::config()->get_blink_rec_arm()) { 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); show_sends_button = manage (new ArdourButton);
@ -1924,7 +1925,7 @@ RouteUI::parameter_changed (string const & p)
} else if (p == "blink-rec-arm") { } else if (p == "blink-rec-arm") {
if (ARDOUR_UI::config()->get_blink_rec_arm()) { if (ARDOUR_UI::config()->get_blink_rec_arm()) {
rec_blink_connection.disconnect (); 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 { } else {
rec_blink_connection.disconnect (); rec_blink_connection.disconnect ();
RouteUI::blink_rec_display(false); RouteUI::blink_rec_display(false);
@ -2220,7 +2221,7 @@ RouteUI::bus_send_display_changed (boost::shared_ptr<Route> send_to)
{ {
if (_route == send_to) { if (_route == send_to) {
show_sends_button->set_active (true); 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 { } else {
show_sends_button->set_active (false); show_sends_button->set_active (false);
send_blink_connection.disconnect (); send_blink_connection.disconnect ();

View file

@ -26,7 +26,7 @@
#include "send_ui.h" #include "send_ui.h"
#include "io_selector.h" #include "io_selector.h"
#include "ardour_ui.h" #include "timers.h"
#include "gui_thread.h" #include "gui_thread.h"
#include "i18n.h" #include "i18n.h"
@ -80,9 +80,9 @@ SendUI::SendUI (Gtk::Window* parent, boost::shared_ptr<Send> s, Session* session
_gpm.setup_meters (); _gpm.setup_meters ();
_gpm.set_fader_name (X_("SendUIFader")); _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)); // 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)); sigc::mem_fun (*this, &SendUI::fast_update));
} }

View file

@ -68,6 +68,7 @@
#include "gain_meter.h" #include "gain_meter.h"
#include "main_clock.h" #include "main_clock.h"
#include "public_editor.h" #include "public_editor.h"
#include "timers.h"
#include "sfdb_freesound_mootcher.h" #include "sfdb_freesound_mootcher.h"
@ -856,7 +857,7 @@ SoundFileBrowser::remove_gain_meter ()
void void
SoundFileBrowser::start_metering () 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 void

View file

@ -41,6 +41,7 @@
#include "selection.h" #include "selection.h"
#include "public_editor.h" #include "public_editor.h"
#include "ardour_ui.h" #include "ardour_ui.h"
#include "timers.h"
#include "rgb_macros.h" #include "rgb_macros.h"
#include "gui_thread.h" #include "gui_thread.h"
#include "utils.h" #include "utils.h"
@ -434,8 +435,7 @@ StreamView::create_rec_box(framepos_t frame_pos, double width)
rec_rects.push_back (recbox); rec_rects.push_back (recbox);
screen_update_connection.disconnect(); screen_update_connection.disconnect();
screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect( screen_update_connection = Timers::rapid_connect (sigc::mem_fun(*this, &StreamView::update_rec_box));
sigc::mem_fun(*this, &StreamView::update_rec_box));
rec_updating = true; rec_updating = true;
rec_active = true; rec_active = true;

210
gtk2_ardour/timers.cc Normal file
View file

@ -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

42
gtk2_ardour/timers.h Normal file
View file

@ -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

View file

@ -20,7 +20,7 @@
#include "pbd/file_utils.h" #include "pbd/file_utils.h"
#include "pbd/convert.h" #include "pbd/convert.h"
#include "gui_thread.h" #include "gui_thread.h"
#include "ardour_ui.h" #include "timers.h"
#include "utils.h" #include "utils.h"
#include <stdio.h> #include <stdio.h>
@ -159,10 +159,10 @@ VideoMonitor::open (std::string filename)
querystate(); querystate();
state_clk_divide = 0; state_clk_divide = 0;
/* TODO once every two second or so -- state_clk_divide hack below */ /* 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; 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(); xjadeo_sync_setup();
} }
@ -570,7 +570,7 @@ VideoMonitor::xjadeo_sync_setup ()
process->write_to_stdin("jack connect\n"); process->write_to_stdin("jack connect\n");
} else { } else {
process->write_to_stdin("jack disconnect\n"); 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; sync_by_manual_seek = my_manual_seek;
} }

View file

@ -231,6 +231,7 @@ gtk2_ardour_sources = [
'time_fx_dialog.cc', 'time_fx_dialog.cc',
'time_info_box.cc', 'time_info_box.cc',
'time_selection.cc', 'time_selection.cc',
'timers.cc',
'track_selection.cc', 'track_selection.cc',
'track_view_list.cc', 'track_view_list.cc',
'transform_dialog.cc', 'transform_dialog.cc',