[vlc-commits] core: replace hardcoded CLOCK_FREQ fractions by VLC_TICK_FROM_MS()

Steve Lhomme git at videolan.org
Tue Jul 3 09:00:48 CEST 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Jul  3 08:48:08 2018 +0200| [b18d95bc829b2b604ee0fbcb78236c09917c7fc4] | committer: Steve Lhomme

core: replace hardcoded CLOCK_FREQ fractions by VLC_TICK_FROM_MS()

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b18d95bc829b2b604ee0fbcb78236c09917c7fc4
---

 src/clock/input_clock.c          |  2 +-
 src/input/decoder.c              |  2 +-
 src/input/es_out.c               |  6 +++---
 src/input/input.c                |  8 ++++----
 src/test/timer.c                 |  8 ++++----
 src/video_output/display.c       |  2 +-
 src/video_output/video_output.c  | 10 +++++-----
 src/video_output/video_widgets.c |  2 +-
 src/video_output/vout_intf.c     |  2 +-
 src/video_output/window.c        |  2 +-
 10 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/src/clock/input_clock.c b/src/clock/input_clock.c
index 5adf4f5c4c..2ffe164890 100644
--- a/src/clock/input_clock.c
+++ b/src/clock/input_clock.c
@@ -252,7 +252,7 @@ void input_clock_Update( input_clock_t *cl, vlc_object_t *p_log,
 
         AvgUpdate( &cl->drift, i_converted - i_ck_stream );
 
-        cl->i_next_drift_update = i_ck_system + CLOCK_FREQ/5; /* FIXME why that */
+        cl->i_next_drift_update = i_ck_system + VLC_TICK_FROM_MS(200); /* FIXME why that */
     }
 
     /* Update the extra buffering value */
diff --git a/src/input/decoder.c b/src/input/decoder.c
index 58ead05738..2b8298bc58 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -148,7 +148,7 @@ struct decoder_owner
 #define DECODER_BOGUS_VIDEO_DELAY                ((vlc_tick_t)(DEFAULT_PTS_DELAY * 30))
 
 /* */
-#define DECODER_SPU_VOUT_WAIT_DURATION   (CLOCK_FREQ/5)
+#define DECODER_SPU_VOUT_WAIT_DURATION   VLC_TICK_FROM_MS(200)
 #define BLOCK_FLAG_CORE_PRIVATE_RELOADED (1 << BLOCK_FLAG_CORE_PRIVATE_SHIFT)
 
 #define VLC_TS_OLDEST  (VLC_TICK_INVALID + 1)
diff --git a/src/input/es_out.c b/src/input/es_out.c
index 620d6bddff..57ba48a08e 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -703,7 +703,7 @@ static void EsOutDecodersStopBuffering( es_out_t *out, bool b_forced )
     input_resource_TerminateVout( input_priv(p_sys->p_input)->p_resource );
 
     /* */
-    const vlc_tick_t i_wakeup_delay = CLOCK_FREQ/100; /* FIXME CLEANUP thread wake up time*/
+    const vlc_tick_t i_wakeup_delay = VLC_TICK_FROM_MS(10); /* FIXME CLEANUP thread wake up time*/
     const vlc_tick_t i_current_date = p_sys->b_paused ? p_sys->i_pause_date : vlc_tick_now();
 
     input_clock_ChangeSystemOrigin( p_sys->p_pgrm->p_input_clock, true,
@@ -825,7 +825,7 @@ static void EsOutFrameNext( es_out_t *out )
     msg_Dbg( p_sys->p_input, "EsOutFrameNext consummed %d ms", (int)(i_duration/1000) );
 
     if( i_duration <= 0 )
-        i_duration = CLOCK_FREQ/25;
+        i_duration = VLC_TICK_FROM_MS(40);
 
     /* FIXME it is not a clean way ? */
     if( p_sys->i_buffering_extra_initial <= 0 )
@@ -2163,7 +2163,7 @@ static void EsOutDel( es_out_t *out, es_out_id_t *es )
                 break;
             /* FIXME there should be a way to have auto deleted es, but there will be
              * a problem when another codec of the same type is created (mainly video) */
-            vlc_tick_sleep( CLOCK_FREQ/50 );
+            vlc_tick_sleep(VLC_TICK_FROM_MS(20));
         }
         EsUnselect( out, es, es->p_pgrm == p_sys->p_pgrm );
     }
