changeset 438:d6051a60aae2 trunk

[svn] Smarter algorithm for detecting differentials between button presses, now takes seconds into account. (I borrowed this from Atheme's lag detection code. :P)
author nenolod
date Sat, 14 Jan 2006 18:19:36 -0800
parents eb17963bc142
children 3c43e25ddc7d
files audacious/mainwin.c
diffstat 1 files changed, 10 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/audacious/mainwin.c	Sat Jan 14 18:12:15 2006 -0800
+++ b/audacious/mainwin.c	Sat Jan 14 18:19:36 2006 -0800
@@ -1935,14 +1935,15 @@
 mainwin_rev_release(void)
 {
     GTimeVal now_time;
+    GTimeVal delta_time;
     glong now_dur;
 
     g_get_current_time(&now_time);
 
-    now_time.tv_usec *= now_time.tv_sec;
-    cb_time.tv_usec *= cb_time.tv_sec;
-
-    now_dur = (now_time.tv_usec - cb_time.tv_usec) / 1000;
+    delta_time.tv_usec = now_time.tv_usec - cb_time.tv_usec;
+    delta_time.tv_sec = now_time.tv_sec - cb_time.tv_sec;
+
+    now_dur = (delta_time.tv_sec * 1000) + (glong) (delta_time.tv_usec / 1000);
 
     if (now_dur <= 150 && now_dur >= -150)
 	playlist_prev();
@@ -1962,14 +1963,15 @@
 mainwin_fwd_release(void)
 {
     GTimeVal now_time;
+    GTimeVal delta_time;
     glong now_dur;
 
     g_get_current_time(&now_time);
 
-    now_time.tv_usec *= now_time.tv_sec;
-    cb_time.tv_usec *= cb_time.tv_sec;
-
-    now_dur = (now_time.tv_usec - cb_time.tv_usec) / 1000;
+    delta_time.tv_usec = now_time.tv_usec - cb_time.tv_usec;
+    delta_time.tv_sec = now_time.tv_sec - cb_time.tv_sec;
+
+    now_dur = (delta_time.tv_sec * 1000) + (glong) (delta_time.tv_usec / 1000);
 
     if (now_dur <= 150 && now_dur >= -150)
 	playlist_next();