summaryrefslogtreecommitdiff
path: root/gtk2_ardour/ardour_ui.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2014-10-25 19:21:15 +0200
committerRobin Gareus <robin@gareus.org>2014-10-25 19:21:15 +0200
commitbaea04713f6a4f96e42bb8f3ed80446cd722f253 (patch)
treec2d54b5f98469d089db301502a73fe287244428d /gtk2_ardour/ardour_ui.cc
parente02efddb219df379869a4362fa939be36b2aa1f1 (diff)
combine short periodic timeout functions for windows.
Fixes excessive CPU usage (spinlock instead of sleep/WaitForSingleObject) MS Windows has a scheduler time-slice of 15ms. Ardour has two fast timeout functions: The FPS timeout (20-60Hz, clock video-monitor) and a fast-screen-update (25Hz, meters etc). They are loosely coupled (async) and scheduled from the main application thread (gtk main). Since they're async, gtk schedules them as needed. Even though the actual period of the separate timeouts is larger. The effective period between all timeout callbacks is <15ms and the main application thread never idles.
Diffstat (limited to 'gtk2_ardour/ardour_ui.cc')
-rw-r--r--gtk2_ardour/ardour_ui.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc
index 133e991a06..aeac8a1637 100644
--- a/gtk2_ardour/ardour_ui.cc
+++ b/gtk2_ardour/ardour_ui.cc
@@ -1006,7 +1006,9 @@ 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();
}
@@ -1159,6 +1161,9 @@ gint
ARDOUR_UI::every_fps ()
{
FPSUpdate(); /* EMIT_SIGNAL */
+#ifdef PLATFORM_WINDOWS
+ every_point_zero_something_seconds();
+#endif
return TRUE;
}
@@ -1178,7 +1183,17 @@ ARDOUR_UI::set_fps_timeout_connection ()
* _session->frame_rate() / _session->nominal_frame_rate()
/ _session->timecode_frames_per_second()
);
+#ifdef PLATFORM_WINDOWS
+ // the smallest windows scheduler time-slice is ~15ms.
+ // periodic GUI timeouts shorter than that will cause
+ // WaitForSingleObject to spinlock (100% of one CPU Core)
+ // and gtk never enters idle mode.
+ // also changing timeBeginPeriod(1) does not affect that in
+ // any beneficial way, so we just limit the max rate for now.
+ interval = std::max(30u, interval); // at most ~33Hz.
+#else
interval = std::max(8u, interval); // at most 120Hz.
+#endif
}
fps_connection.disconnect();
fps_connection = Glib::signal_timeout().connect (sigc::mem_fun(*this, &ARDOUR_UI::every_fps), interval);