diff --git a/src/input/input.c b/src/input/input.c
index fdc1583d56..f279ea78a8 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -769,7 +769,7 @@ static void MainLoop( input_thread_t *p_input, bool b_interactive )
             if( now >= i_intf_update )
             {
                 MainLoopStatistics( p_input );
-                i_intf_update = now + CLOCK_FREQ/4;
+                i_intf_update = now + VLC_TICK_FROM_MS(250);
             }
         }
 
@@ -787,9 +787,9 @@ static void MainLoop( input_thread_t *p_input, bool b_interactive )
                 vlc_tick_t now = vlc_tick_now();
 
                 /* Recheck ES buffer level every 20 ms when seeking */
-                if( now < i_last_seek_mdate + CLOCK_FREQ/8
-                 && (i_deadline < 0 || i_deadline > now + CLOCK_FREQ/50) )
-                    i_deadline = now + CLOCK_FREQ/50;
+                if( now < i_last_seek_mdate + VLC_TICK_FROM_MS(125)
+                 && (i_deadline < 0 || i_deadline > now + VLC_TICK_FROM_MS(20)) )
+                    i_deadline = now + VLC_TICK_FROM_MS(20);
                 else
                     b_postpone = false;
             }
diff --git a/src/test/timer.c b/src/test/timer.c
index 8369d1636a..e287c1548e 100644
--- a/src/test/timer.c
+++ b/src/test/timer.c
@@ -75,7 +75,7 @@ int main (void)
 
     /* Relative timer */
     ts = vlc_tick_now ();
-    vlc_timer_schedule (data.timer, false, 1, CLOCK_FREQ / 100);
+    vlc_timer_schedule (data.timer, false, 1, VLC_TICK_FROM_MS(10));
 
     vlc_mutex_lock (&data.lock);
     while (data.count <= 10)
@@ -92,8 +92,8 @@ int main (void)
     /* Absolute timer */
     ts = vlc_tick_now ();
 
-    vlc_timer_schedule (data.timer, true, ts + CLOCK_FREQ / 10,
-                        CLOCK_FREQ / 100);
+    vlc_timer_schedule (data.timer, true, ts + VLC_TICK_FROM_MS(100),
+                        VLC_TICK_FROM_MS(10));
 
     vlc_mutex_lock (&data.lock);
     while (data.count <= 10)
@@ -102,7 +102,7 @@ int main (void)
     ts = vlc_tick_now () - ts;
     printf ("%u iterations in %"PRId64" us\n", data.count, ts);
     vlc_mutex_unlock (&data.lock);
-    assert(ts >= (CLOCK_FREQ / 5));
+    assert(ts >= VLC_TICK_FROM_MS(200));
 
     vlc_timer_destroy (data.timer);
     vlc_cond_destroy (&data.wait);
