[snappy] ui: clarify usage of GST time unit macros



commit b30d53242b8ff9fb36272ca0120430622cbf045f
Author: Luis de Bethencourt <luis debethencourt com>
Date:   Tue May 15 10:51:26 2012 +0100

    ui: clarify usage of GST time unit macros
    
    g_timeout_add and clutter_actor_animate expect milliseconds but GST_SECOND is
    in nano. so to fix the units differnce use glib's G_TIME_SPAN_MILLISECOND
    (which is 1000) to increase code readability.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=675353

 src/user_interface.c |   15 ++++++++-------
 src/user_interface.h |    4 ++--
 2 files changed, 10 insertions(+), 9 deletions(-)
---
diff --git a/src/user_interface.c b/src/user_interface.c
index 22895e9..8d385e2 100644
--- a/src/user_interface.c
+++ b/src/user_interface.c
@@ -701,15 +701,15 @@ position_ns_to_str (gint64 nanoseconds)
 static void
 progress_timing (UserInterface * ui)
 {
-  gint64 duration_ns;
+  gint64 duration_ms;
   gint64 timeout_ms;
 
   if (ui->progress_id != -1)
     g_source_remove (ui->progress_id);
 
-  duration_ns = ui->engine->media_duration / GST_MSECOND;
-  if (duration_ns > 0) {
-    timeout_ms = MAX (250, duration_ns / ui->seek_width);
+  duration_ms = ui->engine->media_duration / GST_MSECOND;
+  if (duration_ms > 0) {
+    timeout_ms = MAX (250, duration_ms / ui->seek_width);
     ui->progress_id = g_timeout_add (timeout_ms, progress_update_seekbar, ui);
   }
 }
@@ -1196,8 +1196,8 @@ interface_start (UserInterface * ui, gchar * uri)
       clutter_align_constraint_new (ui->stage, CLUTTER_ALIGN_Y_AXIS, 0.5));
 
   clutter_stage_hide_cursor (CLUTTER_STAGE (ui->stage));
-  clutter_actor_animate (ui->control_box, CLUTTER_EASE_OUT_QUINT, GST_USECOND,
-      "opacity", 0, NULL);
+  clutter_actor_animate (ui->control_box, CLUTTER_EASE_OUT_QUINT,
+      G_TIME_SPAN_MILLISECOND, "opacity", 0, NULL);
 
   g_signal_connect (CLUTTER_STAGE (ui->stage), "allocation-changed",
       G_CALLBACK (size_change), ui);
@@ -1209,7 +1209,8 @@ interface_start (UserInterface * ui, gchar * uri)
   ui->screensaver = screensaver_new (CLUTTER_STAGE (ui->stage));
   screensaver_enable (ui->screensaver, FALSE);
 
-  g_timeout_add (GST_USECOND, progress_update_text, ui);
+  g_timeout_add (G_TIME_SPAN_MILLISECOND, progress_update_text,
+      ui);
 
   if (!ui->blind)
     clutter_actor_show (ui->stage);
diff --git a/src/user_interface.h b/src/user_interface.h
index b4974ed..a7525dc 100644
--- a/src/user_interface.h
+++ b/src/user_interface.h
@@ -27,7 +27,7 @@
 #include "screensaver.h"
 
 #define CTL_SHOW_SEC 3
-#define CTL_FADE_DURATION 250
+#define CTL_FADE_DURATION G_TIME_SPAN_MILLISECOND / 4
 
 #define CTL_BORDER 0
 #define SHADOW_CORRECT 15
@@ -60,7 +60,7 @@
 #define SEC_IN_HOUR 3600
 #define SEC_IN_MIN 60
 
-#define PENALTY_TIME 500
+#define PENALTY_TIME G_TIME_SPAN_MILLISECOND / 2
 
 G_BEGIN_DECLS
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]