View Issue Details

IDProjectCategoryView StatusLast Update
0005157ardourbugspublic2015-09-18 15:27
Reportercolinf Assigned Topaul  
PrioritynormalSeveritytrivialReproducibilityalways
Status closedResolutionfixed 
Summary0005157: Ardour's wall clock time display lags
DescriptionThe wall-clock time displayed in the status bar only appears to be updated once per minute, so it can lag the computer's actual wall-clock by up to that amount.

Would updating it once per second be overkill?
TagsNo tags attached.

Activities

paul

2012-11-06 18:06

administrator   ~0014180

i think its overkill, but i see your point. i think we have a timeout set for every second already ...

2012-11-30 17:12

 

wall-clock-seconds-update.patch (1,013 bytes)   
Index: gtk2_ardour/ardour_ui.cc
===================================================================
--- gtk2_ardour/ardour_ui.cc	(revision 13572)
+++ gtk2_ardour/ardour_ui.cc	(working copy)
@@ -426,7 +426,7 @@
 #ifndef GTKOSX
 	/* OS X provides a nearly-always visible wallclock, so don't be stupid */
 	update_wall_clock ();
-	Glib::signal_timeout().connect (sigc::mem_fun(*this, &ARDOUR_UI::update_wall_clock), 60000);
+	Glib::signal_timeout().connect_seconds (sigc::mem_fun(*this, &ARDOUR_UI::update_wall_clock), 1);
 #endif
 
 	update_disk_space ();
@@ -1097,14 +1097,17 @@
 {
 	time_t now;
 	struct tm *tm_now;
-	char buf[16];
+	static int last_min = -1;
 
 	time (&now);
 	tm_now = localtime (&now);
+	if (last_min != tm_now->tm_min) {
+		char buf[16];
+		sprintf (buf, "%02d:%02d", tm_now->tm_hour, tm_now->tm_min);
+		wall_clock_label.set_text (buf);
+		last_min = tm_now->tm_min;
+	}
 
-	sprintf (buf, "%02d:%02d", tm_now->tm_hour, tm_now->tm_min);
-	wall_clock_label.set_text (buf);
-
 	return TRUE;
 }

colinf

2012-11-30 17:26

updater   ~0014307

Using Glib::signal_timeout().connect_seconds() gets a timer with accuracy to the nearest second, which will share a wakeup with any other timer that fires at a close-enough time, so I think that's the right thing to do here.

Also, as a tiny optimisation, we don't need to update wall_clock_label unless it's actually changed: I've done this with an old-skool static variable. If anyone has an idea of how to do that better, or thinks it's unnecessary, I'm not at all attached to the idea, but otherwise I'll commit the patch above.

x42

2012-12-26 16:17

administrator   ~0014392

Glib::signal_timeout() is in milli-seconds.

surely 1 sec accuracy is sufficient for a minute clock.
Calling it every ms is not a good idea.

otherwise +1 for applying this patch.

paul

2012-12-26 16:44

administrator   ~0014393

applied, with a 1 second timeout

colinf

2015-09-18 15:27

updater   ~0017306

Closing old issues reported by me: these have long since been fixed.

Issue History

Date Modified Username Field Change
2012-11-01 19:52 colinf New Issue
2012-11-06 18:06 paul Note Added: 0014180
2012-11-30 17:12 colinf File Added: wall-clock-seconds-update.patch
2012-11-30 17:26 colinf Note Added: 0014307
2012-12-26 16:17 x42 Note Added: 0014392
2012-12-26 16:44 paul cost => 0.00
2012-12-26 16:44 paul Note Added: 0014393
2012-12-26 16:44 paul Status new => resolved
2012-12-26 16:44 paul Resolution open => fixed
2012-12-26 16:44 paul Assigned To => paul
2015-09-18 15:27 colinf Note Added: 0017306
2015-09-18 15:27 colinf Status resolved => closed