diff --git a/src/video_output/display.c b/src/video_output/display.c
index d8168fdf01..7f0b16c937 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -513,7 +513,7 @@ static void VoutDisplayEventMouse(vout_display_t *vd, int event, va_list args)
         vlc_mouse_HasPressed(&osys->mouse.state, &m, MOUSE_BUTTON_LEFT)) {
         const vlc_tick_t i_date = vlc_tick_now();
 
-        if (i_date - osys->mouse.last_pressed < 3*CLOCK_FREQ/10 ) {
+        if (i_date - osys->mouse.last_pressed < VLC_TICK_FROM_MS(300) ) {
             m.b_double_click = true;
             osys->mouse.last_pressed = 0;
         } else {
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index f413a6d795..ac51d4437b 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -64,15 +64,15 @@ static void VoutDestructor(vlc_object_t *);
 /* Maximum delay between 2 displayed pictures.
  * XXX it is needed for now but should be removed in the long term.
  */
-#define VOUT_REDISPLAY_DELAY (4*CLOCK_FREQ/50)
+#define VOUT_REDISPLAY_DELAY VLC_TICK_FROM_MS(80)
 
 /**
  * Late pictures having a delay higher than this value are thrashed.
  */
-#define VOUT_DISPLAY_LATE_THRESHOLD (CLOCK_FREQ/50)
+#define VOUT_DISPLAY_LATE_THRESHOLD VLC_TICK_FROM_MS(20)
 
 /* Better be in advance when awakening than late... */
-#define VOUT_MWAIT_TOLERANCE (CLOCK_FREQ/250)
+#define VOUT_MWAIT_TOLERANCE VLC_TICK_FROM_MS(4)
 
 /* */
 static int VoutValidateFormat(video_format_t *dst,
@@ -1578,7 +1578,7 @@ static void ThreadInit(vout_thread_t *vout)
     vout->p->pause.is_on     = false;
     vout->p->pause.date      = VLC_TICK_INVALID;
 
-    vout_chrono_Init(&vout->p->render, 5, CLOCK_FREQ/100); /* Arbitrary initial time */
+    vout_chrono_Init(&vout->p->render, 5, VLC_TICK_FROM_MS(10)); /* Arbitrary initial time */
 }
 
 static void ThreadClean(vout_thread_t *vout)
@@ -1781,7 +1781,7 @@ static void *Thread(void *object)
 
         if (wait)
         {
-            const vlc_tick_t max_deadline = vlc_tick_now() + CLOCK_FREQ/10;
+            const vlc_tick_t max_deadline = vlc_tick_now() + VLC_TICK_FROM_MS(100);
             deadline = deadline == VLC_TICK_INVALID ? max_deadline : __MIN(deadline, max_deadline);
         } else {
             deadline = VLC_TICK_INVALID;
diff --git a/src/video_output/video_widgets.c b/src/video_output/video_widgets.c
index 2c7e4ac92d..ae75baef41 100644
--- a/src/video_output/video_widgets.c
+++ b/src/video_output/video_widgets.c
@@ -320,7 +320,7 @@ static void OSDWidget(vout_thread_t *vout, int channel, int type, int position)
 
     subpic->i_channel  = channel;
     subpic->i_start    = vlc_tick_now();
-    subpic->i_stop     = subpic->i_start + 12*CLOCK_FREQ/10;
+    subpic->i_stop     = subpic->i_start + VLC_TICK_FROM_MS(1200);
     subpic->b_ephemer  = true;
     subpic->b_absolute = true;
     subpic->b_fade     = true;
diff --git a/src/video_output/vout_intf.c b/src/video_output/vout_intf.c
index 3ab4cf5e0b..28022ef2d5 100644
--- a/src/video_output/vout_intf.c
+++ b/src/video_output/vout_intf.c
@@ -377,7 +377,7 @@ static void VoutSaveSnapshot( vout_thread_t *p_vout )
 
     /* 500ms timeout
      * XXX it will cause trouble with low fps video (< 2fps) */
-    if( vout_GetSnapshot( p_vout, &p_image, &p_picture, NULL, psz_format, CLOCK_FREQ/2 ) )
+    if( vout_GetSnapshot( p_vout, &p_image, &p_picture, NULL, psz_format, VLC_TICK_FROM_MS(500) ) )
     {
         p_picture = NULL;
         p_image = NULL;
diff --git a/src/video_output/window.c b/src/video_output/window.c
index 3ce4ba51fb..6f4835d0c0 100644
--- a/src/video_output/window.c
+++ b/src/video_output/window.c
@@ -125,7 +125,7 @@ void vout_window_SetInhibition(vout_window_t *window, bool enabled)
 #include "window.h"
 #include "vout_internal.h"
 
-#define DOUBLE_CLICK_TIME (3 * CLOCK_FREQ / 10)
+#define DOUBLE_CLICK_TIME VLC_TICK_FROM_MS(300)
 
 typedef struct vout_display_window
 {



More information about the vlc-commits mailing list