diff options
author | Robin Gareus <robin@gareus.org> | 2014-08-30 20:57:22 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2014-08-30 20:57:22 +0200 |
commit | 16443f44a2664bef2b3cd4c33ecaa34e8b453e1b (patch) | |
tree | 93e82144201e5ab5c48ab3257f7d900f4621c5a2 | |
parent | 01864b43e08953b89db5ff7995427a1498487a13 (diff) |
add an idle callback at FPS
-rw-r--r-- | gtk2_ardour/ardour_ui.cc | 31 | ||||
-rw-r--r-- | gtk2_ardour/ardour_ui.h | 7 | ||||
-rw-r--r-- | gtk2_ardour/ardour_ui_dialogs.cc | 2 | ||||
-rw-r--r-- | gtk2_ardour/ardour_ui_options.cc | 5 |
4 files changed, 45 insertions, 0 deletions
diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index f75d9276ce..c4baba4a10 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -151,6 +151,7 @@ UIConfiguration *ARDOUR_UI::ui_config = 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; @@ -992,6 +993,7 @@ If you still wish to quit, please use the\n\n\ second_connection.disconnect (); point_one_second_connection.disconnect (); point_zero_something_second_connection.disconnect(); + fps_connection.disconnect(); } delete ARDOUR_UI::instance()->video_timeline; @@ -1139,6 +1141,35 @@ ARDOUR_UI::every_point_zero_something_seconds () return TRUE; } +gint +ARDOUR_UI::every_fps () +{ + FPSUpdate(); /* EMIT_SIGNAL */ + return TRUE; +} + +void +ARDOUR_UI::set_fps_timeout_connection () +{ + unsigned int interval = 40; + if (!_session) return; + if (_session->timecode_frames_per_second() != 0) { + /* ideally we'll use a select() to sleep and not accumulate + * idle time to provide a regular periodic signal. + * See linux_vst_gui_support.cc 'elapsed_time_ms'. + * However, that'll require a dedicated thread and cross-thread + * signals to the GUI Thread.. + */ + interval = floor(500. /* update twice per FPS, since Glib::signal_timeout is very irregular */ + * _session->frame_rate() / _session->nominal_frame_rate() + / _session->timecode_frames_per_second() + ); + interval = std::max(8u, interval); // at most 120Hz. + } + fps_connection.disconnect(); + fps_connection = Glib::signal_timeout().connect (sigc::mem_fun(*this, &ARDOUR_UI::every_fps), interval); +} + void ARDOUR_UI::update_sample_rate (framecnt_t) { diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index 3a4ffe6085..cc00b0a16b 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -190,6 +190,9 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr /** 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. * @@ -548,10 +551,14 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr gint every_second (); gint every_point_one_seconds (); gint every_point_zero_something_seconds (); + gint every_fps (); sigc::connection second_connection; sigc::connection point_one_second_connection; sigc::connection point_zero_something_second_connection; + sigc::connection fps_connection; + + void set_fps_timeout_connection (); void open_session (); void open_recent_session (); diff --git a/gtk2_ardour/ardour_ui_dialogs.cc b/gtk2_ardour/ardour_ui_dialogs.cc index f23e91069e..198e1cc86a 100644 --- a/gtk2_ardour/ardour_ui_dialogs.cc +++ b/gtk2_ardour/ardour_ui_dialogs.cc @@ -183,6 +183,7 @@ ARDOUR_UI::set_session (Session *s) 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); point_zero_something_second_connection = Glib::signal_timeout().connect (sigc::mem_fun(*this, &ARDOUR_UI::every_point_zero_something_seconds), 40); + set_fps_timeout_connection(); update_format (); @@ -274,6 +275,7 @@ ARDOUR_UI::unload_session (bool hide_stuff) second_connection.disconnect (); point_one_second_connection.disconnect (); point_zero_something_second_connection.disconnect(); + fps_connection.disconnect(); if (editor_meter) { meter_box.remove(*editor_meter); diff --git a/gtk2_ardour/ardour_ui_options.cc b/gtk2_ardour/ardour_ui_options.cc index f5670dbe80..a1c971bc4e 100644 --- a/gtk2_ardour/ardour_ui_options.cc +++ b/gtk2_ardour/ardour_ui_options.cc @@ -367,6 +367,7 @@ ARDOUR_UI::parameter_changed (std::string p) } else if (p == "sync-source") { synchronize_sync_source_and_video_pullup (); + set_fps_timeout_connection (); } else if (p == "show-track-meters") { editor->toggle_meter_updating(); @@ -426,7 +427,11 @@ ARDOUR_UI::session_parameter_changed (std::string p) { if (p == "native-file-data-format" || p == "native-file-header-format") { update_format (); + } else if (p == "timecode-format") { + set_fps_timeout_connection (); } else if (p == "video-pullup" || p == "timecode-format") { + set_fps_timeout_connection (); + synchronize_sync_source_and_video_pullup (); reset_main_clocks (); editor->queue_visual_videotimeline_update(); |