[vlc-devel] [PATCH 6/6] rename mdate() to vlc_tick_now()

Steve Lhomme robux4 at ycbcr.xyz
Wed Jun 20 08:54:36 CEST 2018


The lua "mdate" remains the same.
---
 include/vlc_aout.h                            |  2 +-
 include/vlc_codec.h                           |  2 +-
 include/vlc_interrupt.h                       |  2 +-
 include/vlc_threads.h                         | 10 ++++-----
 lib/core.c                                    |  2 +-
 modules/access/alsa.c                         |  6 ++---
 modules/access/avcapture.m                    |  2 +-
 modules/access/bluray.c                       |  8 +++----
 modules/access/dc1394.c                       |  4 ++--
 modules/access/dshow/dshow.cpp                |  4 ++--
 modules/access/dshow/filter.cpp               |  2 +-
 modules/access/dtv/bdagraph.cpp               |  2 +-
 modules/access/dtv/en50221.c                  |  8 +++----
 modules/access/dv.c                           |  2 +-
 modules/access/dvb/access.c                   |  6 ++---
 modules/access/dvb/scan.c                     |  8 +++----
 modules/access/idummy.c                       | 12 +++++-----
 modules/access/linsys/linsys_sdi.c            | 22 +++++++++----------
 modules/access/oss.c                          |  4 ++--
 modules/access/pulse.c                        |  2 +-
 modules/access/rdp.c                          |  8 +++----
 modules/access/rtp/input.c                    |  2 +-
 modules/access/rtp/session.c                  |  4 ++--
 modules/access/satip.c                        | 14 ++++++------
 modules/access/screen/screen.c                |  8 +++----
 modules/access/screen/wayland.c               |  6 ++---
 modules/access/screen/xcb.c                   |  2 +-
 modules/access/shm.c                          |  4 ++--
 modules/access/v4l2/access.c                  |  2 +-
 modules/access/v4l2/demux.c                   |  6 ++---
 modules/access/v4l2/radio.c                   |  4 ++--
 modules/access/v4l2/vbi.c                     |  2 +-
 modules/access/v4l2/video.c                   |  2 +-
 modules/access/vnc.c                          |  8 +++----
 modules/access/wasapi.c                       |  6 ++---
 modules/access_output/udp.c                   |  6 ++---
 modules/audio_output/audiotrack.c             | 16 +++++++-------
 modules/audio_output/auhal.c                  |  2 +-
 modules/audio_output/coreaudio_common.c       |  2 +-
 modules/audio_output/pulse.c                  |  2 +-
 modules/codec/avcodec/encoder.c               |  2 +-
 modules/codec/avcodec/video.c                 |  2 +-
 modules/codec/kate.c                          |  4 ++--
 modules/codec/libass.c                        |  4 ++--
 modules/codec/omxil/mediacodec.c              |  2 +-
 modules/codec/omxil/omxil_utils.h             |  2 +-
 modules/codec/omxil/utils.c                   |  6 ++---
 modules/codec/synchro.c                       |  8 +++----
 modules/codec/videotoolbox.m                  |  2 +-
 modules/codec/x265.c                          |  4 ++--
 modules/control/dbus/dbus.c                   |  8 +++----
 modules/control/hotkeys.c                     |  4 ++--
 modules/control/netsync.c                     |  6 ++---
 modules/demux/adaptive/PlaylistManager.cpp    |  8 +++----
 modules/demux/adaptive/http/Chunk.cpp         | 10 ++++-----
 modules/demux/avi/avi.c                       |  6 ++---
 modules/demux/image.c                         |  4 ++--
 modules/demux/mjpeg.c                         |  4 ++--
 modules/demux/mp4/heif.c                      |  4 ++--
 modules/demux/rawdv.c                         |  2 +-
 modules/gui/skins2/x11/x11_loop.cpp           |  2 +-
 modules/gui/skins2/x11/x11_timer.cpp          |  4 ++--
 modules/hw/vdpau/display.c                    |  2 +-
 modules/lua/libs/misc.c                       |  2 +-
 modules/misc/audioscrobbler.c                 | 10 ++++-----
 modules/misc/stats.c                          |  8 +++----
 modules/mux/mpeg/ts.c                         |  2 +-
 modules/services_discovery/microdns.c         |  8 +++----
 modules/services_discovery/sap.c              |  6 ++---
 modules/stream_filter/cache_block.c           | 10 ++++-----
 modules/stream_filter/cache_read.c            | 12 +++++-----
 modules/stream_filter/hds/hds.c               |  2 +-
 modules/stream_out/autodel.c                  |  2 +-
 modules/stream_out/bridge.c                   |  2 +-
 .../stream_out/chromecast/chromecast_ctrl.cpp | 10 ++++-----
 .../chromecast/chromecast_demux.cpp           |  4 ++--
 modules/stream_out/description.c              |  4 ++--
 modules/stream_out/record.c                   |  6 ++---
 modules/stream_out/rtp.c                      |  4 ++--
 modules/stream_out/rtsp.c                     |  4 ++--
 .../text_renderer/freetype/fonts/fontconfig.c |  4 ++--
 modules/video_filter/blendbench.c             |  4 ++--
 modules/video_filter/grain.c                  |  4 ++--
 modules/video_filter/magnify.c                |  6 ++---
 modules/video_filter/oldmovie.c               |  4 ++--
 modules/video_filter/ripple.c                 |  2 +-
 modules/video_filter/vhs.c                    |  4 ++--
 modules/video_filter/wave.c                   |  2 +-
 modules/video_output/android/display.c        |  2 +-
 modules/video_output/caca.c                   |  6 ++---
 modules/video_output/decklink.cpp             |  6 ++---
 modules/video_output/vdummy.c                 |  2 +-
 modules/video_output/wayland/input.c          |  6 ++---
 modules/video_output/win32/events.c           |  2 +-
 modules/video_output/xcb/window.c             |  4 ++--
 modules/visualization/cyclic_buffer.h         |  2 +-
 modules/visualization/goom.c                  |  2 +-
 modules/visualization/projectm.cpp            |  2 +-
 src/android/thread.c                          |  2 +-
 src/audio_output/dec.c                        |  8 +++----
 src/clock/input_clock.c                       |  2 +-
 src/clock/input_clock.h                       |  2 +-
 src/darwin/thread.c                           |  8 +++----
 src/input/decoder.c                           |  2 +-
 src/input/demux_chained.c                     |  4 ++--
 src/input/es_out.c                            | 12 +++++-----
 src/input/es_out_timeshift.c                  | 10 ++++-----
 src/input/input.c                             | 12 +++++-----
 src/input/stats.c                             |  2 +-
 src/libvlccore.sym                            |  2 +-
 src/misc/background_worker.c                  |  8 +++----
 src/misc/image.c                              |  2 +-
 src/misc/threads.c                            |  6 ++---
 src/network/httpd.c                           |  4 ++--
 src/network/tcp.c                             |  4 ++--
 src/network/tls.c                             |  4 ++--
 src/os2/thread.c                              | 10 ++++-----
 src/posix/thread.c                            |  2 +-
 src/posix/timer.c                             |  4 ++--
 src/stream_output/sap.c                       |  4 ++--
 src/stream_output/stream_output.c             |  2 +-
 src/test/timer.c                              |  8 +++----
 src/video_output/chrono.h                     |  4 ++--
 src/video_output/display.c                    |  4 ++--
 src/video_output/interlacing.c                |  6 ++---
 src/video_output/snapshot.c                   |  2 +-
 src/video_output/video_epg.c                  |  2 +-
 src/video_output/video_output.c               | 14 ++++++------
 src/video_output/video_text.c                 |  2 +-
 src/video_output/video_widgets.c              |  2 +-
 src/video_output/vout_intf.c                  |  2 +-
 src/video_output/window.c                     |  2 +-
 src/win32/thread.c                            |  6 ++---
 src/win32/timer.c                             |  2 +-
 134 files changed, 324 insertions(+), 324 deletions(-)

diff --git a/include/vlc_aout.h b/include/vlc_aout.h
index bf05490ae1..5020763977 100644
--- a/include/vlc_aout.h
+++ b/include/vlc_aout.h
@@ -175,7 +175,7 @@ struct audio_output
       * clock and the media upstream clock (if any).
       *
       * If the audio output clock is exactly synchronized with the system
-      * monotonic clock (i.e. mdate()), then aout_TimeGetDefault() can
+      * monotonic clock (i.e. vlc_tick_now()), then aout_TimeGetDefault() can
       * implement this callback.
       *
       * \param delay pointer to the delay until the next sample to be written
diff --git a/include/vlc_codec.h b/include/vlc_codec.h
index dde89978e7..776f3dd5c6 100644
--- a/include/vlc_codec.h
+++ b/include/vlc_codec.h
@@ -426,7 +426,7 @@ static inline int decoder_GetInputAttachments( decoder_t *dec,
 
 /**
  * This function converts a decoder timestamp into a display date comparable
- * to mdate().
+ * to vlc_tick_now().
  * You MUST use it *only* for gathering statistics about speed.
  */
 VLC_USED
diff --git a/include/vlc_interrupt.h b/include/vlc_interrupt.h
index 530977fc6c..5527de3213 100644
--- a/include/vlc_interrupt.h
+++ b/include/vlc_interrupt.h
@@ -84,7 +84,7 @@ VLC_API int vlc_mwait_i11e(vlc_tick_t);
  */
 static inline int vlc_msleep_i11e(vlc_tick_t delay)
 {
-    return vlc_mwait_i11e(mdate() + delay);
+    return vlc_mwait_i11e(vlc_tick_now() + delay);
 }
 
 /**
diff --git a/include/vlc_threads.h b/include/vlc_threads.h
index 7cd71cc472..b4ce47fdb6 100644
--- a/include/vlc_threads.h
+++ b/include/vlc_threads.h
@@ -521,7 +521,7 @@ VLC_API void vlc_cond_wait(vlc_cond_t *cond, vlc_mutex_t *mutex);
  *
  * This works like vlc_cond_wait() but with an additional time-out.
  * The time-out is expressed as an absolute timestamp using the same arbitrary
- * time reference as the mdate() and vlc_tick_wait() functions.
+ * time reference as the vlc_tick_now() and vlc_tick_wait() functions.
  *
  * \note This function is a cancellation point. In case of thread cancellation,
  * the mutex is always locked before cancellation proceeds.
@@ -534,7 +534,7 @@ VLC_API void vlc_cond_wait(vlc_cond_t *cond, vlc_mutex_t *mutex);
  * \warning If the variable was initialized with vlc_cond_init_daytime(), or
  * was statically initialized with \ref VLC_STATIC_COND, the time reference
  * used by this function is unspecified (depending on the implementation, it
- * might be the Unix epoch or the mdate() clock).
+ * might be the Unix epoch or the vlc_tick_now() clock).
  *
  * \return 0 if the condition was signaled, an error code in case of timeout.
  */
@@ -842,12 +842,12 @@ VLC_API unsigned long vlc_thread_id(void) VLC_USED;
  *
  * \return a timestamp in microseconds.
  */
-VLC_API vlc_tick_t mdate(void);
+VLC_API vlc_tick_t vlc_tick_now(void);
 
 /**
  * Waits until a deadline.
  *
- * \param deadline timestamp to wait for (\ref mdate())
+ * \param deadline timestamp to wait for (\ref vlc_tick_now())
  *
  * \note The deadline may be exceeded due to OS scheduling.
  * \note This function is a cancellation point.
@@ -959,7 +959,7 @@ VLC_API void vlc_timer_destroy(vlc_timer_t timer);
  * timer is still running. See also vlc_timer_getoverrun().
  *
  * \param timer initialized timer
- * \param absolute the timer value origin is the same as mdate() if true,
+ * \param absolute the timer value origin is the same as vlc_tick_now() if true,
  *                 the timer value is relative to now if false.
  * \param value zero to disarm the timer, otherwise the initial time to wait
  *              before firing the timer.
diff --git a/lib/core.c b/lib/core.c
index 0178a83d44..9b3c9c0245 100644
--- a/lib/core.c
+++ b/lib/core.c
@@ -238,7 +238,7 @@ libvlc_module_description_t *libvlc_video_filter_list_get( libvlc_instance_t *p_
 
 int64_t libvlc_clock(void)
 {
-    return mdate();
+    return vlc_tick_now();
 }
 
 const char vlc_module_name[] = "libvlc";
diff --git a/modules/access/alsa.c b/modules/access/alsa.c
index 88bb4d5398..dc99cca298 100644
--- a/modules/access/alsa.c
+++ b/modules/access/alsa.c
@@ -182,7 +182,7 @@ static void *Thread (void *data)
         vlc_tick_t pts;
 
         frames = snd_pcm_readi (pcm, block->p_buffer, sys->period_size);
-        pts = mdate ();
+        pts = vlc_tick_now ();
         if (frames < 0)
         {
             block_Release (block);
@@ -242,7 +242,7 @@ static int Control (demux_t *demux, int query, va_list ap)
     switch (query)
     {
         case DEMUX_GET_TIME:
-            *va_arg (ap, int64_t *) = mdate () - sys->start;
+            *va_arg (ap, int64_t *) = vlc_tick_now () - sys->start;
             break;
 
         case DEMUX_GET_PTS_DELAY:
@@ -458,7 +458,7 @@ static int Open (vlc_object_t *obj)
     fmt.audio.i_rate = param;
     sys->rate = param;
 
-    sys->start = mdate ();
+    sys->start = vlc_tick_now ();
     sys->caching = INT64_C(1000) * var_InheritInteger (demux, "live-caching");
     param = sys->caching;
     val = snd_pcm_hw_params_set_buffer_time_near (pcm, hw, &param, NULL);
diff --git a/modules/access/avcapture.m b/modules/access/avcapture.m
index 6d7ffa77ec..ed9dc54e20 100644
--- a/modules/access/avcapture.m
+++ b/modules/access/avcapture.m
@@ -456,7 +456,7 @@ static int Control(demux_t *p_demux, int i_query, va_list args)
 
         case DEMUX_GET_TIME:
             pi64 = va_arg(args, int64_t *);
-            *pi64 = mdate();
+            *pi64 = vlc_tick_now();
             return VLC_SUCCESS;
 
         default:
diff --git a/modules/access/bluray.c b/modules/access/bluray.c
index 74db7ce305..00f39aed51 100644
--- a/modules/access/bluray.c
+++ b/modules/access/bluray.c
@@ -414,7 +414,7 @@ static void startBackground(demux_t *p_demux)
     }
 
     // XXX TODO: what would be correct timestamp ???
-    p_block->i_dts = p_block->i_pts = mdate() + CLOCK_FREQ/25;
+    p_block->i_dts = p_block->i_pts = vlc_tick_now() + CLOCK_FREQ/25;
 
     uint8_t *p = p_block->p_buffer;
     memset(p, 0, fmt.video.i_width * fmt.video.i_height);
@@ -1634,7 +1634,7 @@ static void bluraySendOverlayToVout(demux_t *p_demux, bluray_overlay_t *p_ov)
         return;
     }
 
-    p_pic->i_start = p_pic->i_stop = mdate();
+    p_pic->i_start = p_pic->i_stop = vlc_tick_now();
     p_pic->i_channel = vout_RegisterSubpictureChannel(p_sys->p_vout);
     p_ov->i_channel = p_pic->i_channel;
 
@@ -2189,7 +2189,7 @@ static void blurayStillImage( demux_t *p_demux, unsigned i_timeout )
     demux_sys_t *p_sys = p_demux->p_sys;
 
     /* time period elapsed ? */
-    if (p_sys->i_still_end_time > 0 && p_sys->i_still_end_time <= mdate()) {
+    if (p_sys->i_still_end_time > 0 && p_sys->i_still_end_time <= vlc_tick_now()) {
         msg_Dbg(p_demux, "Still image end");
         bd_read_skip_still(p_sys->bluray);
 
@@ -2201,7 +2201,7 @@ static void blurayStillImage( demux_t *p_demux, unsigned i_timeout )
     if (!p_sys->i_still_end_time) {
         if (i_timeout) {
             msg_Dbg(p_demux, "Still image (%d seconds)", i_timeout);
-            p_sys->i_still_end_time = mdate() + i_timeout * CLOCK_FREQ;
+            p_sys->i_still_end_time = vlc_tick_now() + i_timeout * CLOCK_FREQ;
         } else {
             msg_Dbg(p_demux, "Still image (infinite)");
             p_sys->i_still_end_time = -1;
diff --git a/modules/access/dc1394.c b/modules/access/dc1394.c
index 9f14f2a2f8..9952fe9681 100644
--- a/modules/access/dc1394.c
+++ b/modules/access/dc1394.c
@@ -452,7 +452,7 @@ static block_t *GrabVideo( demux_t *p_demux )
     memcpy( p_block->p_buffer, (const char *)p_sys->frame->image,
             p_sys->width * p_sys->height * 2 );
 
-    p_block->i_pts = p_block->i_dts = mdate();
+    p_block->i_pts = p_block->i_dts = vlc_tick_now();
     dc1394_capture_enqueue( p_sys->camera, p_sys->frame );
     return p_block;
 }
@@ -502,7 +502,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             return VLC_SUCCESS;
 
         case DEMUX_GET_TIME:
-            *va_arg( args, int64_t * ) = mdate();
+            *va_arg( args, int64_t * ) = vlc_tick_now();
             return VLC_SUCCESS;
 
         /* TODO implement others */
diff --git a/modules/access/dshow/dshow.cpp b/modules/access/dshow/dshow.cpp
index 749a97e3f0..66844457f2 100644
--- a/modules/access/dshow/dshow.cpp
+++ b/modules/access/dshow/dshow.cpp
@@ -773,7 +773,7 @@ static int DemuxOpen( vlc_object_t *p_this )
         p_stream->p_es = es_out_Add( p_demux->out, &fmt );
     }
 
-    p_sys->i_start = mdate();
+    p_sys->i_start = vlc_tick_now();
     return VLC_SUCCESS;
 }
 
@@ -1988,7 +1988,7 @@ static int DemuxControl( demux_t *p_demux, int i_query, va_list args )
 
     case DEMUX_GET_TIME:
         pi64 = va_arg( args, int64_t * );
-        *pi64 = mdate() - p_sys->i_start;
+        *pi64 = vlc_tick_now() - p_sys->i_start;
         return VLC_SUCCESS;
 
     /* TODO implement others */
diff --git a/modules/access/dshow/filter.cpp b/modules/access/dshow/filter.cpp
index 1f15db3240..0adf4fed26 100644
--- a/modules/access/dshow/filter.cpp
+++ b/modules/access/dshow/filter.cpp
@@ -638,7 +638,7 @@ STDMETHODIMP CapturePin::Receive( IMediaSample *pSample )
     msg_Dbg( p_input, "CapturePin::Receive" );
 #endif
 
-    vlc_tick_t i_timestamp = mdate() * 10;
+    vlc_tick_t i_timestamp = vlc_tick_now() * 10;
     VLCMediaSample vlc_sample = {pSample, i_timestamp};
 
     vlc_mutex_lock( &p_sys->lock );
diff --git a/modules/access/dtv/bdagraph.cpp b/modules/access/dtv/bdagraph.cpp
index f5a00276a8..f80f39aad6 100644
--- a/modules/access/dtv/bdagraph.cpp
+++ b/modules/access/dtv/bdagraph.cpp
@@ -340,7 +340,7 @@ ssize_t BDAOutput::Pop(void *buf, size_t len, int ms)
 
     vlc_mutex_locker l( &lock );
 
-    vlc_tick_t i_deadline = mdate() + ms * 1000;
+    vlc_tick_t i_deadline = vlc_tick_now() + ms * 1000;
     while( !p_first )
     {
         if( vlc_cond_timedwait( &wait, &lock, i_deadline ) )
diff --git a/modules/access/dtv/en50221.c b/modules/access/dtv/en50221.c
index 1d0a61fe45..941f722f08 100644
--- a/modules/access/dtv/en50221.c
+++ b/modules/access/dtv/en50221.c
@@ -1439,7 +1439,7 @@ static void DateTimeSend( cam_t * p_cam, int i_session_id )
 
         APDUSend( p_cam, i_session_id, AOT_DATE_TIME, p_response, 7 );
 
-        p_date->i_last = mdate();
+        p_date->i_last = vlc_tick_now();
     }
 }
 
@@ -1488,7 +1488,7 @@ static void DateTimeManage( cam_t * p_cam, int i_session_id )
         (date_time_t *)p_cam->p_sessions[i_session_id - 1].p_sys;
 
     if ( p_date->i_interval
-          && mdate() > p_date->i_last + (vlc_tick_t)p_date->i_interval * CLOCK_FREQ )
+          && vlc_tick_now() > p_date->i_last + (vlc_tick_t)p_date->i_interval * CLOCK_FREQ )
     {
         DateTimeSend( p_cam, i_session_id );
     }
@@ -2030,7 +2030,7 @@ void en50221_Poll( cam_t * p_cam )
     switch( p_cam->i_ca_type )
     {
     case CA_CI_LINK:
-        if( mdate() > p_cam->i_next_event )
+        if( vlc_tick_now() > p_cam->i_next_event )
             break;
     case CA_CI:
         return;
@@ -2168,7 +2168,7 @@ void en50221_Poll( cam_t * p_cam )
         }
     }
 
-    p_cam->i_next_event = mdate() + p_cam->i_timeout;
+    p_cam->i_next_event = vlc_tick_now() + p_cam->i_timeout;
 }
 
 
diff --git a/modules/access/dv.c b/modules/access/dv.c
index 08c7632916..0ea1c46464 100644
--- a/modules/access/dv.c
+++ b/modules/access/dv.c
@@ -389,7 +389,7 @@ Raw1394Handler(raw1394handle_t handle, unsigned char *data,
             if( p_sys->p_ev->p_frame )
             {
                 /* Push current frame to p_access thread. */
-                //p_sys->p_ev->p_frame->i_pts = mdate();
+                //p_sys->p_ev->p_frame->i_pts = vlc_tick_now();
                 block_ChainAppend( &p_sys->p_frame, p_sys->p_ev->p_frame );
             }
             /* reset list */
diff --git a/modules/access/dvb/access.c b/modules/access/dvb/access.c
index c5564eb234..e8c0210272 100644
--- a/modules/access/dvb/access.c
+++ b/modules/access/dvb/access.c
@@ -292,7 +292,7 @@ static int ScanReadCallback( scan_t *p_scan, void *p_privdata,
     FrontendGetStatus( &p_sys->dvb, &status );
     bool b_has_lock = status.b_has_lock;
 
-    vlc_tick_t i_scan_start = mdate();
+    vlc_tick_t i_scan_start = vlc_tick_now();
 
     for( ; *pi_count == 0; )
     {
@@ -304,7 +304,7 @@ static int ScanReadCallback( scan_t *p_scan, void *p_privdata,
 
         do
         {
-            vlc_tick_t i_poll_timeout = i_scan_start - mdate() + i_timeout;
+            vlc_tick_t i_poll_timeout = i_scan_start - vlc_tick_now() + i_timeout;
 
             i_ret = 0;
 
@@ -332,7 +332,7 @@ static int ScanReadCallback( scan_t *p_scan, void *p_privdata,
             FrontendGetStatus( &p_sys->dvb, &status );
             if( status.b_has_lock && !b_has_lock )
             {
-                i_scan_start = mdate();
+                i_scan_start = vlc_tick_now();
                 b_has_lock = true;
             }
         }
diff --git a/modules/access/dvb/scan.c b/modules/access/dvb/scan.c
index 01961794d8..aa4eea573e 100644
--- a/modules/access/dvb/scan.c
+++ b/modules/access/dvb/scan.c
@@ -421,7 +421,7 @@ scan_t *scan_New( vlc_object_t *p_obj, const scan_parameter_t *p_parameter,
     p_scan->b_multiplexes_from_nit = false;
     scan_parameter_Init( &p_scan->parameter );
     scan_parameter_Copy( p_parameter, &p_scan->parameter );
-    p_scan->i_time_start = mdate();
+    p_scan->i_time_start = vlc_tick_now();
     p_scan->p_scanlist = NULL;
     p_scan->i_scanlist = 0;
 
@@ -812,7 +812,7 @@ static int scan_Next( scan_t *p_scan, scan_tuner_config_t *p_cfg )
     //while( !scan_tuner_config_ParametersValidate( &p_scan->parameter, p_cfg ) );
 
     const size_t i_total_services = scan_CountServices( p_scan );
-    const vlc_tick_t i_eta = f_position > 0.005 ? (mdate() - p_scan->i_time_start) * ( 1.0 / f_position - 1.0 ) : -1;
+    const vlc_tick_t i_eta = f_position > 0.005 ? (vlc_tick_now() - p_scan->i_time_start) * ( 1.0 / f_position - 1.0 ) : -1;
     char psz_eta[MSTRTIME_MAX_SIZE];
     const char *psz_fmt = _("%.1f MHz (%d services)\n~%s remaining");
 
@@ -871,12 +871,12 @@ int scan_Run( scan_t *p_scan )
 
     /* */
     uint8_t packet[TS_PACKET_SIZE * SCAN_READ_BUFFER_COUNT];
-    int64_t i_scan_start = mdate();
+    int64_t i_scan_start = vlc_tick_now();
 
     for( ;; )
     {
         unsigned i_timeout = scan_session_GetTablesTimeout( session );
-        vlc_tick_t i_remaining = mdate() - i_scan_start;
+        vlc_tick_t i_remaining = vlc_tick_now() - i_scan_start;
         if( i_remaining > i_timeout )
             break;
 
diff --git a/modules/access/idummy.c b/modules/access/idummy.c
index 95618a1172..7194a19d48 100644
--- a/modules/access/idummy.c
+++ b/modules/access/idummy.c
@@ -69,7 +69,7 @@ typedef struct
 static int DemuxPause( demux_t *demux )
 {
     demux_sys_t *p_sys = demux->p_sys;
-    vlc_tick_t now = mdate();
+    vlc_tick_t now = vlc_tick_now();
 
     if( now >= p_sys->end )
         return 0;
@@ -88,7 +88,7 @@ static int ControlPause( demux_t *demux, int query, va_list args )
         {
             double *ppos = va_arg( args, double * );
             double pos;
-            vlc_tick_t now = mdate();
+            vlc_tick_t now = vlc_tick_now();
 
             pos = 1. + ((double)(now - p_sys->end) / (double)p_sys->length);
             *ppos = (pos <= 1.) ? pos : 1.;
@@ -98,7 +98,7 @@ static int ControlPause( demux_t *demux, int query, va_list args )
         case DEMUX_SET_POSITION:
         {
             double pos = va_arg( args, double );
-            vlc_tick_t now = mdate();
+            vlc_tick_t now = vlc_tick_now();
 
             p_sys->end = now + (p_sys->length * (1. - pos));
             break;
@@ -114,14 +114,14 @@ static int ControlPause( demux_t *demux, int query, va_list args )
         case DEMUX_GET_TIME:
         {
             vlc_tick_t *ppos = va_arg( args, vlc_tick_t * );
-            *ppos = mdate() + p_sys->length - p_sys->end;
+            *ppos = vlc_tick_now() + p_sys->length - p_sys->end;
             break;
         }
 
         case DEMUX_SET_TIME:
         {
             vlc_tick_t pos = va_arg( args, vlc_tick_t );
-            p_sys->end = mdate() + p_sys->length - pos;
+            p_sys->end = vlc_tick_now() + p_sys->length - pos;
             break;
         }
 
@@ -188,7 +188,7 @@ nop:
         if( p_sys == NULL )
             return VLC_ENOMEM;
 
-        p_sys->end = mdate() + length;
+        p_sys->end = vlc_tick_now() + length;
         p_sys->length = length;
 
         p_demux->p_sys = p_sys;
diff --git a/modules/access/linsys/linsys_sdi.c b/modules/access/linsys/linsys_sdi.c
index 0c40c29983..70bca000a3 100644
--- a/modules/access/linsys/linsys_sdi.c
+++ b/modules/access/linsys/linsys_sdi.c
@@ -223,7 +223,7 @@ static int DemuxOpen( vlc_object_t *p_this )
         return VLC_ENOMEM;
 
     p_sys->i_state = STATE_NOSYNC;
-    p_sys->i_last_state_change = mdate();
+    p_sys->i_last_state_change = vlc_tick_now();
 
     /* SDI AR */
     unsigned int i_num, i_den;
@@ -1416,10 +1416,10 @@ static int HandleSDBuffer( demux_t *p_demux, uint8_t *p_buffer,
     const uint8_t *p_line;
 
     if ( p_sys->i_state != STATE_SYNC
-          && p_sys->i_last_state_change < mdate() - RESYNC_TIMEOUT )
+          && p_sys->i_last_state_change < vlc_tick_now() - RESYNC_TIMEOUT )
     {
         p_sys->i_state = STATE_NOSYNC;
-        p_sys->i_last_state_change = mdate();
+        p_sys->i_last_state_change = vlc_tick_now();
         return VLC_EGENERIC;
     }
 
@@ -1431,7 +1431,7 @@ static int HandleSDBuffer( demux_t *p_demux, uint8_t *p_buffer,
         if ( p_parser == NULL )
             break;
         p_sys->i_state = STATE_STARTSYNC;
-        p_sys->i_last_state_change = mdate();
+        p_sys->i_last_state_change = vlc_tick_now();
 
     case STATE_STARTSYNC:
         p_parser = FindReferenceCode( FIELD_1_VBLANK_EAV, p_parser, p_end );
@@ -1439,7 +1439,7 @@ static int HandleSDBuffer( demux_t *p_demux, uint8_t *p_buffer,
             break;
         p_sys->i_anc_size = 0;
         p_sys->i_state = STATE_ANCSYNC;
-        p_sys->i_last_state_change = mdate();
+        p_sys->i_last_state_change = vlc_tick_now();
 
     case STATE_ANCSYNC:
         p_parser = CountReference( &p_sys->i_anc_size,
@@ -1448,7 +1448,7 @@ static int HandleSDBuffer( demux_t *p_demux, uint8_t *p_buffer,
             break;
         p_sys->i_active_size = 0;
         p_sys->i_state = STATE_LINESYNC;
-        p_sys->i_last_state_change = mdate();
+        p_sys->i_last_state_change = vlc_tick_now();
 
     case STATE_LINESYNC:
         p_parser = CountReference( &p_sys->i_active_size,
@@ -1457,7 +1457,7 @@ static int HandleSDBuffer( demux_t *p_demux, uint8_t *p_buffer,
             break;
         p_sys->i_picture_size = p_sys->i_anc_size + p_sys->i_active_size;
         p_sys->i_state = STATE_ACTIVESYNC;
-        p_sys->i_last_state_change = mdate();
+        p_sys->i_last_state_change = vlc_tick_now();
 
     case STATE_ACTIVESYNC:
         p_parser = CountReference( &p_sys->i_picture_size,
@@ -1467,7 +1467,7 @@ static int HandleSDBuffer( demux_t *p_demux, uint8_t *p_buffer,
         p_sys->i_line_offset = p_sys->i_picture_size
                              / (p_sys->i_anc_size + p_sys->i_active_size);
         p_sys->i_state = STATE_VBLANKSYNC;
-        p_sys->i_last_state_change = mdate();
+        p_sys->i_last_state_change = vlc_tick_now();
 
     case STATE_VBLANKSYNC:
         p_parser = CountReference( &p_sys->i_picture_size,
@@ -1475,7 +1475,7 @@ static int HandleSDBuffer( demux_t *p_demux, uint8_t *p_buffer,
         if ( p_parser == NULL )
             break;
         p_sys->i_state = STATE_PICSYNC;
-        p_sys->i_last_state_change = mdate();
+        p_sys->i_last_state_change = vlc_tick_now();
 
     case STATE_PICSYNC:
         p_parser = CountReference( &p_sys->i_picture_size,
@@ -1490,7 +1490,7 @@ static int HandleSDBuffer( demux_t *p_demux, uint8_t *p_buffer,
                  p_sys->i_anc_size, p_sys->i_active_size,
                  p_sys->i_picture_size, p_sys->i_line_offset + 1 );
             p_sys->i_state = STATE_NOSYNC;
-            p_sys->i_last_state_change = mdate();
+            p_sys->i_last_state_change = vlc_tick_now();
             break;
         }
 
@@ -1552,7 +1552,7 @@ static int HandleSDBuffer( demux_t *p_demux, uint8_t *p_buffer,
                           p_sys->i_current_line + 1, p_line[4], p_line[anc+4] );
                 StopDecode( p_demux );
                 p_sys->i_state = STATE_NOSYNC;
-                p_sys->i_last_state_change = mdate();
+                p_sys->i_last_state_change = vlc_tick_now();
                 break;
             }
 
diff --git a/modules/access/oss.c b/modules/access/oss.c
index e58a2e7b90..cd817a5e74 100644
--- a/modules/access/oss.c
+++ b/modules/access/oss.c
@@ -224,7 +224,7 @@ static int DemuxControl( demux_t *p_demux, int i_query, va_list args )
 
         case DEMUX_GET_TIME:
             pi64 = va_arg( args, int64_t * );
-            *pi64 = mdate();
+            *pi64 = vlc_tick_now();
             return VLC_SUCCESS;
 
         case DEMUX_SET_NEXT_DEMUX_TIME:
@@ -320,7 +320,7 @@ static block_t* GrabAudio( demux_t *p_demux )
 
     /* Timestamp */
     p_block->i_pts = p_block->i_dts =
-        mdate() - CLOCK_FREQ * (vlc_tick_t)i_correct /
+        vlc_tick_now() - CLOCK_FREQ * (vlc_tick_t)i_correct /
         2 / ( p_sys->b_stereo ? 2 : 1) / p_sys->i_sample_rate;
 
     return p_block;
diff --git a/modules/access/pulse.c b/modules/access/pulse.c
index 1423b346b8..35d1f60c11 100644
--- a/modules/access/pulse.c
+++ b/modules/access/pulse.c
@@ -161,7 +161,7 @@ static void stream_read_cb(pa_stream *s, size_t length, void *userdata)
         return;
     }
 
-    vlc_tick_t pts = mdate();
+    vlc_tick_t pts = vlc_tick_now();
     pa_usec_t latency;
     int negative;
 
diff --git a/modules/access/rdp.c b/modules/access/rdp.c
index 4e33414c01..4dbe2f37a5 100644
--- a/modules/access/rdp.c
+++ b/modules/access/rdp.c
@@ -309,7 +309,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
 
         case DEMUX_GET_TIME:
             pi64 = va_arg( args, int64_t * );
-            *pi64 = mdate() - p_sys->i_starttime;
+            *pi64 = vlc_tick_now() - p_sys->i_starttime;
             return VLC_SUCCESS;
 
         case DEMUX_GET_LENGTH:
@@ -339,8 +339,8 @@ static void *DemuxThread( void *p_data )
 {
     demux_t *p_demux = (demux_t *) p_data;
     demux_sys_t *p_sys = p_demux->p_sys;
-    p_sys->i_starttime = mdate();
-    vlc_tick_t i_next_frame_date = mdate() + p_sys->i_frame_interval;
+    p_sys->i_starttime = vlc_tick_now();
+    vlc_tick_t i_next_frame_date = vlc_tick_now() + p_sys->i_frame_interval;
     int i_ret;
 
     for(;;)
@@ -408,7 +408,7 @@ static void *DemuxThread( void *p_data )
             block_t *p_block = block_Duplicate( p_sys->p_block );
             if (likely( p_block && p_sys->p_block ))
             {
-                p_sys->p_block->i_dts = p_sys->p_block->i_pts = mdate() - p_sys->i_starttime;
+                p_sys->p_block->i_dts = p_sys->p_block->i_pts = vlc_tick_now() - p_sys->i_starttime;
                 es_out_SetPCR( p_demux->out, p_sys->p_block->i_pts );
                 es_out_Send( p_demux->out, p_sys->es, p_sys->p_block );
                 p_sys->p_block = p_block;
diff --git a/modules/access/rtp/input.c b/modules/access/rtp/input.c
index 9f8f8e72fd..11450be5f8 100644
--- a/modules/access/rtp/input.c
+++ b/modules/access/rtp/input.c
@@ -90,7 +90,7 @@ static int rtp_timeout (vlc_tick_t deadline)
     if (deadline == VLC_TS_INVALID)
         return -1; /* infinite */
 
-    vlc_tick_t t = mdate ();
+    vlc_tick_t t = vlc_tick_now ();
     if (t >= deadline)
         return 0;
 
diff --git a/modules/access/rtp/session.c b/modules/access/rtp/session.c
index fa668f8a62..adc0d18877 100644
--- a/modules/access/rtp/session.c
+++ b/modules/access/rtp/session.c
@@ -256,7 +256,7 @@ rtp_queue (demux_t *demux, rtp_session_t *session, block_t *block)
         block->i_buffer -= padding;
     }
 
-    vlc_tick_t     now = mdate ();
+    vlc_tick_t     now = vlc_tick_now ();
     rtp_source_t  *src  = NULL;
     const uint16_t seq  = rtp_seq (block);
     const uint32_t ssrc = GetDWBE (block->p_buffer + 8);
@@ -393,7 +393,7 @@ static void rtp_decode (demux_t *, const rtp_session_t *, rtp_source_t *);
 bool rtp_dequeue (demux_t *demux, const rtp_session_t *session,
                   vlc_tick_t *restrict deadlinep)
 {
-    vlc_tick_t now = mdate ();
+    vlc_tick_t now = vlc_tick_now ();
     bool pending = false;
 
     *deadlinep = INT64_MAX;
diff --git a/modules/access/satip.c b/modules/access/satip.c
index 59012a57c3..5ab0875c79 100644
--- a/modules/access/satip.c
+++ b/modules/access/satip.c
@@ -425,9 +425,9 @@ static void *satip_thread(void *data) {
     stream_t *access = data;
     access_sys_t *sys = access->p_sys;
     int sock = sys->udp_sock;
-    vlc_tick_t last_recv = mdate();
+    vlc_tick_t last_recv = vlc_tick_now();
     ssize_t len;
-    vlc_tick_t next_keepalive = mdate() + sys->keepalive_interval * 1000 * 1000;
+    vlc_tick_t next_keepalive = vlc_tick_now() + sys->keepalive_interval * 1000 * 1000;
 #ifdef HAVE_RECVMMSG
     struct mmsghdr msgs[VLEN];
     struct iovec iovecs[VLEN];
@@ -449,7 +449,7 @@ static void *satip_thread(void *data) {
     ufd.events = POLLIN;
 #endif
 
-    while (last_recv > mdate() - RECV_TIMEOUT) {
+    while (last_recv > vlc_tick_now() - RECV_TIMEOUT) {
 #ifdef HAVE_RECVMMSG
         for (size_t i = 0; i < VLEN; i++) {
             if (input_blocks[i] != NULL)
@@ -468,7 +468,7 @@ static void *satip_thread(void *data) {
         if (retval == -1)
             continue;
 
-        last_recv = mdate();
+        last_recv = vlc_tick_now();
         for (int i = 0; i < retval; ++i) {
             block_t *block = input_blocks[i];
 
@@ -504,13 +504,13 @@ static void *satip_thread(void *data) {
             block_Release(block);
             continue;
         }
-        last_recv = mdate();
+        last_recv = vlc_tick_now();
         block->p_buffer += RTP_HEADER_SIZE;
         block->i_buffer = len - RTP_HEADER_SIZE;
         block_FifoPut(sys->fifo, block);
 #endif
 
-        if (sys->keepalive_interval > 0 && mdate() > next_keepalive) {
+        if (sys->keepalive_interval > 0 && vlc_tick_now() > next_keepalive) {
             net_Printf(access, sys->tcp_sock,
                     "OPTIONS %s RTSP/1.0\r\n"
                     "CSeq: %d\r\n"
@@ -519,7 +519,7 @@ static void *satip_thread(void *data) {
             if (rtsp_handle(access, NULL) != RTSP_RESULT_OK)
                 msg_Warn(access, "Failed to keepalive RTSP session");
 
-            next_keepalive = mdate() + sys->keepalive_interval * 1000 * 1000;
+            next_keepalive = vlc_tick_now() + sys->keepalive_interval * 1000 * 1000;
         }
     }
 
diff --git a/modules/access/screen/screen.c b/modules/access/screen/screen.c
index 5453ef7f8a..dda2b99fc2 100644
--- a/modules/access/screen/screen.c
+++ b/modules/access/screen/screen.c
@@ -246,7 +246,7 @@ static int Open( vlc_object_t *p_this )
 
     p_sys->es = es_out_Add( p_demux->out, &p_sys->fmt );
 
-    p_sys->i_start = mdate();
+    p_sys->i_start = vlc_tick_now();
 
     return VLC_SUCCESS;
 }
@@ -275,10 +275,10 @@ static int Demux( demux_t *p_demux )
     demux_sys_t *p_sys = p_demux->p_sys;
     block_t *p_block;
 
-    if( !p_sys->i_next_date ) p_sys->i_next_date = mdate();
+    if( !p_sys->i_next_date ) p_sys->i_next_date = vlc_tick_now();
 
     /* Frame skipping if necessary */
-    while( mdate() >= p_sys->i_next_date + p_sys->i_incr )
+    while( vlc_tick_now() >= p_sys->i_next_date + p_sys->i_incr )
         p_sys->i_next_date += p_sys->i_incr;
 
     vlc_tick_wait( p_sys->i_next_date );
@@ -327,7 +327,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
 
         case DEMUX_GET_TIME:
             pi64 = va_arg( args, int64_t * );
-            *pi64 = mdate() - p_sys->i_start;
+            *pi64 = vlc_tick_now() - p_sys->i_start;
             return VLC_SUCCESS;
 
         /* TODO implement others */
diff --git a/modules/access/screen/wayland.c b/modules/access/screen/wayland.c
index d528a09656..3fa740fdc1 100644
--- a/modules/access/screen/wayland.c
+++ b/modules/access/screen/wayland.c
@@ -253,7 +253,7 @@ static void *Thread(void *data)
         {
             block_t *block = Shoot(demux);
 
-            block->i_pts = block->i_dts = mdate();
+            block->i_pts = block->i_dts = vlc_tick_now();
             es_out_SetPCR(demux->out, block->i_pts);
             es_out_Send(demux->out, sys->es, block);
         }
@@ -289,7 +289,7 @@ static int Control(demux_t *demux, int query, va_list args)
             break;
 
         case DEMUX_GET_TIME:
-            *va_arg(args, int64_t *) = mdate() - sys->start;
+            *va_arg(args, int64_t *) = vlc_tick_now() - sys->start;
             break;
 
         case DEMUX_GET_FPS:
@@ -416,7 +416,7 @@ static int Open(vlc_object_t *obj)
         goto error;
 
     /* Initializes demux */
-    sys->start = mdate();
+    sys->start = vlc_tick_now();
 
     if (vlc_clone(&sys->thread, Thread, demux, VLC_THREAD_PRIORITY_INPUT))
         goto error;
diff --git a/modules/access/screen/xcb.c b/modules/access/screen/xcb.c
index 9a6e21457f..7560b1a530 100644
--- a/modules/access/screen/xcb.c
+++ b/modules/access/screen/xcb.c
@@ -502,7 +502,7 @@ noshm:
     /* Send block - zero copy */
     if (sys->es != NULL)
     {
-        block->i_pts = block->i_dts = mdate ();
+        block->i_pts = block->i_dts = vlc_tick_now ();
 
         es_out_SetPCR(demux->out, block->i_pts);
         es_out_Send (demux->out, sys->es, block);
diff --git a/modules/access/shm.c b/modules/access/shm.c
index d165c710e5..1663ea65f7 100644
--- a/modules/access/shm.c
+++ b/modules/access/shm.c
@@ -328,7 +328,7 @@ static void DemuxFile (void *data)
     block_t *block = block_File(sys->fd, true);
     if (block == NULL)
         return;
-    block->i_pts = block->i_dts = mdate ();
+    block->i_pts = block->i_dts = vlc_tick_now ();
 
     /* Send block */
     es_out_SetPCR(demux->out, block->i_pts);
@@ -351,7 +351,7 @@ static void DemuxIPC (void *data)
     if (block == NULL)
         return;
     memcpy (block->p_buffer, sys->mem.addr, sys->mem.length);
-    block->i_pts = block->i_dts = mdate ();
+    block->i_pts = block->i_dts = vlc_tick_now ();
 
     /* Send block */
     es_out_SetPCR(demux->out, block->i_pts);
diff --git a/modules/access/v4l2/access.c b/modules/access/v4l2/access.c
index e44a94d08d..9ce5f5c764 100644
--- a/modules/access/v4l2/access.c
+++ b/modules/access/v4l2/access.c
@@ -220,7 +220,7 @@ static block_t *MMapBlock (stream_t *access, bool *restrict eof)
     block_t *block = GrabVideo (VLC_OBJECT(access), sys->fd, sys->bufv);
     if( block != NULL )
     {
-        block->i_pts = block->i_dts = mdate();
+        block->i_pts = block->i_dts = vlc_tick_now();
         block->i_flags |= sys->block_flags;
     }
     (void) eof;
diff --git a/modules/access/v4l2/demux.c b/modules/access/v4l2/demux.c
index d73272dd21..77adfc53f2 100644
--- a/modules/access/v4l2/demux.c
+++ b/modules/access/v4l2/demux.c
@@ -104,7 +104,7 @@ int DemuxOpen( vlc_object_t *obj )
     }
 
     sys->controls = ControlsInit (VLC_OBJECT(demux), fd);
-    sys->start = mdate ();
+    sys->start = vlc_tick_now ();
     demux->pf_demux = NULL;
     demux->pf_control = DemuxControl;
     return VLC_SUCCESS;
@@ -811,7 +811,7 @@ static void *ReadThread (void *data)
                 v4l2_read (fd, NULL, 0); /* discard frame */
                 continue;
             }
-            block->i_pts = block->i_dts = mdate ();
+            block->i_pts = block->i_dts = vlc_tick_now ();
             block->i_flags |= sys->block_flags;
 
             int canc = vlc_savecancel ();
@@ -853,7 +853,7 @@ static int DemuxControl( demux_t *demux, int query, va_list args )
             return VLC_SUCCESS;
 
         case DEMUX_GET_TIME:
-            *va_arg (args, int64_t *) = mdate() - sys->start;
+            *va_arg (args, int64_t *) = vlc_tick_now() - sys->start;
             return VLC_SUCCESS;
 
         /* TODO implement others */
diff --git a/modules/access/v4l2/radio.c b/modules/access/v4l2/radio.c
index 4469b9b8b4..fa33dc1124 100644
--- a/modules/access/v4l2/radio.c
+++ b/modules/access/v4l2/radio.c
@@ -55,7 +55,7 @@ static int RadioControl (demux_t *demux, int query, va_list args)
             break;
 
         case DEMUX_GET_TIME:
-            *va_arg (args, int64_t *) = mdate () - sys->start;
+            *va_arg (args, int64_t *) = vlc_tick_now () - sys->start;
             break;
 
         /* TODO implement others */
@@ -101,7 +101,7 @@ int RadioOpen (vlc_object_t *obj)
 
     sys->fd = fd;
     sys->controls = ControlsInit (VLC_OBJECT(demux), fd);
-    sys->start = mdate ();
+    sys->start = vlc_tick_now ();
 
     demux->p_sys = sys;
     demux->pf_demux = NULL;
diff --git a/modules/access/v4l2/vbi.c b/modules/access/v4l2/vbi.c
index 64780b6eab..d645cdfcbf 100644
--- a/modules/access/v4l2/vbi.c
+++ b/modules/access/v4l2/vbi.c
@@ -136,7 +136,7 @@ void GrabVBI (demux_t *p_demux, vlc_v4l2_vbi_t *vbi)
                 memcpy(data, sliced_array[field].data, sliced_size);
                 data += sliced_size;
             }
-            p_block->i_pts = mdate();
+            p_block->i_pts = vlc_tick_now();
 
             for (unsigned i = 0; i < VBI_NUM_CC_STREAMS; i++)
             {
diff --git a/modules/access/v4l2/video.c b/modules/access/v4l2/video.c
index e3e11b5f5e..3d87b176ba 100644
--- a/modules/access/v4l2/video.c
+++ b/modules/access/v4l2/video.c
@@ -573,7 +573,7 @@ vlc_tick_t GetBufferPTS (const struct v4l2_buffer *buf)
             break;
         case V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN:
         default:
-            pts = mdate ();
+            pts = vlc_tick_now ();
             break;
     }
     return pts;
diff --git a/modules/access/vnc.c b/modules/access/vnc.c
index 57dbfb6955..c6a8ae426a 100644
--- a/modules/access/vnc.c
+++ b/modules/access/vnc.c
@@ -306,7 +306,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
 
         case DEMUX_GET_TIME:
             pi64 = va_arg( args, int64_t * );
-            *pi64 = mdate() - p_sys->i_starttime;
+            *pi64 = vlc_tick_now() - p_sys->i_starttime;
             return VLC_SUCCESS;
 
         case DEMUX_GET_LENGTH:
@@ -337,7 +337,7 @@ static void *DemuxThread( void *p_data )
 {
     demux_t *p_demux = (demux_t *) p_data;
     demux_sys_t  *p_sys = p_demux->p_sys;
-    vlc_tick_t i_next_frame_date = mdate() + p_sys->i_frame_interval;
+    vlc_tick_t i_next_frame_date = vlc_tick_now() + p_sys->i_frame_interval;
     int i_status;
 
     for(;;)
@@ -369,7 +369,7 @@ static void *DemuxThread( void *p_data )
                 block_t *p_block = block_Duplicate( p_sys->p_block );
                 if ( p_block ) /* drop frame/content if no next block */
                 {
-                    p_sys->p_block->i_dts = p_sys->p_block->i_pts = mdate();
+                    p_sys->p_block->i_dts = p_sys->p_block->i_pts = vlc_tick_now();
                     es_out_SetPCR( p_demux->out, p_sys->p_block->i_pts );
                     es_out_Send( p_demux->out, p_sys->es, p_sys->p_block );
                     p_sys->p_block = p_block;
@@ -472,7 +472,7 @@ static int Open( vlc_object_t *p_this )
         return VLC_EGENERIC;
     }
 
-    p_sys->i_starttime = mdate();
+    p_sys->i_starttime = vlc_tick_now();
 
     if ( vlc_clone( &p_sys->thread, DemuxThread, p_demux, VLC_THREAD_PRIORITY_INPUT ) != VLC_SUCCESS )
     {
diff --git a/modules/access/wasapi.c b/modules/access/wasapi.c
index 226682b56d..a453cf4a69 100644
--- a/modules/access/wasapi.c
+++ b/modules/access/wasapi.c
@@ -325,7 +325,7 @@ static unsigned __stdcall Thread(void *data)
         if (hr != S_OK)
             continue;
 
-        pts = mdate() - ((GetQPC() - qpc) / 10);
+        pts = vlc_tick_now() - ((GetQPC() - qpc) / 10);
 
         es_out_SetPCR(demux->out, pts);
 
@@ -356,7 +356,7 @@ static int Control(demux_t *demux, int query, va_list ap)
     switch (query)
     {
         case DEMUX_GET_TIME:
-            *(va_arg(ap, int64_t *)) = mdate() - sys->start_time;
+            *(va_arg(ap, int64_t *)) = vlc_tick_now() - sys->start_time;
             break;
 
         case DEMUX_GET_PTS_DELAY:
@@ -397,7 +397,7 @@ static int Open(vlc_object_t *obj)
     sys->client = NULL;
     sys->es = NULL;
     sys->caching = INT64_C(1000) * var_InheritInteger(obj, "live-caching");
-    sys->start_time = mdate();
+    sys->start_time = vlc_tick_now();
     for (unsigned i = 0; i < 2; i++)
         sys->events[i] = NULL;
 
diff --git a/modules/access_output/udp.c b/modules/access_output/udp.c
index 91a052ae3e..ccf67559c0 100644
--- a/modules/access_output/udp.c
+++ b/modules/access_output/udp.c
@@ -277,7 +277,7 @@ static ssize_t Write( sout_access_out_t *p_access, block_t *p_buffer )
     {
         block_t *p_next;
         int i_packets = 0;
-        vlc_tick_t now = mdate();
+        vlc_tick_t now = vlc_tick_now();
 
         if( !p_sys->b_mtu_warning && p_buffer->i_buffer > p_sys->i_mtu )
         {
@@ -333,7 +333,7 @@ static ssize_t Write( sout_access_out_t *p_access, block_t *p_buffer )
                 if( p_sys->p_buffer->i_dts + p_sys->i_caching < now )
                 {
                     msg_Dbg( p_access, "late packet for udp input (%"PRId64 ")",
-                             mdate() - p_sys->p_buffer->i_dts
+                             vlc_tick_now() - p_sys->p_buffer->i_dts
                               - p_sys->i_caching );
                 }
                 block_FifoPut( p_sys->p_fifo, p_sys->p_buffer );
@@ -439,7 +439,7 @@ static void* ThreadWrite( void *data )
         }
 
 #if 1
-        i_sent = mdate();
+        i_sent = vlc_tick_now();
         if ( i_sent > i_date + 20000 )
         {
             msg_Dbg( p_access, "packet has been sent too late (%"PRId64 ")",
diff --git a/modules/audio_output/audiotrack.c b/modules/audio_output/audiotrack.c
index acac7dbef2..f6fe0646cc 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -577,7 +577,7 @@ AudioTrack_ResetPositions( JNIEnv *env, audio_output_t *p_aout )
     aout_sys_t *p_sys = p_aout->sys;
     VLC_UNUSED( env );
 
-    p_sys->timestamp.i_play_time = mdate();
+    p_sys->timestamp.i_play_time = vlc_tick_now();
     p_sys->timestamp.i_last_time = 0;
     p_sys->timestamp.i_frame_us = 0;
     p_sys->timestamp.i_frame_pos = 0;
@@ -613,7 +613,7 @@ AudioTrack_GetSmoothPositionUs( JNIEnv *env, audio_output_t *p_aout )
 {
     aout_sys_t *p_sys = p_aout->sys;
     uint64_t i_audiotrack_us;
-    vlc_tick_t i_now = mdate();
+    vlc_tick_t i_now = vlc_tick_now();
 
     /* Fetch an AudioTrack position every SMOOTHPOS_INTERVAL_US (30ms) */
     if( i_now - p_sys->smoothpos.i_last_time >= SMOOTHPOS_INTERVAL_US )
@@ -661,7 +661,7 @@ AudioTrack_GetTimestampPositionUs( JNIEnv *env, audio_output_t *p_aout )
     if( !p_sys->timestamp.p_obj )
         return 0;
 
-    i_now = mdate();
+    i_now = vlc_tick_now();
 
     /* Android doc:
      * getTimestamp: Poll for a timestamp on demand.
@@ -741,7 +741,7 @@ TimeGet( audio_output_t *p_aout, vlc_tick_t *restrict p_delay )
     if( i_ts_us > 0 )
         i_smooth_us = AudioTrack_GetSmoothPositionUs(env, p_aout );
     else if ( p_sys->smoothpos.i_us != 0 )
-        i_smooth_us = p_sys->smoothpos.i_us + mdate()
+        i_smooth_us = p_sys->smoothpos.i_us + vlc_tick_now()
             - p_sys->smoothpos.i_latency_us;
 
     msg_Err( p_aout, "TimeGet: TimeStamp: %lld, Smooth: %lld (latency: %lld)",
@@ -1647,7 +1647,7 @@ AudioTrack_Thread( void *p_data )
         vlc_mutex_lock( &p_sys->lock );
 
         /* Wait for free space in Audiotrack internal buffer */
-        if( i_play_deadline != 0 && mdate() < i_play_deadline )
+        if( i_play_deadline != 0 && vlc_tick_now() < i_play_deadline )
         {
             /* Don't wake up the thread when there is new data since we are
              * waiting for more space */
@@ -1685,7 +1685,7 @@ AudioTrack_Thread( void *p_data )
          * Android 4.4.2 if we send frames too quickly. To fix this issue,
          * force the writing of the buffer after a certain delay. */
         if( i_last_time_blocked != 0 )
-            b_forced = mdate() - i_last_time_blocked >
+            b_forced = vlc_tick_now() - i_last_time_blocked >
                        FRAMES_TO_US( p_sys->i_max_audiotrack_samples ) * 2;
         else
             b_forced = false;
@@ -1703,11 +1703,11 @@ AudioTrack_Thread( void *p_data )
                 if( i_ret != 0 )
                     i_last_time_blocked = 0;
                 else if( i_last_time_blocked == 0 )
-                    i_last_time_blocked = mdate();
+                    i_last_time_blocked = vlc_tick_now();
             }
 
             if( i_ret == 0 )
-                i_play_deadline = mdate() + __MAX( 10000, FRAMES_TO_US(
+                i_play_deadline = vlc_tick_now() + __MAX( 10000, FRAMES_TO_US(
                                   p_sys->i_max_audiotrack_samples / 5 ) );
             else
                 p_sys->circular.i_read += i_ret;
diff --git a/modules/audio_output/auhal.c b/modules/audio_output/auhal.c
index 25441e3e0a..f85904750d 100644
--- a/modules/audio_output/auhal.c
+++ b/modules/audio_output/auhal.c
@@ -842,7 +842,7 @@ AudioStreamChangeFormat(audio_output_t *p_aout, AudioStreamID i_stream_id,
          * set. */
         if (i > 0)
         {
-            vlc_tick_t timeout = mdate() + CLOCK_FREQ/2;
+            vlc_tick_t timeout = vlc_tick_now() + CLOCK_FREQ/2;
             if (vlc_cond_timedwait(&w.cond, &w.lock, timeout))
                 msg_Dbg(p_aout, "reached timeout");
         }
diff --git a/modules/audio_output/coreaudio_common.c b/modules/audio_output/coreaudio_common.c
index 8ade888968..79aaf2dc15 100644
--- a/modules/audio_output/coreaudio_common.c
+++ b/modules/audio_output/coreaudio_common.c
@@ -219,7 +219,7 @@ ca_TimeGet(audio_output_t *p_aout, vlc_tick_t *delay)
 
     const int64_t i_out_frames = BytesToFrames(p_sys, p_sys->i_out_size);
     *delay = FramesToUs(p_sys, i_out_frames + p_sys->i_render_frames)
-           + p_sys->i_dev_latency_us + i_render_time_us - mdate();
+           + p_sys->i_dev_latency_us + i_render_time_us - vlc_tick_now();
 
     lock_unlock(p_sys);
     return 0;
diff --git a/modules/audio_output/pulse.c b/modules/audio_output/pulse.c
index bc9f39be29..f999eb534b 100644
--- a/modules/audio_output/pulse.c
+++ b/modules/audio_output/pulse.c
@@ -240,7 +240,7 @@ static void stream_start(pa_stream *s, audio_output_t *aout, vlc_tick_t date)
         delta = 0; /* screwed */
     }
 
-    delta = (date - mdate()) - delta;
+    delta = (date - vlc_tick_now()) - delta;
     if (delta > 0) {
         msg_Dbg(aout, "deferring start (%"PRId64" us)", delta);
         delta += pa_rtclock_now();
diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index e90ce7fbd1..4fd193a758 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -1103,7 +1103,7 @@ static block_t *vlc_av_packet_Wrap(AVPacket *packet, vlc_tick_t i_length, AVCode
 
 static void check_hurry_up( encoder_sys_t *p_sys, AVFrame *frame, encoder_t *p_enc )
 {
-    vlc_tick_t current_date = mdate();
+    vlc_tick_t current_date = vlc_tick_now();
 
     if ( current_date + HURRY_UP_GUARD3 > frame->pts )
     {
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index a9eaa38c85..7bf12eba6b 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -1156,7 +1156,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t **pp_block )
 
         interpolate_next_pts( p_dec, frame );
 
-        update_late_frame_count( p_dec, p_block, mdate(), i_pts, frame->reordered_opaque);
+        update_late_frame_count( p_dec, p_block, vlc_tick_now(), i_pts, frame->reordered_opaque);
 
         if( ( !p_sys->p_va && !frame->linesize[0] ) ||
            ( p_dec->b_frame_drop_allowed && (frame->flags & AV_FRAME_FLAG_CORRUPT) &&
diff --git a/modules/codec/kate.c b/modules/codec/kate.c
index 70c4e41e72..8926125dfd 100644
--- a/modules/codec/kate.c
+++ b/modules/codec/kate.c
@@ -43,8 +43,8 @@
 /* #define ENABLE_PROFILE */
 
 #ifdef ENABLE_PROFILE
-# define PROFILE_START(name) int64_t profile_start_##name = mdate()
-# define PROFILE_STOP(name) fprintf( stderr, #name ": %f ms\n", (mdate() - profile_start_##name)/1000.0f )
+# define PROFILE_START(name) int64_t profile_start_##name = vlc_tick_now()
+# define PROFILE_STOP(name) fprintf( stderr, #name ": %f ms\n", (vlc_tick_now() - profile_start_##name)/1000.0f )
 #else
 # define PROFILE_START(name) ((void)0)
 # define PROFILE_STOP(name) ((void)0)
diff --git a/modules/codec/libass.c b/modules/codec/libass.c
index a314844708..03d2a95f0b 100644
--- a/modules/codec/libass.c
+++ b/modules/codec/libass.c
@@ -561,7 +561,7 @@ static int BuildRegions( rectangle_t *p_region, int i_max_region, ASS_Image *p_i
     int i_count;
 
 #ifdef DEBUG_REGION
-    int64_t i_ck_start = mdate();
+    int64_t i_ck_start = vlc_tick_now();
 #endif
 
     for( p_tmp = p_img_list, i_count = 0; p_tmp != NULL; p_tmp = p_tmp->next )
@@ -674,7 +674,7 @@ static int BuildRegions( rectangle_t *p_region, int i_max_region, ASS_Image *p_i
         p_region[n] = region[n];
 
 #ifdef DEBUG_REGION
-    int64_t i_ck_time = mdate() - i_ck_start;
+    int64_t i_ck_time = vlc_tick_now() - i_ck_start;
     msg_Err( p_spu, "ASS: %d objects merged into %d region in %d micros", i_count, i_region, (int)(i_ck_time) );
 #endif
 
diff --git a/modules/codec/omxil/mediacodec.c b/modules/codec/omxil/mediacodec.c
index 68587533fb..4a9ac18cdc 100644
--- a/modules/codec/omxil/mediacodec.c
+++ b/modules/codec/omxil/mediacodec.c
@@ -1422,7 +1422,7 @@ static int QueueBlockLocked(decoder_t *p_dec, block_t *p_in_block,
         /* Wait for the OutThread to stop (and process all remaining output
          * frames. Use a timeout here since we can't know if all decoders will
          * behave correctly. */
-        vlc_tick_t deadline = mdate() + INT64_C(3000000);
+        vlc_tick_t deadline = vlc_tick_now() + INT64_C(3000000);
         while (!p_sys->b_aborted && !p_sys->b_drained
             && vlc_cond_timedwait(&p_sys->dec_cond, &p_sys->lock, deadline) == 0);
 
diff --git a/modules/codec/omxil/omxil_utils.h b/modules/codec/omxil/omxil_utils.h
index 58c9e99b6e..c4f5fd2614 100644
--- a/modules/codec/omxil/omxil_utils.h
+++ b/modules/codec/omxil/omxil_utils.h
@@ -108,7 +108,7 @@ static inline OMX_TICKS ToOmxTicks(int64_t value)
 
 #define OMX_FIFO_GET_TIMEOUT(p_fifo, p_buffer, timeout) \
     do { vlc_mutex_lock( &(p_fifo)->lock ); \
-         vlc_tick_t end = mdate() + timeout; \
+         vlc_tick_t end = vlc_tick_now() + timeout; \
          if( !(p_fifo)->p_first ) \
              vlc_cond_timedwait( &(p_fifo)->wait, &(p_fifo)->lock, end ); \
          p_buffer = (p_fifo)->p_first; \
diff --git a/modules/codec/omxil/utils.c b/modules/codec/omxil/utils.c
index 0b877f323e..6df9a53d30 100644
--- a/modules/codec/omxil/utils.c
+++ b/modules/codec/omxil/utils.c
@@ -81,7 +81,7 @@ OMX_ERRORTYPE WaitForOmxEvent(OmxEventQueue *queue, OMX_EVENTTYPE *event,
     OMX_U32 *data_1, OMX_U32 *data_2, OMX_PTR *event_data)
 {
     OmxEvent *p_event;
-    vlc_tick_t deadline = mdate() + CLOCK_FREQ;
+    vlc_tick_t deadline = vlc_tick_now() + CLOCK_FREQ;
 
     vlc_mutex_lock(&queue->mutex);
 
@@ -116,7 +116,7 @@ OMX_ERRORTYPE WaitForSpecificOmxEvent(OmxEventQueue *queue,
 {
     OMX_ERRORTYPE status;
     OMX_EVENTTYPE event;
-    vlc_tick_t before =  mdate();
+    vlc_tick_t before =  vlc_tick_now();
 
     while(1)
     {
@@ -124,7 +124,7 @@ OMX_ERRORTYPE WaitForSpecificOmxEvent(OmxEventQueue *queue,
         if(status != OMX_ErrorNone) return status;
 
         if(event == specific_event) break;
-        if(mdate() - before > CLOCK_FREQ) return OMX_ErrorTimeout;
+        if(vlc_tick_now() - before > CLOCK_FREQ) return OMX_ErrorTimeout;
     }
 
     return OMX_ErrorNone;
diff --git a/modules/codec/synchro.c b/modules/codec/synchro.c
index c60fa066e4..8285d8c00b 100644
--- a/modules/codec/synchro.c
+++ b/modules/codec/synchro.c
@@ -224,7 +224,7 @@ bool decoder_SynchroChoose( decoder_synchro_t * p_synchro, int i_coding_type,
 
     i_current_rate = decoder_GetDisplayRate( p_synchro->p_dec );
 
-    now = mdate();
+    now = vlc_tick_now();
     period = CLOCK_FREQ * 1001 / p_synchro->i_frame_rate * i_current_rate;
 
     p_synchro->i_render_time = i_render_time;
@@ -356,7 +356,7 @@ void decoder_SynchroTrash( decoder_synchro_t * p_synchro )
  *****************************************************************************/
 void decoder_SynchroDecode( decoder_synchro_t * p_synchro )
 {
-    p_synchro->decoding_start = mdate();
+    p_synchro->decoding_start = vlc_tick_now();
     p_synchro->i_nb_ref = p_synchro->i_dec_nb_ref;
 }
 
@@ -371,7 +371,7 @@ void decoder_SynchroEnd( decoder_synchro_t * p_synchro, int i_coding_type,
     if( b_garbage )
         return;
 
-    tau = mdate() - p_synchro->decoding_start;
+    tau = vlc_tick_now() - p_synchro->decoding_start;
 
     /* If duration too high, something happened (pause ?), so don't
      * take it into account. */
@@ -408,7 +408,7 @@ void decoder_SynchroNewPicture( decoder_synchro_t * p_synchro, int i_coding_type
 {
     vlc_tick_t      period = CLOCK_FREQ * 1001 / p_synchro->i_frame_rate;
 #if 0
-    vlc_tick_t      now = mdate();
+    vlc_tick_t      now = vlc_tick_now();
 #endif
 
     switch( i_coding_type )
diff --git a/modules/codec/videotoolbox.m b/modules/codec/videotoolbox.m
index 32dc0c114f..8f46909df4 100644
--- a/modules/codec/videotoolbox.m
+++ b/modules/codec/videotoolbox.m
@@ -2143,7 +2143,7 @@ static int pic_holder_wait(struct pic_holder *pic_holder, const picture_t *pic)
      * output pictures (will they be rendered immediately ?), so don't wait
      * infinitely. The output will be paced anyway by the vlc_cond_timedwait()
      * call. */
-    vlc_tick_t deadline = mdate() + INT64_C(200000);
+    vlc_tick_t deadline = vlc_tick_now() + INT64_C(200000);
     int ret = 0;
     while (ret == 0 && pic_holder->field_reorder_max != 0
         && pic_holder->nb_field_out >= pic_holder->field_reorder_max + reserved_fields)
diff --git a/modules/codec/x265.c b/modules/codec/x265.c
index cee528cc97..00eeb50caa 100644
--- a/modules/codec/x265.c
+++ b/modules/codec/x265.c
@@ -76,7 +76,7 @@ static block_t *Encode(encoder_t *p_enc, picture_t *p_pict)
         if (unlikely(p_sys->initial_date == 0)) {
             p_sys->initial_date = p_pict->date;
 #ifndef NDEBUG
-            p_sys->start = mdate();
+            p_sys->start = vlc_tick_now();
 #endif
         }
 
@@ -130,7 +130,7 @@ static block_t *Encode(encoder_t *p_enc, picture_t *p_pict)
 
 #ifndef NDEBUG
     msg_Dbg(p_enc, "%zu bytes (frame %"PRId64", %.2ffps)", p_block->i_buffer,
-        p_sys->dts, (float)p_sys->dts * CLOCK_FREQ / (mdate() - p_sys->start));
+        p_sys->dts, (float)p_sys->dts * CLOCK_FREQ / (vlc_tick_now() - p_sys->start));
 #endif
 
     return p_block;
diff --git a/modules/control/dbus/dbus.c b/modules/control/dbus/dbus.c
index 8603a5e81c..3159fa0557 100644
--- a/modules/control/dbus/dbus.c
+++ b/modules/control/dbus/dbus.c
@@ -369,7 +369,7 @@ static void toggle_timeout(DBusTimeout *to, void *data)
 
     vlc_mutex_lock(&sys->lock);
     if (dbus_timeout_get_enabled(to))
-        *expiry = mdate() + UINT64_C(1000) * dbus_timeout_get_interval(to);
+        *expiry = vlc_tick_now() + UINT64_C(1000) * dbus_timeout_get_interval(to);
     vlc_mutex_unlock(&sys->lock);
 
     wakeup_main_loop(intf);
@@ -428,7 +428,7 @@ static void process_timeouts(intf_thread_t *intf)
             continue;
 
         vlc_tick_t *expiry = dbus_timeout_get_data(to);
-        if (*expiry > mdate())
+        if (*expiry > vlc_tick_now())
             continue;
 
         expiry += UINT64_C(1000) * dbus_timeout_get_interval(to);
@@ -831,7 +831,7 @@ static void *Run( void *data )
 
         if( i_events > 0 )
         {
-            vlc_tick_t now = mdate();
+            vlc_tick_t now = vlc_tick_now();
             if( events_last_date == VLC_TS_INVALID
              || now - events_last_date > EVENTS_DELAY )
             {
@@ -953,7 +953,7 @@ static int InputCallback( vlc_object_t *p_this, const char *psz_var,
             break;
         case INPUT_EVENT_POSITION:
         {
-            vlc_tick_t i_now = mdate(), i_pos, i_projected_pos, i_interval;
+            vlc_tick_t i_now = vlc_tick_now(), i_pos, i_projected_pos, i_interval;
             float f_current_rate;
 
             /* Detect seeks
diff --git a/modules/control/hotkeys.c b/modules/control/hotkeys.c
index 12449d7e6a..ac10feb6e1 100644
--- a/modules/control/hotkeys.c
+++ b/modules/control/hotkeys.c
@@ -637,7 +637,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
 
         case ACTIONID_SUBSYNC_MARKAUDIO:
         {
-            p_sys->subtitle_delaybookmarks.i_time_audio = mdate();
+            p_sys->subtitle_delaybookmarks.i_time_audio = vlc_tick_now();
             DisplayMessage( p_vout, _("Sub sync: bookmarked audio time"));
             break;
         }
@@ -658,7 +658,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
                 }
                 else
                 {
-                    p_sys->subtitle_delaybookmarks.i_time_subtitle = mdate();
+                    p_sys->subtitle_delaybookmarks.i_time_subtitle = vlc_tick_now();
                     DisplayMessage(p_vout,
                                    _("Sub sync: bookmarked subtitle time"));
                 }
diff --git a/modules/control/netsync.c b/modules/control/netsync.c
index ea59856a62..e6700fdbe1 100644
--- a/modules/control/netsync.c
+++ b/modules/control/netsync.c
@@ -198,7 +198,7 @@ static void *Master(void *handle)
         if (master_system < 0)
             continue;
 
-        data[0] = hton64(mdate());
+        data[0] = hton64(vlc_tick_now());
         data[1] = hton64(master_system);
 
         /* Reply to the sender */
@@ -231,7 +231,7 @@ static void *Slave(void *handle)
             goto wait;
 
         /* Send clock request to the master */
-        const vlc_tick_t send_date = mdate();
+        const vlc_tick_t send_date = vlc_tick_now();
 
         data[0] = hton64(system);
         send(sys->fd, data, 8, 0);
@@ -240,7 +240,7 @@ static void *Slave(void *handle)
         if (poll(&ufd, 1, sys->timeout) <= 0)
             continue;
 
-        const vlc_tick_t receive_date = mdate();
+        const vlc_tick_t receive_date = vlc_tick_now();
         if (recv(sys->fd, data, 16, 0) < 16)
             goto wait;
 
diff --git a/modules/demux/adaptive/PlaylistManager.cpp b/modules/demux/adaptive/PlaylistManager.cpp
index 1de276b38c..b123968fb6 100644
--- a/modules/demux/adaptive/PlaylistManager.cpp
+++ b/modules/demux/adaptive/PlaylistManager.cpp
@@ -422,7 +422,7 @@ int PlaylistManager::doDemux(vlc_tick_t increment)
         for(it=streams.begin(); it!=streams.end(); ++it)
             b_dead &= !(*it)->canActivate();
         if(!b_dead)
-            vlc_cond_timedwait(&demux.cond, &demux.lock, mdate() + CLOCK_FREQ / 20);
+            vlc_cond_timedwait(&demux.cond, &demux.lock, vlc_tick_now() + CLOCK_FREQ / 20);
         vlc_mutex_unlock(&demux.lock);
         return (b_dead) ? AbstractStream::status_eof : AbstractStream::status_buffering;
     }
@@ -464,7 +464,7 @@ int PlaylistManager::doDemux(vlc_tick_t increment)
         break;
     case AbstractStream::status_buffering:
         vlc_mutex_lock(&demux.lock);
-        vlc_cond_timedwait(&demux.cond, &demux.lock, mdate() + CLOCK_FREQ / 20);
+        vlc_cond_timedwait(&demux.cond, &demux.lock, vlc_tick_now() + CLOCK_FREQ / 20);
         vlc_mutex_unlock(&demux.lock);
         break;
     case AbstractStream::status_discontinuity:
@@ -647,7 +647,7 @@ void PlaylistManager::Run()
 
         if(i_return != AbstractStream::buffering_lessthanmin)
         {
-            vlc_tick_t i_deadline = mdate();
+            vlc_tick_t i_deadline = vlc_tick_now();
             if(i_return == AbstractStream::buffering_ongoing)
                 i_deadline += (CLOCK_FREQ / 100);
             else if(i_return == AbstractStream::buffering_full)
@@ -664,7 +664,7 @@ void PlaylistManager::Run()
             mutex_cleanup_push(&lock);
             while(b_buffering &&
                     vlc_cond_timedwait(&waitcond, &lock, i_deadline) == 0 &&
-                    i_deadline > mdate());
+                    i_deadline > vlc_tick_now());
             vlc_cleanup_pop();
         }
     }
diff --git a/modules/demux/adaptive/http/Chunk.cpp b/modules/demux/adaptive/http/Chunk.cpp
index 08ca84784c..36e911ed56 100644
--- a/modules/demux/adaptive/http/Chunk.cpp
+++ b/modules/demux/adaptive/http/Chunk.cpp
@@ -192,9 +192,9 @@ block_t * HTTPChunkSource::read(size_t readsize)
         return NULL;
     }
 
-    vlc_tick_t time = mdate();
+    vlc_tick_t time = vlc_tick_now();
     ssize_t ret = connection->read(p_block->p_buffer, readsize);
-    time = mdate() - time;
+    time = vlc_tick_now() - time;
     if(ret < 0)
     {
         block_Release(p_block);
@@ -369,7 +369,7 @@ void HTTPChunkBufferedSource::bufferize(size_t readsize)
         vlc_mutex_locker locker( &lock );
         done = true;
         rate.size = buffered + consumed;
-        rate.time = mdate() - downloadstart;
+        rate.time = vlc_tick_now() - downloadstart;
         downloadstart = 0;
     }
     else
@@ -382,7 +382,7 @@ void HTTPChunkBufferedSource::bufferize(size_t readsize)
         {
             done = true;
             rate.size = buffered + consumed;
-            rate.time = mdate() - downloadstart;
+            rate.time = vlc_tick_now() - downloadstart;
             downloadstart = 0;
         }
     }
@@ -399,7 +399,7 @@ bool HTTPChunkBufferedSource::prepare()
 {
     if(!prepared)
     {
-        downloadstart = mdate();
+        downloadstart = vlc_tick_now();
         return HTTPChunkSource::prepare();
     }
     return true;
diff --git a/modules/demux/avi/avi.c b/modules/demux/avi/avi.c
index 55d265174d..eaec2b4d73 100644
--- a/modules/demux/avi/avi.c
+++ b/modules/demux/avi/avi.c
@@ -2702,7 +2702,7 @@ static void AVI_IndexCreate( demux_t *p_demux )
 
 
     /* Only show dialog if AVI is > 10MB */
-    i_dialog_update = mdate();
+    i_dialog_update = vlc_tick_now();
     if( stream_Size( p_demux->s ) > 10000000 )
     {
         p_dialog_id =
@@ -2716,7 +2716,7 @@ static void AVI_IndexCreate( demux_t *p_demux )
         avi_packet_t pk;
 
         /* Don't update/check dialog too often */
-        if( p_dialog_id != NULL && mdate() - i_dialog_update > 100000 )
+        if( p_dialog_id != NULL && vlc_tick_now() - i_dialog_update > 100000 )
         {
             if( vlc_dialog_is_cancelled( p_demux, p_dialog_id ) )
                 break;
@@ -2726,7 +2726,7 @@ static void AVI_IndexCreate( demux_t *p_demux )
             double f_pos     = f_current / f_size;
             vlc_dialog_update_progress( p_demux, p_dialog_id, f_pos );
 
-            i_dialog_update = mdate();
+            i_dialog_update = vlc_tick_now();
         }
 
         if( AVI_PacketGetHeader( p_demux, &pk ) )
diff --git a/modules/demux/image.c b/modules/demux/image.c
index b9c92d9b02..bc71b688d5 100644
--- a/modules/demux/image.c
+++ b/modules/demux/image.c
@@ -195,7 +195,7 @@ static int Demux(demux_t *demux)
     if (sys->pts_next != VLC_TS_INVALID) {
         deadline = sys->pts_next;
     } else if (sys->is_realtime) {
-        deadline = mdate();
+        deadline = vlc_tick_now();
         const vlc_tick_t max_wait = CLOCK_FREQ / 50;
         if (deadline + max_wait < pts_first) {
             es_out_SetPCR(demux->out, deadline);
@@ -733,7 +733,7 @@ static int Open(vlc_object_t *object)
     sys->es          = es_out_Add(demux->out, &fmt);
     sys->duration    = CLOCK_FREQ * var_InheritFloat(demux, "image-duration");
     sys->is_realtime = var_InheritBool(demux, "image-realtime");
-    sys->pts_offset  = sys->is_realtime ? mdate() : 0;
+    sys->pts_offset  = sys->is_realtime ? vlc_tick_now() : 0;
     sys->pts_next    = VLC_TS_INVALID;
     date_Init(&sys->pts, fmt.video.i_frame_rate, fmt.video.i_frame_rate_base);
     date_Set(&sys->pts, VLC_TS_0);
diff --git a/modules/demux/mjpeg.c b/modules/demux/mjpeg.c
index 17a9aa73af..cbc5a1609d 100644
--- a/modules/demux/mjpeg.c
+++ b/modules/demux/mjpeg.c
@@ -274,7 +274,7 @@ static int SendBlock( demux_t *p_demux, int i )
     }
     else
     {
-        p_block->i_pts = mdate();
+        p_block->i_pts = vlc_tick_now();
     }
     p_block->i_dts = p_block->i_pts;
 
@@ -282,7 +282,7 @@ static int SendBlock( demux_t *p_demux, int i )
     es_out_Send( p_demux->out, p_sys->p_es, p_block );
 
     if( p_sys->b_still )
-        p_sys->i_still_end = mdate() + p_sys->i_frame_length;
+        p_sys->i_still_end = vlc_tick_now() + p_sys->i_frame_length;
 
     return VLC_DEMUXER_SUCCESS;
 }
diff --git a/modules/demux/mp4/heif.c b/modules/demux/mp4/heif.c
index f841df3299..18381c68be 100644
--- a/modules/demux/mp4/heif.c
+++ b/modules/demux/mp4/heif.c
@@ -221,7 +221,7 @@ static int DemuxHEIF( demux_t *p_demux )
     {
         bool b_empty;
         es_out_Control( p_demux->out, ES_OUT_GET_EMPTY, &b_empty );
-        if( !b_empty || mdate() <= p_sys->i_end_display_time )
+        if( !b_empty || vlc_tick_now() <= p_sys->i_end_display_time )
         {
             vlc_tick_sleep( 40 * 1000 );
             return VLC_DEMUXER_SUCCESS;
@@ -423,7 +423,7 @@ static int DemuxHEIF( demux_t *p_demux )
 
     p_block->i_flags |= BLOCK_FLAG_END_OF_SEQUENCE;
 
-    p_sys->i_end_display_time = mdate() + p_block->i_length;
+    p_sys->i_end_display_time = vlc_tick_now() + p_block->i_length;
     p_sys->b_seekpoint_changed = true;
 
     p_sys->i_pcr = p_block->i_dts + p_block->i_length;
diff --git a/modules/demux/rawdv.c b/modules/demux/rawdv.c
index d91311f47e..a3425823c8 100644
--- a/modules/demux/rawdv.c
+++ b/modules/demux/rawdv.c
@@ -259,7 +259,7 @@ static int Demux( demux_t *p_demux )
     if( p_sys->b_hurry_up )
     {
          /* 3 frames */
-        p_sys->i_pcr = mdate() + (p_sys->i_dsf ? 120000 : 90000);
+        p_sys->i_pcr = vlc_tick_now() + (p_sys->i_dsf ? 120000 : 90000);
     }
 
     /* Call the pace control */
diff --git a/modules/gui/skins2/x11/x11_loop.cpp b/modules/gui/skins2/x11/x11_loop.cpp
index e2bc306866..b9dc0d1b81 100644
--- a/modules/gui/skins2/x11/x11_loop.cpp
+++ b/modules/gui/skins2/x11/x11_loop.cpp
@@ -254,7 +254,7 @@ void X11Loop::handleX11Event()
             if( event.type == ButtonPress &&
                 event.xbutton.button == 1 )
             {
-                vlc_tick_t time = mdate();
+                vlc_tick_t time = vlc_tick_now();
                 int x, y;
                 pFactory->getMousePos( x, y );
                 if( time - m_lastClickTime < m_dblClickDelay &&
diff --git a/modules/gui/skins2/x11/x11_timer.cpp b/modules/gui/skins2/x11/x11_timer.cpp
index 258e607311..4d1b932577 100644
--- a/modules/gui/skins2/x11/x11_timer.cpp
+++ b/modules/gui/skins2/x11/x11_timer.cpp
@@ -51,7 +51,7 @@ void X11Timer::start( int delay, bool oneShot )
 {
     m_interval = 1000LL * (vlc_tick_t)delay;
     m_oneShot = oneShot;
-    m_nextDate = mdate() + m_interval;
+    m_nextDate = vlc_tick_now() + m_interval;
     m_pTimerLoop->addTimer( *this );
 }
 
@@ -103,7 +103,7 @@ void X11TimerLoop::removeTimer( X11Timer &rTimer )
 
 void X11TimerLoop::waitNextTimer()
 {
-    vlc_tick_t curDate = mdate();
+    vlc_tick_t curDate = vlc_tick_now();
     vlc_tick_t nextDate = INT64_MAX;
 
     X11Timer *nextTimer = NULL;
diff --git a/modules/hw/vdpau/display.c b/modules/hw/vdpau/display.c
index e6508fe764..80b57d70fe 100644
--- a/modules/hw/vdpau/display.c
+++ b/modules/hw/vdpau/display.c
@@ -260,7 +260,7 @@ static void Queue(vout_display_t *vd, picture_t *pic, subpicture_t *subpic,
             RenderRegion(vd, surface, subpic, r);
 
     /* Compute picture presentation time */
-    vlc_tick_t now = mdate();
+    vlc_tick_t now = vlc_tick_now();
     VdpTime pts;
 
     err = vdp_presentation_queue_get_time(sys->vdp, sys->queue, &pts);
diff --git a/modules/lua/libs/misc.c b/modules/lua/libs/misc.c
index 7aecce03bb..45661ccbac 100644
--- a/modules/lua/libs/misc.c
+++ b/modules/lua/libs/misc.c
@@ -129,7 +129,7 @@ static int vlclua_quit( lua_State *L )
 
 static int vlclua_mdate( lua_State *L )
 {
-    lua_pushnumber( L, mdate() );
+    lua_pushnumber( L, vlc_tick_now() );
     return 1;
 }
 
diff --git a/modules/misc/audioscrobbler.c b/modules/misc/audioscrobbler.c
index 0dcd5e9dd9..46cc60049a 100644
--- a/modules/misc/audioscrobbler.c
+++ b/modules/misc/audioscrobbler.c
@@ -225,7 +225,7 @@ static void AddToQueue (intf_thread_t *p_this)
         goto end;
 
     /* wait for the user to listen enough before submitting */
-    played_time = mdate() - p_sys->p_current_song.i_start -
+    played_time = vlc_tick_now() - p_sys->p_current_song.i_start -
                             p_sys->time_total_pauses;
     played_time /= CLOCK_FREQ; /* µs → s */
 
@@ -327,10 +327,10 @@ static int PlayingChange(vlc_object_t *p_this, const char *psz_var,
     if (state >= END_S)
         AddToQueue(p_intf);
     else if (state == PAUSE_S)
-        p_sys->time_pause = mdate();
+        p_sys->time_pause = vlc_tick_now();
     else if (p_sys->time_pause > 0 && state == PLAYING_S)
     {
-        p_sys->time_total_pauses += (mdate() - p_sys->time_pause);
+        p_sys->time_total_pauses += (vlc_tick_now() - p_sys->time_pause);
         p_sys->time_pause = 0;
     }
 
@@ -374,7 +374,7 @@ static int ItemChange(vlc_object_t *p_this, const char *psz_var,
 
     p_sys->time_total_pauses = 0;
     time(&p_sys->p_current_song.date);        /* to be sent to last.fm */
-    p_sys->p_current_song.i_start = mdate();    /* only used locally */
+    p_sys->p_current_song.i_start = vlc_tick_now();    /* only used locally */
 
     p_sys->p_input = vlc_object_hold(p_input);
     var_AddCallback(p_input, "intf-event", PlayingChange, p_intf);
@@ -660,7 +660,7 @@ static void HandleInterval(vlc_tick_t *next, unsigned int *i_interval)
         if (*i_interval > 120)
             *i_interval = 120;
     }
-    *next = mdate() + (*i_interval * CLOCK_FREQ * 60);
+    *next = vlc_tick_now() + (*i_interval * CLOCK_FREQ * 60);
 }
 
 /*****************************************************************************
diff --git a/modules/misc/stats.c b/modules/misc/stats.c
index fc9e0e0262..49b124c956 100644
--- a/modules/misc/stats.c
+++ b/modules/misc/stats.c
@@ -57,13 +57,13 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
         msg_Dbg( p_dec, "got %"PRIu64" ms",
                  *(vlc_tick_t *)p_block->p_buffer  / 1000 );
         msg_Dbg( p_dec, "got %"PRIu64" ms offset",
-                 (mdate() - *(vlc_tick_t *)p_block->p_buffer) / 1000 );
+                 (vlc_tick_now() - *(vlc_tick_t *)p_block->p_buffer) / 1000 );
         *(vlc_tick_t *)(p_pic->p->p_pixels) = *(vlc_tick_t *)p_block->p_buffer;
     }
     else
     {
         msg_Dbg( p_dec, "got a packet not from stats demuxer" );
-        *(vlc_tick_t *)(p_pic->p->p_pixels) = mdate();
+        *(vlc_tick_t *)(p_pic->p->p_pixels) = vlc_tick_now();
     }
 
     p_pic->date = p_block->i_pts != VLC_TS_INVALID ?
@@ -102,7 +102,7 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict )
     (void)p_pict;
     block_t * p_block = block_Alloc( kBufferSize );
 
-    *(vlc_tick_t*)p_block->p_buffer = mdate();
+    *(vlc_tick_t*)p_block->p_buffer = vlc_tick_now();
     p_block->i_buffer = kBufferSize;
     p_block->i_length = kBufferSize;
     p_block->i_dts = p_pict->date;
@@ -152,7 +152,7 @@ static int Demux( demux_t *p_demux )
     p_block->i_dts = p_block->i_pts = date_Increment( &p_sys->pts, kBufferSize );
 
     msg_Dbg( p_demux, "demux got %"PRId64" ms offset",
-             (mdate() - *(vlc_tick_t *)p_block->p_buffer) / 1000 );
+             (vlc_tick_now() - *(vlc_tick_t *)p_block->p_buffer) / 1000 );
 
     //es_out_SetPCR( p_demux->out, p_block->i_pts );
 
diff --git a/modules/mux/mpeg/ts.c b/modules/mux/mpeg/ts.c
index 8535fc4a35..681cf3732c 100644
--- a/modules/mux/mpeg/ts.c
+++ b/modules/mux/mpeg/ts.c
@@ -1776,7 +1776,7 @@ static void TSDate( sout_mux_t *p_mux, sout_buffer_chain_t *p_chain_ts,
         {
             msg_Warn( p_mux, "max bitrate exceeded at %"PRId64
                       " (%d bi/s for %d pkt in %"PRId64" us)",
-                      i_pcr_dts + p_sys->i_shaping_delay * 3 / 2 - mdate(),
+                      i_pcr_dts + p_sys->i_shaping_delay * 3 / 2 - vlc_tick_now(),
                       i_bitrate, i_packet_count, i_pcr_length);
         }
     }
diff --git a/modules/services_discovery/microdns.c b/modules/services_discovery/microdns.c
index 02109cebad..be05bbc2e7 100644
--- a/modules/services_discovery/microdns.c
+++ b/modules/services_discovery/microdns.c
@@ -173,7 +173,7 @@ items_add_input( struct discovery_sys *p_sys, services_discovery_t *p_sd,
     p_item->psz_uri = psz_uri;
     p_item->p_input_item = p_input_item;
     p_item->p_renderer_item = NULL;
-    p_item->i_last_seen = mdate();
+    p_item->i_last_seen = vlc_tick_now();
     vlc_array_append_or_abort( &p_sys->items, p_item );
     services_discovery_AddItem( p_sd, p_input_item );
 
@@ -205,7 +205,7 @@ items_add_renderer( struct discovery_sys *p_sys, vlc_renderer_discovery_t *p_rd,
     p_item->psz_uri = psz_uri;
     p_item->p_input_item = NULL;
     p_item->p_renderer_item = p_renderer_item;
-    p_item->i_last_seen = mdate();
+    p_item->i_last_seen = vlc_tick_now();
     vlc_array_append_or_abort( &p_sys->items, p_item );
     vlc_rd_add_item( p_rd, p_renderer_item );
 
@@ -238,7 +238,7 @@ items_exists( struct discovery_sys *p_sys, const char *psz_uri )
         struct item *p_item = vlc_array_item_at_index( &p_sys->items, i );
         if( strcmp( p_item->psz_uri, psz_uri ) == 0 )
         {
-            p_item->i_last_seen = mdate();
+            p_item->i_last_seen = vlc_tick_now();
             return true;
         }
     }
@@ -250,7 +250,7 @@ items_timeout( struct discovery_sys *p_sys, services_discovery_t *p_sd,
                vlc_renderer_discovery_t *p_rd )
 {
     assert( p_rd != NULL || p_sd != NULL );
-    vlc_tick_t i_now = mdate();
+    vlc_tick_t i_now = vlc_tick_now();
 
     /* Remove items that are not seen since TIMEOUT */
     for( size_t i = 0; i < vlc_array_count( &p_sys->items ); ++i )
diff --git a/modules/services_discovery/sap.c b/modules/services_discovery/sap.c
index dbe4bd2785..7e5ce60574 100644
--- a/modules/services_discovery/sap.c
+++ b/modules/services_discovery/sap.c
@@ -570,7 +570,7 @@ static void *Run( void *data )
             }
         }
 
-        vlc_tick_t now = mdate();
+        vlc_tick_t now = vlc_tick_now();
 
         /* A 1 hour timeout correspond to the RFC Implicit timeout.
          * This timeout is tuned in the following loop. */
@@ -814,7 +814,7 @@ static int ParseSAP( services_discovery_t *p_sd, const uint8_t *buf,
                     p_announce->i_period_trust++;
 
                 /* Compute the average period */
-                vlc_tick_t now = mdate();
+                vlc_tick_t now = vlc_tick_now();
                 p_announce->i_period = ( p_announce->i_period * (p_announce->i_period_trust-1) + (now - p_announce->i_last) ) / p_announce->i_period_trust;
                 p_announce->i_last = now;
             }
@@ -846,7 +846,7 @@ sap_announce_t *CreateAnnounce( services_discovery_t *p_sd, uint32_t *i_source,
 
     p_sys = p_sd->p_sys;
 
-    p_sap->i_last = mdate();
+    p_sap->i_last = vlc_tick_now();
     p_sap->i_period = 0;
     p_sap->i_period_trust = 0;
     p_sap->i_hash = i_hash;
diff --git a/modules/stream_filter/cache_block.c b/modules/stream_filter/cache_block.c
index 339539b9b6..8609382f9d 100644
--- a/modules/stream_filter/cache_block.c
+++ b/modules/stream_filter/cache_block.c
@@ -96,7 +96,7 @@ static int AStreamRefillBlock(stream_t *s)
     }
 
     /* Now read a new block */
-    const vlc_tick_t start = mdate();
+    const vlc_tick_t start = vlc_tick_now();
     block_t *b;
 
     for (;;)
@@ -110,7 +110,7 @@ static int AStreamRefillBlock(stream_t *s)
         if (vlc_stream_Eof(s->s))
             return VLC_EGENERIC;
     }
-    sys->stat.read_time += mdate() - start;
+    sys->stat.read_time += vlc_tick_now() - start;
     size_t added_bytes;
     block_ChainProperties( b, NULL, &added_bytes, NULL );
     sys->stat.read_bytes += added_bytes;
@@ -122,13 +122,13 @@ static int AStreamRefillBlock(stream_t *s)
 static void AStreamPrebufferBlock(stream_t *s)
 {
     stream_sys_t *sys = s->p_sys;
-    vlc_tick_t start = mdate();
+    vlc_tick_t start = vlc_tick_now();
     bool first = true;
 
     msg_Dbg(s, "starting pre-buffering");
     for (;;)
     {
-        const vlc_tick_t now = mdate();
+        const vlc_tick_t now = vlc_tick_now();
         size_t cache_size = block_BytestreamRemaining( &sys->cache );
 
         if (vlc_killed() || cache_size > STREAM_CACHE_PREBUFFER_SIZE)
@@ -162,7 +162,7 @@ static void AStreamPrebufferBlock(stream_t *s)
         if (first)
         {
             msg_Dbg(s, "received first data after %"PRId64" ms",
-                    (mdate() - start) / 1000);
+                    (vlc_tick_now() - start) / 1000);
             first = false;
         }
     }
diff --git a/modules/stream_filter/cache_read.c b/modules/stream_filter/cache_read.c
index 40f68eb08a..859529481b 100644
--- a/modules/stream_filter/cache_read.c
+++ b/modules/stream_filter/cache_read.c
@@ -124,7 +124,7 @@ static int AStreamRefillStream(stream_t *s)
                  sys->i_used, i_toread);
 #endif
 
-    vlc_tick_t start = mdate();
+    vlc_tick_t start = vlc_tick_now();
     while (i_toread > 0)
     {
         int i_off = tk->i_end % STREAM_CACHE_TRACK_SIZE;
@@ -163,21 +163,21 @@ static int AStreamRefillStream(stream_t *s)
         sys->stat.i_read_count++;
     }
 
-    sys->stat.i_read_time += mdate() - start;
+    sys->stat.i_read_time += vlc_tick_now() - start;
     return VLC_SUCCESS;
 }
 
 static void AStreamPrebufferStream(stream_t *s)
 {
     stream_sys_t *sys = s->p_sys;
-    vlc_tick_t start = mdate();
+    vlc_tick_t start = vlc_tick_now();
     bool first = true;
 
     msg_Dbg(s, "starting pre-buffering");
     for (;;)
     {
         stream_track_t *tk = &sys->tk[sys->i_tk];
-        vlc_tick_t now = mdate();
+        vlc_tick_t now = vlc_tick_now();
 
         int i_read;
         int i_buffered = tk->i_end - tk->i_start;
@@ -209,7 +209,7 @@ static void AStreamPrebufferStream(stream_t *s)
         if (first)
         {
             msg_Dbg(s, "received first data after %"PRId64" ms",
-                    (mdate() - start) / 1000);
+                    (vlc_tick_now() - start) / 1000);
             first = false;
         }
 
@@ -324,7 +324,7 @@ static int AStreamSeekStream(stream_t *s, uint64_t i_pos)
         i_skip_threshold = INT64_MAX;
 
     /* Date the current track */
-    p_current->date = mdate();
+    p_current->date = vlc_tick_now();
 
     /* Search a new track slot */
     stream_track_t *tk = NULL;
diff --git a/modules/stream_filter/hds/hds.c b/modules/stream_filter/hds/hds.c
index f498aa4d36..b29dc89a2b 100644
--- a/modules/stream_filter/hds/hds.c
+++ b/modules/stream_filter/hds/hds.c
@@ -1135,7 +1135,7 @@ static void* live_thread( void* p )
 
     while( ! sys->closed )
     {
-        last_dl_start_time = mdate();
+        last_dl_start_time = vlc_tick_now();
         stream_t* download_stream = vlc_stream_NewURL( p_this, abst_url );
         if( ! download_stream )
         {
diff --git a/modules/stream_out/autodel.c b/modules/stream_out/autodel.c
index 302f23c466..b76c5f5ea2 100644
--- a/modules/stream_out/autodel.c
+++ b/modules/stream_out/autodel.c
@@ -146,7 +146,7 @@ static int Send( sout_stream_t *p_stream, void *_p_es, block_t *p_buffer )
 {
     sout_stream_sys_t *p_sys = (sout_stream_sys_t *)p_stream->p_sys;
     sout_stream_id_sys_t *p_es = (sout_stream_id_sys_t *)_p_es;
-    vlc_tick_t i_current = mdate();
+    vlc_tick_t i_current = vlc_tick_now();
     int i;
 
     p_es->i_last = p_buffer->i_dts;
diff --git a/modules/stream_out/bridge.c b/modules/stream_out/bridge.c
index 351120d168..b0135e72df 100644
--- a/modules/stream_out/bridge.c
+++ b/modules/stream_out/bridge.c
@@ -508,7 +508,7 @@ static int SendIn( sout_stream_t *p_stream, void *_id, block_t *p_buffer )
     bridge_t *p_bridge;
     bool b_no_es = true;
     int i;
-    vlc_tick_t i_date = mdate();
+    vlc_tick_t i_date = vlc_tick_now();
 
     /* First forward the packet for our own ES */
     if( !p_sys->b_placeholder )
diff --git a/modules/stream_out/chromecast/chromecast_ctrl.cpp b/modules/stream_out/chromecast/chromecast_ctrl.cpp
index 2b8b870a3f..abdd68b4d2 100644
--- a/modules/stream_out/chromecast/chromecast_ctrl.cpp
+++ b/modules/stream_out/chromecast/chromecast_ctrl.cpp
@@ -492,7 +492,7 @@ int intf_sys_t::pace()
     m_interrupted = false;
     vlc_interrupt_register( interrupt_wake_up_cb, this );
     int ret = 0;
-    vlc_tick_t deadline = mdate() + CLOCK_FREQ/2;
+    vlc_tick_t deadline = vlc_tick_now() + CLOCK_FREQ/2;
 
     /* Wait for the sout to send more data via http (m_pace), or wait for the
      * CC to finish. In case the demux filter is EOF, we always wait for
@@ -862,7 +862,7 @@ void intf_sys_t::processMediaMessage( const castchannel::CastMessage& msg )
             {
                 vlc_tick_t currentTime = timeCCToVLC((double) status[0]["currentTime"]);
                 m_cc_time = currentTime;
-                m_cc_time_date = mdate();
+                m_cc_time_date = vlc_tick_now();
 
                 setState( Playing );
             }
@@ -947,7 +947,7 @@ bool intf_sys_t::handleMessages()
     size_t i_payloadSize = 0;
     size_t i_received = 0;
     bool b_timeout = false;
-    vlc_tick_t i_begin_time = mdate();
+    vlc_tick_t i_begin_time = vlc_tick_now();
 
     /* Packet structure:
      * +------------------------------------+------------------------------+
@@ -960,7 +960,7 @@ bool intf_sys_t::handleMessages()
         // how many bytes to read
         ssize_t i_ret = m_communication->receive( p_packet + i_received,
                                         i_payloadSize + PACKET_HEADER_LEN - i_received,
-                                        PING_WAIT_TIME - ( mdate() - i_begin_time ) / CLOCK_FREQ,
+                                        PING_WAIT_TIME - ( vlc_tick_now() - i_begin_time ) / CLOCK_FREQ,
                                         &b_timeout );
         if ( i_ret < 0 )
         {
@@ -1138,7 +1138,7 @@ vlc_tick_t intf_sys_t::getPlaybackTimestamp()
         case Playing:
         {
             assert( m_communication );
-            vlc_tick_t now = mdate();
+            vlc_tick_t now = vlc_tick_now();
             if( m_state == Playing && m_last_request_id == 0
              && now - m_cc_time_last_request_date > INT64_C(4000000) )
             {
diff --git a/modules/stream_out/chromecast/chromecast_demux.cpp b/modules/stream_out/chromecast/chromecast_demux.cpp
index bacb3a70ee..6935416449 100644
--- a/modules/stream_out/chromecast/chromecast_demux.cpp
+++ b/modules/stream_out/chromecast/chromecast_demux.cpp
@@ -391,13 +391,13 @@ struct demux_cc
             if (paused)
             {
                 if (m_pause_date == VLC_TS_INVALID)
-                    m_pause_date = mdate();
+                    m_pause_date = vlc_tick_now();
             }
             else
             {
                 if (m_pause_date != VLC_TS_INVALID)
                 {
-                    m_pause_delay += mdate() - m_pause_date;
+                    m_pause_delay += vlc_tick_now() - m_pause_date;
                     m_pause_date = VLC_TS_INVALID;
                 }
             }
diff --git a/modules/stream_out/description.c b/modules/stream_out/description.c
index 5451942ac2..a5bfe779c5 100644
--- a/modules/stream_out/description.c
+++ b/modules/stream_out/description.c
@@ -118,7 +118,7 @@ static void *Add( sout_stream_t *p_stream, const es_format_t *p_fmt )
     TAB_APPEND( p_sys->data->i_es, p_sys->data->es, p_fmt_copy );
 
     if( p_sys->i_stream_start <= 0 )
-        p_sys->i_stream_start = mdate();
+        p_sys->i_stream_start = vlc_tick_now();
 
     return (void *)p_fmt_copy;
 }
@@ -137,7 +137,7 @@ static int Send( sout_stream_t *p_stream, void *id, block_t *p_buffer )
 
     block_ChainRelease( p_buffer );
 
-    if( p_sys->i_stream_start + 1500000 < mdate() )
+    if( p_sys->i_stream_start + 1500000 < vlc_tick_now() )
         vlc_sem_post(p_sys->data->sem);
 
     return VLC_SUCCESS;
diff --git a/modules/stream_out/record.c b/modules/stream_out/record.c
index 18ee744e24..8e18a208d1 100644
--- a/modules/stream_out/record.c
+++ b/modules/stream_out/record.c
@@ -234,13 +234,13 @@ static int Send( sout_stream_t *p_stream, void *id, block_t *p_buffer )
     sout_stream_sys_t *p_sys = p_stream->p_sys;
 
     if( p_sys->i_date_start < 0 )
-        p_sys->i_date_start = mdate();
+        p_sys->i_date_start = vlc_tick_now();
     if( !p_sys->p_out &&
-        ( mdate() - p_sys->i_date_start > p_sys->i_max_wait ||
+        ( vlc_tick_now() - p_sys->i_date_start > p_sys->i_max_wait ||
           p_sys->i_size > p_sys->i_max_size ) )
     {
         msg_Dbg( p_stream, "Starting recording, waited %ds and %dbyte",
-                 (int)((mdate() - p_sys->i_date_start)/CLOCK_FREQ), (int)p_sys->i_size );
+                 (int)((vlc_tick_now() - p_sys->i_date_start)/CLOCK_FREQ), (int)p_sys->i_size );
         OutputStart( p_stream );
     }
 
diff --git a/modules/stream_out/rtp.c b/modules/stream_out/rtp.c
index 7d60f63d7f..5df5db2c41 100644
--- a/modules/stream_out/rtp.c
+++ b/modules/stream_out/rtp.c
@@ -1558,7 +1558,7 @@ static vlc_tick_t rtp_init_ts( const vod_media_t *p_media,
                             const char *psz_vod_session )
 {
     if (p_media == NULL || psz_vod_session == NULL)
-        return mdate();
+        return vlc_tick_now();
 
     uint64_t i_ts_init;
     /* As per RFC 2326, session identifiers are at least 8 bytes long */
@@ -1597,7 +1597,7 @@ vlc_tick_t rtp_get_ts( const sout_stream_t *p_stream, const sout_stream_id_sys_t
     if( i_npt_zero == VLC_TS_INVALID )
         return p_sys->i_pts_zero;
 
-    vlc_tick_t now = mdate();
+    vlc_tick_t now = vlc_tick_now();
     if( now < i_npt_zero )
         return p_sys->i_pts_zero;
 
diff --git a/modules/stream_out/rtsp.c b/modules/stream_out/rtsp.c
index a907389601..80b136b852 100644
--- a/modules/stream_out/rtsp.c
+++ b/modules/stream_out/rtsp.c
@@ -320,7 +320,7 @@ static void RtspTimeOut( void *data )
     rtsp_stream_t *rtsp = data;
 
     vlc_mutex_lock(&rtsp->lock);
-    vlc_tick_t now = mdate();
+    vlc_tick_t now = vlc_tick_now();
     for (int i = rtsp->sessionc - 1; i >= 0; i--)
     {
         if (rtsp->sessionv[i]->last_seen + rtsp->timeout * CLOCK_FREQ < now)
@@ -406,7 +406,7 @@ static void RtspClientAlive( rtsp_session_t *session )
     if (session->stream->timeout <= 0)
         return;
 
-    session->last_seen = mdate();
+    session->last_seen = vlc_tick_now();
     RtspUpdateTimer(session->stream);
 }
 
diff --git a/modules/text_renderer/freetype/fonts/fontconfig.c b/modules/text_renderer/freetype/fonts/fontconfig.c
index a8359066d7..0485bc210f 100644
--- a/modules/text_renderer/freetype/fonts/fontconfig.c
+++ b/modules/text_renderer/freetype/fonts/fontconfig.c
@@ -61,7 +61,7 @@ int FontConfig_Prepare( filter_t *p_filter )
     }
 
     msg_Dbg( p_filter, "Building font databases.");
-    ts = mdate();
+    ts = vlc_tick_now();
 
 #ifndef _WIN32
     config = FcInitLoadConfigAndFonts();
@@ -90,7 +90,7 @@ int FontConfig_Prepare( filter_t *p_filter )
 #endif
 
     vlc_mutex_unlock( &lock );
-    ts -= mdate();
+    ts -= vlc_tick_now();
     msg_Dbg( p_filter, "Took %ld microseconds", (long)ts );
 
     return (config != NULL) ? VLC_SUCCESS : VLC_EGENERIC;
diff --git a/modules/video_filter/blendbench.c b/modules/video_filter/blendbench.c
index 2db0ee91b8..a9ae8086bc 100644
--- a/modules/video_filter/blendbench.c
+++ b/modules/video_filter/blendbench.c
@@ -251,14 +251,14 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
         return NULL;
     }
 
-    vlc_tick_t time = mdate();
+    vlc_tick_t time = vlc_tick_now();
     for( int i_iter = 0; i_iter < p_sys->i_loops; ++i_iter )
     {
         p_blend->pf_video_blend( p_blend,
                                  p_sys->p_base_image, p_sys->p_blend_image,
                                  0, 0, p_sys->i_alpha );
     }
-    time = mdate() - time;
+    time = vlc_tick_now() - time;
 
     msg_Info( p_filter, "Blended %d images in %f sec", p_sys->i_loops,
               time / (float)CLOCK_FREQ );
diff --git a/modules/video_filter/grain.c b/modules/video_filter/grain.c
index c3331608d9..49e8024ebc 100644
--- a/modules/video_filter/grain.c
+++ b/modules/video_filter/grain.c
@@ -335,7 +335,7 @@ static int Generate(int16_t *bank, int h_min, int h_max, int v_min, int v_max)
         }
     }
 
-    //vlc_tick_t tmul_0 = mdate();
+    //vlc_tick_t tmul_0 = vlc_tick_now();
     for (int i = 0; i < N; i++) {
         for (int j = 0; j < N; j++) {
             double v = 0.0;
@@ -358,7 +358,7 @@ static int Generate(int16_t *bank, int h_min, int h_max, int v_min, int v_max)
             bank[i * N + j] = VLC_CLIP(vq, INT16_MIN, INT16_MAX);
         }
     }
-    //vlc_tick_t mul_duration = mdate() - tmul_0;
+    //vlc_tick_t mul_duration = vlc_tick_now() - tmul_0;
     //fprintf(stderr, "IDCT took %d ms\n", (int)(mul_duration / 1000));
 
     free(workspace);
diff --git a/modules/video_filter/magnify.c b/modules/video_filter/magnify.c
index 04b2e7f3ae..ce0e2a9446 100644
--- a/modules/video_filter/magnify.c
+++ b/modules/video_filter/magnify.c
@@ -126,7 +126,7 @@ static int Create( vlc_object_t *p_this )
     p_sys->i_y = 0;
     p_sys->i_zoom = 2*ZOOM_FACTOR;
     p_sys->b_visible = true;
-    p_sys->i_last_activity = mdate();
+    p_sys->i_last_activity = vlc_tick_now();
     p_sys->i_hide_timeout = 1000 * var_InheritInteger( p_filter, "mouse-hide-timeout" );
 
     /* */
@@ -245,7 +245,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
 
     /* print a small "VLC ZOOM" */
 
-    if( b_visible || p_sys->i_last_activity + p_sys->i_hide_timeout > mdate() )
+    if( b_visible || p_sys->i_last_activity + p_sys->i_hide_timeout > vlc_tick_now() )
         DrawZoomStatus( p_oyp->p_pixels, p_oyp->i_visible_pitch, p_oyp->i_pitch, p_oyp->i_lines,
                         1, v_h, b_visible );
 
@@ -410,7 +410,7 @@ static int Mouse( filter_t *p_filter, vlc_mouse_t *p_mouse, const vlc_mouse_t *p
     }
 
     if( vlc_mouse_HasMoved( p_old, p_new ) )
-        p_sys->i_last_activity = mdate();
+        p_sys->i_last_activity = vlc_tick_now();
 
     if( b_grab )
         return VLC_EGENERIC;
diff --git a/modules/video_filter/oldmovie.c b/modules/video_filter/oldmovie.c
index 43fabb115f..bf9fa1053b 100644
--- a/modules/video_filter/oldmovie.c
+++ b/modules/video_filter/oldmovie.c
@@ -218,7 +218,7 @@ static int Open( vlc_object_t *p_this ) {
 
     /* init data */
     p_filter->pf_video_filter = Filter;
-    p_sys->i_start_time = p_sys->i_cur_time = p_sys->i_last_time = mdate();
+    p_sys->i_start_time = p_sys->i_cur_time = p_sys->i_last_time = vlc_tick_now();
 
     return VLC_SUCCESS;
 }
@@ -254,7 +254,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic_in ) {
     * manage time
     */
     p_sys->i_last_time = p_sys->i_cur_time;
-    p_sys->i_cur_time  = mdate();
+    p_sys->i_cur_time  = vlc_tick_now();
 
    /*
     * allocate data
diff --git a/modules/video_filter/ripple.c b/modules/video_filter/ripple.c
index 40379a1eff..5b83686287 100644
--- a/modules/video_filter/ripple.c
+++ b/modules/video_filter/ripple.c
@@ -121,7 +121,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
 {
     picture_t *p_outpic;
     double f_angle;
-    vlc_tick_t new_date = mdate();
+    vlc_tick_t new_date = vlc_tick_now();
 
     if( !p_pic ) return NULL;
 
diff --git a/modules/video_filter/vhs.c b/modules/video_filter/vhs.c
index e1a094b379..67a310992c 100644
--- a/modules/video_filter/vhs.c
+++ b/modules/video_filter/vhs.c
@@ -145,7 +145,7 @@ static int Open( vlc_object_t *p_this )
 
     /* init data */
     p_filter->pf_video_filter = Filter;
-    p_sys->i_start_time = p_sys->i_cur_time = p_sys->i_last_time = mdate();
+    p_sys->i_start_time = p_sys->i_cur_time = p_sys->i_last_time = vlc_tick_now();
 
     return VLC_SUCCESS;
 }
@@ -181,7 +181,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic_in ) {
     * manage time
     */
     p_sys->i_last_time = p_sys->i_cur_time;
-    p_sys->i_cur_time = mdate();
+    p_sys->i_cur_time = vlc_tick_now();
 
    /*
     * allocate data
diff --git a/modules/video_filter/wave.c b/modules/video_filter/wave.c
index 8570b51328..3c8be15f71 100644
--- a/modules/video_filter/wave.c
+++ b/modules/video_filter/wave.c
@@ -110,7 +110,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
 {
     picture_t *p_outpic;
     double f_angle;
-    vlc_tick_t new_date = mdate();
+    vlc_tick_t new_date = vlc_tick_now();
 
     if( !p_pic ) return NULL;
 
diff --git a/modules/video_output/android/display.c b/modules/video_output/android/display.c
index 1e8a3111e4..ee24e31c5c 100644
--- a/modules/video_output/android/display.c
+++ b/modules/video_output/android/display.c
@@ -988,7 +988,7 @@ static void Prepare(vout_display_t *vd, picture_t *picture,
     if (sys->p_window->b_opaque
      && AndroidOpaquePicture_CanReleaseAtTime(picture->p_sys))
     {
-        vlc_tick_t now = mdate();
+        vlc_tick_t now = vlc_tick_now();
         if (date > now)
         {
             if (date - now <= 1*CLOCK_FREQ)
diff --git a/modules/video_output/caca.c b/modules/video_output/caca.c
index 82b315db69..59267fd897 100644
--- a/modules/video_output/caca.c
+++ b/modules/video_output/caca.c
@@ -302,7 +302,7 @@ static void Manage(vout_display_t *vd)
 {
     vout_display_sys_t *sys = vd->sys;
 
-    if (sys->cursor_deadline != INT64_MAX && sys->cursor_deadline < mdate()) {
+    if (sys->cursor_deadline != INT64_MAX && sys->cursor_deadline < vlc_tick_now()) {
         caca_set_mouse(sys->dp, 0);
         sys->cursor_deadline = INT64_MAX;
     }
@@ -332,7 +332,7 @@ static void Manage(vout_display_t *vd)
             break;
         case CACA_EVENT_MOUSE_MOTION:
             caca_set_mouse(sys->dp, 1);
-            sys->cursor_deadline = mdate() + sys->cursor_timeout;
+            sys->cursor_deadline = vlc_tick_now() + sys->cursor_timeout;
             vout_window_ReportMouseMoved(vd->cfg->window,
                                          caca_get_event_mouse_x(&ev),
                                          caca_get_event_mouse_y(&ev));
@@ -340,7 +340,7 @@ static void Manage(vout_display_t *vd)
         case CACA_EVENT_MOUSE_PRESS:
         case CACA_EVENT_MOUSE_RELEASE: {
             caca_set_mouse(sys->dp, 1);
-            sys->cursor_deadline = mdate() + sys->cursor_timeout;
+            sys->cursor_deadline = vlc_tick_now() + sys->cursor_timeout;
 
             const int caca = caca_get_event_mouse_button(&ev);
             for (int i = 0; mouses[i].caca != -1; i++) {
diff --git a/modules/video_output/decklink.cpp b/modules/video_output/decklink.cpp
index 88c560ddb4..015cb3fc3d 100644
--- a/modules/video_output/decklink.cpp
+++ b/modules/video_output/decklink.cpp
@@ -723,7 +723,7 @@ static int OpenDecklink(vout_display_t *vd, decklink_sys_t *sys)
 
     /* start */
     result = sys->p_output->StartScheduledPlayback(
-        (mdate() * sys->timescale) / CLOCK_FREQ, sys->timescale, 1.0);
+        (vlc_tick_now() * sys->timescale) / CLOCK_FREQ, sys->timescale, 1.0);
     CHECK("Could not start playback");
 
     p_config->Release();
@@ -893,7 +893,7 @@ static void PrepareVideo(vout_display_t *vd, picture_t *picture, subpicture_t *,
                          vlc_tick_t date)
 {
     decklink_sys_t *sys = (decklink_sys_t *) vd->sys;
-    vlc_tick_t now = mdate();
+    vlc_tick_t now = vlc_tick_now();
 
     if (!picture)
         return;
@@ -993,7 +993,7 @@ static void PrepareVideo(vout_display_t *vd, picture_t *picture, subpicture_t *,
         goto end;
     }
 
-    now = mdate() - sys->offset;
+    now = vlc_tick_now() - sys->offset;
 
     BMDTimeValue decklink_now;
     double speed;
diff --git a/modules/video_output/vdummy.c b/modules/video_output/vdummy.c
index c2f28b219e..887740122a 100644
--- a/modules/video_output/vdummy.c
+++ b/modules/video_output/vdummy.c
@@ -153,7 +153,7 @@ static void DisplayStat(vout_display_t *vd, picture_t *picture, subpicture_t *su
         vlc_tick_t date;
         memcpy(&date, p->p_pixels, sizeof(date));
         msg_Dbg(vd, "VOUT got %"PRIu64" ms offset",
-                (mdate() - date) / 1000 );
+                (vlc_tick_now() - date) / 1000 );
     }
     picture_Release(picture);
 }
diff --git a/modules/video_output/wayland/input.c b/modules/video_output/wayland/input.c
index c9a4f7bcc3..d81b1d3f05 100644
--- a/modules/video_output/wayland/input.c
+++ b/modules/video_output/wayland/input.c
@@ -71,7 +71,7 @@ static void pointer_show(struct seat_data *sd, struct wl_pointer *pointer)
     if (surface != NULL)
     {
         wl_pointer_set_cursor(pointer, sd->cursor_serial, surface, hsx, hsy);
-        sd->cursor_deadline = mdate() + sd->cursor_timeout;
+        sd->cursor_deadline = vlc_tick_now() + sd->cursor_timeout;
     }
 }
 
@@ -524,7 +524,7 @@ int seat_next_timeout(const struct wl_list *list)
     if (deadline == INT64_MAX)
         return -1;
 
-    vlc_tick_t now = mdate();
+    vlc_tick_t now = vlc_tick_now();
     if (now >= deadline)
         return 0;
 
@@ -534,7 +534,7 @@ int seat_next_timeout(const struct wl_list *list)
 void seat_timeout(struct wl_list *list)
 {
     struct seat_data *sd;
-    vlc_tick_t now = mdate();
+    vlc_tick_t now = vlc_tick_now();
 
     wl_list_for_each(sd, list, node)
         seat_refresh(sd, now);
diff --git a/modules/video_output/win32/events.c b/modules/video_output/win32/events.c
index 4611f177cc..ecb2451514 100644
--- a/modules/video_output/win32/events.c
+++ b/modules/video_output/win32/events.c
@@ -133,7 +133,7 @@ static void CALLBACK HideMouse(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwT
 static void UpdateCursorMoved( event_thread_t *p_event )
 {
     UpdateCursor( p_event, true );
-    p_event->last_moved = mdate();
+    p_event->last_moved = vlc_tick_now();
     if( p_event->hwnd )
         SetTimer( p_event->hwnd, (UINT_PTR)p_event, p_event->hide_timeout, HideMouse );
 }
diff --git a/modules/video_output/xcb/window.c b/modules/video_output/xcb/window.c
index 575179a37d..4123cadba4 100644
--- a/modules/video_output/xcb/window.c
+++ b/modules/video_output/xcb/window.c
@@ -328,7 +328,7 @@ static void *Thread (void *data)
 
         if (deadline != INT64_MAX)
         {
-            vlc_tick_t delay = deadline - mdate();
+            vlc_tick_t delay = deadline - vlc_tick_now();
             timeout = (delay > 0) ? delay / (CLOCK_FREQ / 1000) : 0;
         }
 
@@ -357,7 +357,7 @@ static void *Thread (void *data)
                                              XCB_CW_CURSOR,
                                              &(uint32_t){ XCB_CURSOR_NONE });
                 xcb_flush(conn);
-                deadline = mdate() + lifetime;
+                deadline = vlc_tick_now() + lifetime;
             }
         }
 
diff --git a/modules/visualization/cyclic_buffer.h b/modules/visualization/cyclic_buffer.h
index 6c7c279e74..4fab7fd2c0 100644
--- a/modules/visualization/cyclic_buffer.h
+++ b/modules/visualization/cyclic_buffer.h
@@ -50,7 +50,7 @@ public:
 
     block_holder* consume()
     {
-        vlc_tick_t cur_machine_time = mdate();
+        vlc_tick_t cur_machine_time = vlc_tick_now();
         size_t steps = 0;
         while (
                (cycl_buffer[consumer_pos].pts < cur_machine_time)
diff --git a/modules/visualization/goom.c b/modules/visualization/goom.c
index d66e64162b..56c4b62dad 100644
--- a/modules/visualization/goom.c
+++ b/modules/visualization/goom.c
@@ -322,7 +322,7 @@ static void *Thread( void *p_thread_data )
         if( p_thread->i_speed && (++i_count % (p_thread->i_speed+1)) ) continue;
 
         /* Frame dropping if necessary */
-        if( date_Get( &i_pts ) + GOOM_DELAY <= mdate() ) continue;
+        if( date_Get( &i_pts ) + GOOM_DELAY <= vlc_tick_now() ) continue;
 
         plane = goom_update( p_plugin_info, p_data, 0, 0.0,
                              NULL, NULL );
diff --git a/modules/visualization/projectm.cpp b/modules/visualization/projectm.cpp
index 60c27e9b1f..4f0d7c564a 100644
--- a/modules/visualization/projectm.cpp
+++ b/modules/visualization/projectm.cpp
@@ -347,7 +347,7 @@ static void *Thread( void *p_data )
     /* */
     for( ;; )
     {
-        const vlc_tick_t i_deadline = mdate() + CLOCK_FREQ / 50; /* 50 fps max */
+        const vlc_tick_t i_deadline = vlc_tick_now() + CLOCK_FREQ / 50; /* 50 fps max */
 
         /* Manage the events */
         unsigned width, height;
diff --git a/src/android/thread.c b/src/android/thread.c
index ae5025abab..c14a119af1 100644
--- a/src/android/thread.c
+++ b/src/android/thread.c
@@ -409,7 +409,7 @@ void *vlc_threadvar_get (vlc_threadvar_t key)
 }
 
 /* time */
-vlc_tick_t mdate (void)
+vlc_tick_t vlc_tick_now (void)
 {
     struct timespec ts;
 
diff --git a/src/audio_output/dec.c b/src/audio_output/dec.c
index 008a34c2b6..4f90c04d3c 100644
--- a/src/audio_output/dec.c
+++ b/src/audio_output/dec.c
@@ -240,16 +240,16 @@ static void aout_DecSynchronize(audio_output_t *aout, vlc_tick_t dec_pts)
      * The audio output plugin is responsible for estimating its actual
      * playback time, or rather the estimated time when the next sample will
      * be played. (The actual playback time is always the current time, that is
-     * to say mdate(). It is not an useful statistic.)
+     * to say vlc_tick_now(). It is not an useful statistic.)
      *
      * Most audio output plugins can estimate the delay until playback of
      * the next sample to be written to the buffer, or equally the time until
      * all samples in the buffer will have been played. Then:
-     *    pts = mdate() + delay
+     *    pts = vlc_tick_now() + delay
      */
     if (aout->time_get(aout, &drift) != 0)
         return; /* nothing can be done if timing is unknown */
-    drift += mdate () - dec_pts;
+    drift += vlc_tick_now () - dec_pts;
 
     /* Late audio output.
      * This can happen due to insufficient caching, scheduling jitter
@@ -275,7 +275,7 @@ static void aout_DecSynchronize(audio_output_t *aout, vlc_tick_t dec_pts)
         /* Now the output might be too early... Recheck. */
         if (aout->time_get(aout, &drift) != 0)
             return; /* nothing can be done if timing is unknown */
-        drift += mdate () - dec_pts;
+        drift += vlc_tick_now () - dec_pts;
     }
 
     /* Early audio output.
diff --git a/src/clock/input_clock.c b/src/clock/input_clock.c
index 0e75174ae2..247d78ddfa 100644
--- a/src/clock/input_clock.c
+++ b/src/clock/input_clock.c
@@ -413,7 +413,7 @@ int input_clock_ConvertTS( vlc_object_t *p_object, input_clock_t *cl,
 
     /* Check ts validity */
     if (i_ts_bound != INT64_MAX && *pi_ts0 != VLC_TS_INVALID) {
-        if (*pi_ts0 >= mdate() + i_ts_delay + i_ts_buffering + i_ts_bound) {
+        if (*pi_ts0 >= vlc_tick_now() + i_ts_delay + i_ts_buffering + i_ts_bound) {
             msg_Err(p_object,
                 "Timestamp conversion failed (delay %"PRId64", buffering "
                 "%"PRId64", bound %"PRId64")",
diff --git a/src/clock/input_clock.h b/src/clock/input_clock.h
index 56518dc8e8..b9b508c968 100644
--- a/src/clock/input_clock.h
+++ b/src/clock/input_clock.h
@@ -102,7 +102,7 @@ void    input_clock_ChangeSystemOrigin( input_clock_t *, bool b_absolute, vlc_ti
  * p_ts1 is a pointer to a timestamp to be converted (in place) and can be NULL.
  *
  * It will return VLC_EGENERIC if i_ts_bound is not INT64_MAX and if the value *p_ts0
- * after conversion is not before the deadline mdate() + i_pts_delay + i_ts_bound.
+ * after conversion is not before the deadline vlc_tick_now() + i_pts_delay + i_ts_bound.
  * It will also return VLC_EGENERIC if the conversion cannot be done successfully. In
  * this case, *p_ts0 and *p_ts1 will hold an invalid timestamp.
  * Otherwise it will return VLC_SUCCESS.
diff --git a/src/darwin/thread.c b/src/darwin/thread.c
index 814517013b..7b0dfdb290 100644
--- a/src/darwin/thread.c
+++ b/src/darwin/thread.c
@@ -251,10 +251,10 @@ int vlc_cond_timedwait (vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex,
     pthread_testcancel();
 
     /*
-     * mdate() is the monotonic clock, pthread_cond_timedwait expects
+     * vlc_tick_now() is the monotonic clock, pthread_cond_timedwait expects
      * origin of gettimeofday(). Use timedwait_relative_np() instead.
      */
-    vlc_tick_t base = mdate();
+    vlc_tick_t base = vlc_tick_now();
     deadline -= base;
     if (deadline < 0)
         deadline = 0;
@@ -519,7 +519,7 @@ void vlc_control_cancel (int cmd, ...)
     vlc_assert_unreachable ();
 }
 
-vlc_tick_t mdate (void)
+vlc_tick_t vlc_tick_now (void)
 {
     vlc_clock_setup();
     uint64_t date = mach_absolute_time();
@@ -539,7 +539,7 @@ vlc_tick_t mdate (void)
 #undef vlc_tick_wait
 void vlc_tick_wait (vlc_tick_t deadline)
 {
-    deadline -= mdate ();
+    deadline -= vlc_tick_now ();
     if (deadline > 0)
         vlc_tick_sleep (deadline);
 }
diff --git a/src/input/decoder.c b/src/input/decoder.c
index ef8a1a469f..411f913715 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -709,7 +709,7 @@ static int DecoderTimedWait( decoder_t *p_dec, vlc_tick_t deadline )
 {
     struct decoder_owner *p_owner = dec_get_owner( p_dec );
 
-    if (deadline - mdate() <= 0)
+    if (deadline - vlc_tick_now() <= 0)
         return VLC_SUCCESS;
 
     vlc_fifo_Lock( p_owner->p_fifo );
diff --git a/src/input/demux_chained.c b/src/input/demux_chained.c
index dbae43b775..7dba40a8f9 100644
--- a/src/input/demux_chained.c
+++ b/src/input/demux_chained.c
@@ -69,7 +69,7 @@ static void *vlc_demux_chained_Thread(void *data)
     vlc_tick_t next_update = 0;
 
     do
-        if (demux_TestAndClearFlags(demux, UINT_MAX) || mdate() >= next_update)
+        if (demux_TestAndClearFlags(demux, UINT_MAX) || vlc_tick_now() >= next_update)
         {
             double newpos;
             int64_t newlen, newtime;
@@ -87,7 +87,7 @@ static void *vlc_demux_chained_Thread(void *data)
             dc->stats.time = newtime;
             vlc_mutex_unlock(&dc->lock);
 
-            next_update = mdate() + (CLOCK_FREQ / 4);
+            next_update = vlc_tick_now() + (CLOCK_FREQ / 4);
         }
     while (demux_Demux(demux) > 0);
 
diff --git a/src/input/es_out.c b/src/input/es_out.c
index 28a47d79f8..d36fd2c4ff 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -678,7 +678,7 @@ static void EsOutDecodersStopBuffering( es_out_t *out, bool b_forced )
         return;
     }
 
-    const vlc_tick_t i_decoder_buffering_start = mdate();
+    const vlc_tick_t i_decoder_buffering_start = vlc_tick_now();
     vlc_list_foreach(p_es, &p_sys->es, node)
     {
         if( !p_es->p_dec || p_es->fmt.i_cat == SPU_ES )
@@ -689,14 +689,14 @@ static void EsOutDecodersStopBuffering( es_out_t *out, bool b_forced )
     }
 
     msg_Dbg( p_sys->p_input, "Decoder wait done in %d ms",
-              (int)(mdate() - i_decoder_buffering_start)/1000 );
+              (int)(vlc_tick_now() - i_decoder_buffering_start)/1000 );
 
     /* Here is a good place to destroy unused vout with every demuxer */
     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_current_date = p_sys->b_paused ? p_sys->i_pause_date : mdate();
+    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,
                                     i_current_date + i_wakeup_delay - i_buffering_duration );
@@ -885,7 +885,7 @@ static vlc_tick_t EsOutGetBuffering( es_out_t *out )
         }
         else
         {
-            i_system_duration = mdate() - i_system_start;
+            i_system_duration = vlc_tick_now() - i_system_start;
         }
 
         const vlc_tick_t i_consumed = i_system_duration * INPUT_RATE_DEFAULT / p_sys->i_rate - i_stream_duration;
@@ -2477,13 +2477,13 @@ static int EsOutControlLocked( es_out_t *out, int i_query, va_list args )
             return VLC_EGENERIC;
         }
 
-        /* TODO do not use mdate() but proper stream acquisition date */
+        /* TODO do not use vlc_tick_now() but proper stream acquisition date */
         bool b_late;
         input_clock_Update( p_pgrm->p_input_clock, VLC_OBJECT(p_sys->p_input),
                             &b_late,
                             input_priv(p_sys->p_input)->b_can_pace_control || p_sys->b_buffering,
                             EsOutIsExtraBufferingAllowed( out ),
-                            i_pcr, mdate() );
+                            i_pcr, vlc_tick_now() );
 
         if( !p_sys->p_pgrm )
             return VLC_SUCCESS;
diff --git a/src/input/es_out_timeshift.c b/src/input/es_out_timeshift.c
index 65972440be..ac5be963e8 100644
--- a/src/input/es_out_timeshift.c
+++ b/src/input/es_out_timeshift.c
@@ -773,7 +773,7 @@ static int TsStart( es_out_t *p_out )
     vlc_mutex_init( &p_ts->lock );
     vlc_cond_init( &p_ts->wait );
     p_ts->b_paused = p_sys->b_input_paused && !p_sys->b_input_paused_source;
-    p_ts->i_pause_date = p_ts->b_paused ? mdate() : -1;
+    p_ts->i_pause_date = p_ts->b_paused ? vlc_tick_now() : -1;
     p_ts->i_rate_source = p_sys->i_input_rate_source;
     p_ts->i_rate        = p_sys->i_input_rate;
     p_ts->i_rate_date = -1;
@@ -1284,7 +1284,7 @@ static void CmdClean( ts_cmd_t *p_cmd )
 static int CmdInitAdd( ts_cmd_t *p_cmd, es_out_id_t *p_es, const es_format_t *p_fmt, bool b_copy )
 {
     p_cmd->i_type = C_ADD;
-    p_cmd->i_date = mdate();
+    p_cmd->i_date = vlc_tick_now();
     p_cmd->u.add.p_es = p_es;
     if( b_copy )
     {
@@ -1312,7 +1312,7 @@ static void CmdCleanAdd( ts_cmd_t *p_cmd )
 static void CmdInitSend( ts_cmd_t *p_cmd, es_out_id_t *p_es, block_t *p_block )
 {
     p_cmd->i_type = C_SEND;
-    p_cmd->i_date = mdate();
+    p_cmd->i_date = vlc_tick_now();
     p_cmd->u.send.p_es = p_es;
     p_cmd->u.send.p_block = p_block;
 }
@@ -1339,7 +1339,7 @@ static void CmdCleanSend( ts_cmd_t *p_cmd )
 static int CmdInitDel( ts_cmd_t *p_cmd, es_out_id_t *p_es )
 {
     p_cmd->i_type = C_DEL;
-    p_cmd->i_date = mdate();
+    p_cmd->i_date = vlc_tick_now();
     p_cmd->u.del.p_es = p_es;
     return VLC_SUCCESS;
 }
@@ -1353,7 +1353,7 @@ static void CmdExecuteDel( es_out_t *p_out, ts_cmd_t *p_cmd )
 static int CmdInitControl( ts_cmd_t *p_cmd, int i_query, va_list args, bool b_copy )
 {
     p_cmd->i_type = C_CONTROL;
-    p_cmd->i_date = mdate();
+    p_cmd->i_date = vlc_tick_now();
     p_cmd->u.control.i_query = i_query;
 
     switch( i_query )
diff --git a/src/input/input.c b/src/input/input.c
index 04ee726d1f..89b1764b60 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -690,7 +690,7 @@ static void MainLoop( input_thread_t *p_input, bool b_interactive )
     vlc_tick_t i_last_seek_mdate = 0;
 
     if( b_interactive && var_InheritBool( p_input, "start-paused" ) )
-        ControlPause( p_input, mdate() );
+        ControlPause( p_input, vlc_tick_now() );
 
     bool b_pause_after_eof = b_interactive &&
                            var_InheritBool( p_input, "play-and-pause" );
@@ -728,7 +728,7 @@ static void MainLoop( input_thread_t *p_input, bool b_interactive )
             else if( !es_out_GetEmpty( input_priv(p_input)->p_es_out ) )
             {
                 msg_Dbg( p_input, "waiting decoder fifos to empty" );
-                i_wakeup = mdate() + INPUT_IDLE_SLEEP;
+                i_wakeup = vlc_tick_now() + INPUT_IDLE_SLEEP;
             }
             /* Pause after eof only if the input is pausable.
              * This way we won't trigger timeshifting for nothing */
@@ -752,7 +752,7 @@ static void MainLoop( input_thread_t *p_input, bool b_interactive )
             }
 
             /* Update interface and statistics */
-            vlc_tick_t now = mdate();
+            vlc_tick_t now = vlc_tick_now();
             if( now >= i_intf_update )
             {
                 MainLoopStatistics( p_input );
@@ -771,7 +771,7 @@ static void MainLoop( input_thread_t *p_input, bool b_interactive )
                             && !input_priv(p_input)->master->b_eof;
             if( b_postpone )
             {
-                vlc_tick_t now = mdate();
+                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
@@ -797,7 +797,7 @@ static void MainLoop( input_thread_t *p_input, bool b_interactive )
             if( Control( p_input, i_type, val ) )
             {
                 if( ControlIsSeekRequest( i_type ) )
-                    i_last_seek_mdate = mdate();
+                    i_last_seek_mdate = vlc_tick_now();
                 i_intf_update = 0;
             }
 
@@ -1832,7 +1832,7 @@ static void ControlInsertDemuxFilter( input_thread_t* p_input, const char* psz_d
 static bool Control( input_thread_t *p_input,
                      int i_type, vlc_value_t val )
 {
-    const vlc_tick_t i_control_date = mdate();
+    const vlc_tick_t i_control_date = vlc_tick_now();
     /* FIXME b_force_update is abused, it should be carefully checked */
     bool b_force_update = false;
 
diff --git a/src/input/stats.c b/src/input/stats.c
index 4e1070f85f..8cf5ff5f36 100644
--- a/src/input/stats.c
+++ b/src/input/stats.c
@@ -124,7 +124,7 @@ void input_rate_Add(input_rate_t *counter, uintmax_t val)
     counter->value += val;
 
     /* Ignore samples within a second of another */
-    vlc_tick_t now = mdate();
+    vlc_tick_t now = vlc_tick_now();
     if (counter->samples[0].date != VLC_TS_INVALID
      && (now - counter->samples[0].date) < 1*CLOCK_FREQ)
         return;
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 05008ba723..0378c96e1b 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -236,7 +236,7 @@ vlc_uri_encode
 vlc_uri_compose
 vlc_uri_resolve
 vlc_uri_fixup
-mdate
+vlc_tick_now
 module_config_free
 module_config_get
 module_exists
diff --git a/src/misc/background_worker.c b/src/misc/background_worker.c
index b9071bae6d..42d5de4a59 100644
--- a/src/misc/background_worker.c
+++ b/src/misc/background_worker.c
@@ -82,14 +82,14 @@ static void* Thread( void* data )
             if( item )
             {
                 if( item->timeout > 0 )
-                    worker->head.deadline = mdate() + item->timeout * 1000;
+                    worker->head.deadline = vlc_tick_now() + item->timeout * 1000;
                 else
                     worker->head.deadline = INT64_MAX;
             }
             else if( worker->head.deadline != VLC_TS_INVALID )
             {
                 /* Wait 1 seconds for new inputs before terminating */
-                vlc_tick_t deadline = mdate() + 1*CLOCK_FREQ;
+                vlc_tick_t deadline = vlc_tick_now() + 1*CLOCK_FREQ;
                 int ret = vlc_cond_timedwait( &worker->tail.wait,
                                               &worker->lock, deadline );
                 if( ret != 0 )
@@ -123,7 +123,7 @@ static void* Thread( void* data )
         {
             vlc_mutex_lock( &worker->lock );
 
-            bool const b_timeout = worker->head.deadline <= mdate();
+            bool const b_timeout = worker->head.deadline <= vlc_tick_now();
             worker->head.probe_request = false;
 
             vlc_mutex_unlock( &worker->lock );
@@ -139,7 +139,7 @@ static void* Thread( void* data )
 
             vlc_mutex_lock( &worker->lock );
             if( worker->head.probe_request == false &&
-                worker->head.deadline > mdate() )
+                worker->head.deadline > vlc_tick_now() )
             {
                 vlc_cond_timedwait( &worker->head.worker_wait, &worker->lock,
                                      worker->head.deadline );
diff --git a/src/misc/image.c b/src/misc/image.c
index 3b0fec711a..ca89dcf761 100644
--- a/src/misc/image.c
+++ b/src/misc/image.c
@@ -170,7 +170,7 @@ static picture_t *ImageRead( image_handler_t *p_image, block_t *p_block,
         }
     }
 
-    p_block->i_pts = p_block->i_dts = mdate();
+    p_block->i_pts = p_block->i_dts = vlc_tick_now();
     int ret = p_image->p_dec->pf_decode( p_image->p_dec, p_block );
     if( ret == VLCDEC_SUCCESS )
     {
diff --git a/src/misc/threads.c b/src/misc/threads.c
index f76da8d3a2..5f2238147c 100644
--- a/src/misc/threads.c
+++ b/src/misc/threads.c
@@ -87,7 +87,7 @@ void (vlc_tick_wait)(vlc_tick_t deadline)
 
     vlc_cancel_addr_prepare(&value);
 
-    while ((delay = (deadline - mdate())) > 0)
+    while ((delay = (deadline - vlc_tick_now())) > 0)
     {
         vlc_addr_timedwait(&value, 0, delay);
         vlc_testcancel();
@@ -98,7 +98,7 @@ void (vlc_tick_wait)(vlc_tick_t deadline)
 
 void (vlc_tick_sleep)(vlc_tick_t delay)
 {
-    vlc_tick_wait(mdate() + delay);
+    vlc_tick_wait(vlc_tick_now() + delay);
 }
 #endif
 
@@ -209,7 +209,7 @@ static int vlc_cond_wait_delay(vlc_cond_t *cond, vlc_mutex_t *mutex,
 
 int vlc_cond_timedwait(vlc_cond_t *cond, vlc_mutex_t *mutex, vlc_tick_t deadline)
 {
-    return vlc_cond_wait_delay(cond, mutex, deadline - mdate());
+    return vlc_cond_wait_delay(cond, mutex, deadline - vlc_tick_now());
 }
 
 int vlc_cond_timedwait_daytime(vlc_cond_t *cond, vlc_mutex_t *mutex,
diff --git a/src/network/httpd.c b/src/network/httpd.c
index 782d35d48c..49c1471c96 100644
--- a/src/network/httpd.c
+++ b/src/network/httpd.c
@@ -1692,7 +1692,7 @@ static void httpdLoop(httpd_host_t *host)
         vlc_cleanup_pop();
     }
 
-    vlc_tick_t now = mdate();
+    vlc_tick_t now = vlc_tick_now();
     bool b_low_delay = false;
     httpd_client_t *cl;
 
@@ -1951,7 +1951,7 @@ static void httpdLoop(httpd_host_t *host)
     vlc_mutex_lock(&host->lock);
 
     /* Handle client sockets */
-    now = mdate();
+    now = vlc_tick_now();
     nfd = host->nfd;
 
     vlc_list_foreach(cl, &host->clients, node) {
diff --git a/src/network/tcp.c b/src/network/tcp.c
index 32c6560c69..1374673afe 100644
--- a/src/network/tcp.c
+++ b/src/network/tcp.c
@@ -165,11 +165,11 @@ int net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port,
 
             ufd.fd = fd;
             ufd.events = POLLOUT;
-            deadline = mdate() + timeout;
+            deadline = vlc_tick_now() + timeout;
 
             do
             {
-                vlc_tick_t now = mdate();
+                vlc_tick_t now = vlc_tick_now();
 
                 if (vlc_killed())
                     goto next_ai;
diff --git a/src/network/tls.c b/src/network/tls.c
index 12bd53c7e7..3650095394 100644
--- a/src/network/tls.c
+++ b/src/network/tls.c
@@ -167,7 +167,7 @@ vlc_tls_t *vlc_tls_ClientSessionCreate(vlc_tls_creds_t *crd, vlc_tls_t *sock,
         return NULL;
 
     int canc = vlc_savecancel();
-    vlc_tick_t deadline = mdate ();
+    vlc_tick_t deadline = vlc_tick_now ();
     deadline += var_InheritInteger (crd, "ipv4-timeout") * 1000;
 
     struct pollfd ufd[1];
@@ -186,7 +186,7 @@ error:
             break;
         }
 
-        vlc_tick_t now = mdate ();
+        vlc_tick_t now = vlc_tick_now ();
         if (now > deadline)
            now = deadline;
 
diff --git a/src/os2/thread.c b/src/os2/thread.c
index 8c07c5fe5b..3a0716ef3f 100644
--- a/src/os2/thread.c
+++ b/src/os2/thread.c
@@ -399,7 +399,7 @@ int vlc_cond_timedwait (vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex,
 {
     ULONG ulTimeout;
 
-    vlc_tick_t total = mdate();
+    vlc_tick_t total = vlc_tick_now();
     total = (deadline - total) / 1000;
     if( total < 0 )
         total = 0;
@@ -898,7 +898,7 @@ int vlc_poll_os2( struct pollfd *fds, unsigned nfds, int timeout )
 #define Q2LL( q )   ( *( long long * )&( q ))
 
 /*** Clock ***/
-vlc_tick_t mdate (void)
+vlc_tick_t vlc_tick_now (void)
 {
     /* We don't need the real date, just the value of a high precision timer */
     QWORD counter;
@@ -919,7 +919,7 @@ void vlc_tick_wait (vlc_tick_t deadline)
     vlc_tick_t delay;
 
     vlc_testcancel();
-    while ((delay = (deadline - mdate())) > 0)
+    while ((delay = (deadline - vlc_tick_now())) > 0)
     {
         delay /= 1000;
         if (unlikely(delay > 0x7fffffff))
@@ -932,7 +932,7 @@ void vlc_tick_wait (vlc_tick_t deadline)
 #undef vlc_tick_sleep
 void vlc_tick_sleep (vlc_tick_t delay)
 {
-    vlc_tick_wait (mdate () + delay);
+    vlc_tick_wait (vlc_tick_now () + delay);
 }
 
 /*** Timers ***/
@@ -1015,7 +1015,7 @@ void vlc_timer_schedule (vlc_timer_t timer, bool absolute,
         return; /* Disarm */
 
     if (absolute)
-        value -= mdate ();
+        value -= vlc_tick_now ();
     value = (value + 999) / 1000;
     interval = (interval + 999) / 1000;
 
diff --git a/src/posix/thread.c b/src/posix/thread.c
index d0c8318098..ca3b5ec485 100644
--- a/src/posix/thread.c
+++ b/src/posix/thread.c
@@ -578,7 +578,7 @@ void vlc_control_cancel (int cmd, ...)
     vlc_assert_unreachable ();
 }
 
-vlc_tick_t mdate (void)
+vlc_tick_t vlc_tick_now (void)
 {
     struct timespec ts;
 
diff --git a/src/posix/timer.c b/src/posix/timer.c
index 9926a06c94..e806e85fec 100644
--- a/src/posix/timer.c
+++ b/src/posix/timer.c
@@ -67,7 +67,7 @@ noreturn static void *vlc_timer_thread (void *data)
 
         if (timer->interval != 0)
         {
-            vlc_tick_t now = mdate();
+            vlc_tick_t now = vlc_tick_now();
 
             if (now > timer->value)
             {   /* Update overrun counter */
@@ -150,7 +150,7 @@ void vlc_timer_schedule (vlc_timer_t timer, bool absolute,
         interval = 0;
     else
     if (!absolute)
-        value += mdate();
+        value += vlc_tick_now();
 
     vlc_mutex_lock (&timer->lock);
     timer->value = value;
diff --git a/src/stream_output/sap.c b/src/stream_output/sap.c
index f0d1a24742..f7da040896 100644
--- a/src/stream_output/sap.c
+++ b/src/stream_output/sap.c
@@ -149,7 +149,7 @@ noreturn static void *RunThread (void *self)
 
         assert (addr->session_count > 0);
 
-        deadline = mdate ();
+        deadline = vlc_tick_now ();
         for (p_session = addr->first; p_session; p_session = p_session->next)
         {
             send (addr->fd, p_session->data, p_session->length, 0);
@@ -317,7 +317,7 @@ sout_AnnounceRegisterSDP (vlc_object_t *obj, const char *sdp,
 #endif
     vlc_memstream_putc(&stream, flags);
     vlc_memstream_putc(&stream, 0x00); /* No authentication length */
-    vlc_memstream_write(&stream, &(uint16_t){ mdate() }, 2); /* ID hash */
+    vlc_memstream_write(&stream, &(uint16_t){ vlc_tick_now() }, 2); /* ID hash */
 
     switch (sap_addr->orig.ss_family)
     {
diff --git a/src/stream_output/stream_output.c b/src/stream_output/stream_output.c
index f12559ee32..48a0f3f7c0 100644
--- a/src/stream_output/stream_output.c
+++ b/src/stream_output/stream_output.c
@@ -537,7 +537,7 @@ int sout_MuxSendBuffer( sout_mux_t *p_mux, sout_input_t *p_input,
 
     if( p_mux->p_sout->i_out_pace_nocontrol )
     {
-        vlc_tick_t current_date = mdate();
+        vlc_tick_t current_date = vlc_tick_now();
         if ( current_date > i_dts )
             msg_Warn( p_mux, "late buffer for mux input (%"PRId64")",
                       current_date - i_dts );
diff --git a/src/test/timer.c b/src/test/timer.c
index 1f5007cdf4..d7aef01772 100644
--- a/src/test/timer.c
+++ b/src/test/timer.c
@@ -74,14 +74,14 @@ int main (void)
     assert (val == 0);
 
     /* Relative timer */
-    ts = mdate ();
+    ts = vlc_tick_now ();
     vlc_timer_schedule (data.timer, false, 1, CLOCK_FREQ / 100);
 
     vlc_mutex_lock (&data.lock);
     while (data.count <= 10)
         vlc_cond_wait(&data.wait, &data.lock);
 
-    ts = mdate () - ts;
+    ts = vlc_tick_now () - ts;
     printf ("%u iterations in %"PRId64" us\n", data.count, ts);
     data.count = 0;
     vlc_mutex_unlock (&data.lock);
@@ -90,7 +90,7 @@ int main (void)
     vlc_timer_schedule (data.timer, false, 0, 0);
 
     /* Absolute timer */
-    ts = mdate ();
+    ts = vlc_tick_now ();
 
     vlc_timer_schedule (data.timer, true, ts + CLOCK_FREQ / 10,
                         CLOCK_FREQ / 100);
@@ -99,7 +99,7 @@ int main (void)
     while (data.count <= 10)
         vlc_cond_wait(&data.wait, &data.lock);
 
-    ts = mdate () - ts;
+    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));
diff --git a/src/video_output/chrono.h b/src/video_output/chrono.h
index 073f417fb4..030615c028 100644
--- a/src/video_output/chrono.h
+++ b/src/video_output/chrono.h
@@ -54,7 +54,7 @@ static inline void vout_chrono_Clean(vout_chrono_t *chrono)
 }
 static inline void vout_chrono_Start(vout_chrono_t *chrono)
 {
-    chrono->start = mdate();
+    chrono->start = vlc_tick_now();
 }
 static inline vlc_tick_t vout_chrono_GetHigh(vout_chrono_t *chrono)
 {
@@ -70,7 +70,7 @@ static inline void vout_chrono_Stop(vout_chrono_t *chrono)
     assert(chrono->start != VLC_TS_INVALID);
 
     /* */
-    const vlc_tick_t duration = mdate() - chrono->start;
+    const vlc_tick_t duration = vlc_tick_now() - chrono->start;
     const vlc_tick_t var = llabs( duration - chrono->avg );
 
     /* Update average only if the current point is 'valid' */
diff --git a/src/video_output/display.c b/src/video_output/display.c
index e4b4b9419d..5c35415c70 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -511,13 +511,13 @@ static void VoutDisplayEventMouse(vout_display_t *vd, int event, va_list args)
     /* Emulate double-click if needed */
     if (!vd->info.has_double_click &&
         vlc_mouse_HasPressed(&osys->mouse.state, &m, MOUSE_BUTTON_LEFT)) {
-        const vlc_tick_t i_date = mdate();
+        const vlc_tick_t i_date = vlc_tick_now();
 
         if (i_date - osys->mouse.last_pressed < 3*CLOCK_FREQ/10 ) {
             m.b_double_click = true;
             osys->mouse.last_pressed = 0;
         } else {
-            osys->mouse.last_pressed = mdate();
+            osys->mouse.last_pressed = vlc_tick_now();
         }
     }
 
diff --git a/src/video_output/interlacing.c b/src/video_output/interlacing.c
index 3451bb5095..1da44c5b3a 100644
--- a/src/video_output/interlacing.c
+++ b/src/video_output/interlacing.c
@@ -164,7 +164,7 @@ void vout_InitInterlacingSupport(vout_thread_t *vout, bool is_interlaced)
 
     vout->p->interlacing.is_interlaced = is_interlaced;
     if (is_interlaced)
-        vout->p->interlacing.date = mdate();
+        vout->p->interlacing.date = vlc_tick_now();
 }
 
 void vout_ReinitInterlacingSupport(vout_thread_t *vout)
@@ -180,7 +180,7 @@ void vout_SetInterlacingState(vout_thread_t *vout, bool is_interlaced)
                                  - (!!vout->p->interlacing.is_interlaced);
     if (interlacing_change == 1 ||
         (interlacing_change == -1 &&
-        vout->p->interlacing.date + CLOCK_FREQ*30 < mdate()))
+        vout->p->interlacing.date + CLOCK_FREQ*30 < vlc_tick_now()))
     {
         msg_Dbg(vout, "Detected %s video",
                  is_interlaced ? "interlaced" : "progressive");
@@ -188,5 +188,5 @@ void vout_SetInterlacingState(vout_thread_t *vout, bool is_interlaced)
         vout->p->interlacing.is_interlaced = is_interlaced;
     }
     if (is_interlaced)
-        vout->p->interlacing.date = mdate();
+        vout->p->interlacing.date = vlc_tick_now();
 }
diff --git a/src/video_output/snapshot.c b/src/video_output/snapshot.c
index 7cdaa5dd04..35bedad380 100644
--- a/src/video_output/snapshot.c
+++ b/src/video_output/snapshot.c
@@ -77,7 +77,7 @@ void vout_snapshot_End(vout_snapshot_t *snap)
 /* */
 picture_t *vout_snapshot_Get(vout_snapshot_t *snap, vlc_tick_t timeout)
 {
-    const vlc_tick_t deadline = mdate() + timeout;
+    const vlc_tick_t deadline = vlc_tick_now() + timeout;
 
     vlc_mutex_lock(&snap->lock);
 
diff --git a/src/video_output/video_epg.c b/src/video_output/video_epg.c
index 89da457526..409fc9d481 100644
--- a/src/video_output/video_epg.c
+++ b/src/video_output/video_epg.c
@@ -636,7 +636,7 @@ int vout_OSDEpg(vout_thread_t *vout, input_item_t *input )
         .p_sys       = sys
     };
 
-    const vlc_tick_t now = mdate();
+    const vlc_tick_t now = vlc_tick_now();
     subpicture_t *subpic = subpicture_New(&updater);
     if (!subpic) {
         vlc_epg_Delete(sys->epg);
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 09e5d55337..9b30a987db 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -851,7 +851,7 @@ static int ThreadDisplayPreparePicture(vout_thread_t *vout, bool reuse, bool fra
                         late_threshold = ((CLOCK_FREQ/2) * decoded->format.i_frame_rate_base) / decoded->format.i_frame_rate;
                     else
                         late_threshold = VOUT_DISPLAY_LATE_THRESHOLD;
-                    const vlc_tick_t predicted = mdate() + 0; /* TODO improve */
+                    const vlc_tick_t predicted = vlc_tick_now() + 0; /* TODO improve */
                     const vlc_tick_t late = predicted - decoded->date;
                     if (late > late_threshold) {
                         msg_Warn(vout, "picture is too late to be displayed (missing %"PRId64" ms)", late/1000);
@@ -976,8 +976,8 @@ static int ThreadDisplayRenderPicture(vout_thread_t *vout, bool is_forced)
     if (vout->p->pause.is_on)
         render_subtitle_date = vout->p->pause.date;
     else
-        render_subtitle_date = filtered->date > 1 ? filtered->date : mdate();
-    vlc_tick_t render_osd_date = mdate(); /* FIXME wrong */
+        render_subtitle_date = filtered->date > 1 ? filtered->date : vlc_tick_now();
+    vlc_tick_t render_osd_date = vlc_tick_now(); /* FIXME wrong */
 
     /*
      * Get the subpicture to be displayed
@@ -1152,7 +1152,7 @@ static int ThreadDisplayRenderPicture(vout_thread_t *vout, bool is_forced)
 
     /* Wait the real date (for rendering jitter) */
 #if 0
-    vlc_tick_t delay = todisplay->date - mdate();
+    vlc_tick_t delay = todisplay->date - vlc_tick_now();
     if (delay < 1000)
         msg_Warn(vout, "picture is late (%lld ms)", delay / 1000);
 #endif
@@ -1160,7 +1160,7 @@ static int ThreadDisplayRenderPicture(vout_thread_t *vout, bool is_forced)
         vlc_tick_wait(todisplay->date);
 
     /* Display the direct buffer returned by vout_RenderPicture */
-    vout->p->displayed.date = mdate();
+    vout->p->displayed.date = vlc_tick_now();
     vout_display_Display(vd, todisplay, subpic);
 
     vout_statistic_AddDisplayed(&vout->p->statistic, 1);
@@ -1182,7 +1182,7 @@ static int ThreadDisplayPicture(vout_thread_t *vout, vlc_tick_t *deadline)
         while (!vout->p->displayed.next && !ThreadDisplayPreparePicture(vout, false, frame_by_frame))
             ;
 
-    const vlc_tick_t date = mdate();
+    const vlc_tick_t date = vlc_tick_now();
     const vlc_tick_t render_delay = vout_chrono_GetHigh(&vout->p->render) + VOUT_MWAIT_TOLERANCE;
 
     bool drop_next_frame = frame_by_frame;
@@ -1780,7 +1780,7 @@ static void *Thread(void *object)
 
         if (wait)
         {
-            const vlc_tick_t max_deadline = mdate() + CLOCK_FREQ/10;
+            const vlc_tick_t max_deadline = vlc_tick_now() + CLOCK_FREQ/10;
             deadline = deadline == VLC_TS_INVALID ? max_deadline : __MIN(deadline, max_deadline);
         } else {
             deadline = VLC_TS_INVALID;
diff --git a/src/video_output/video_text.c b/src/video_output/video_text.c
index dc9a4e1c39..ab5f0fa1ed 100644
--- a/src/video_output/video_text.c
+++ b/src/video_output/video_text.c
@@ -135,7 +135,7 @@ void vout_OSDText(vout_thread_t *vout, int channel,
     }
 
     subpic->i_channel  = channel;
-    subpic->i_start    = mdate();
+    subpic->i_start    = vlc_tick_now();
     subpic->i_stop     = subpic->i_start + duration;
     subpic->b_ephemer  = true;
     subpic->b_absolute = false;
diff --git a/src/video_output/video_widgets.c b/src/video_output/video_widgets.c
index a24d71b8a5..2c7e4ac92d 100644
--- a/src/video_output/video_widgets.c
+++ b/src/video_output/video_widgets.c
@@ -319,7 +319,7 @@ static void OSDWidget(vout_thread_t *vout, int channel, int type, int position)
     }
 
     subpic->i_channel  = channel;
-    subpic->i_start    = mdate();
+    subpic->i_start    = vlc_tick_now();
     subpic->i_stop     = subpic->i_start + 12*CLOCK_FREQ/10;
     subpic->b_ephemer  = true;
     subpic->b_absolute = true;
diff --git a/src/video_output/vout_intf.c b/src/video_output/vout_intf.c
index b4ea07aa9e..3ab4cf5e0b 100644
--- a/src/video_output/vout_intf.c
+++ b/src/video_output/vout_intf.c
@@ -334,7 +334,7 @@ static int VoutSnapshotPip( vout_thread_t *p_vout, picture_t *p_pic )
     /* FIXME SPU_DEFAULT_CHANNEL is not good (used by the text) but
      * hardcoded 0 doesn't seem right */
     p_subpic->i_channel = 0;
-    p_subpic->i_start = mdate();
+    p_subpic->i_start = vlc_tick_now();
     p_subpic->i_stop  = p_subpic->i_start + CLOCK_FREQ*4;
     p_subpic->b_ephemer = true;
     p_subpic->b_fade = true;
diff --git a/src/video_output/window.c b/src/video_output/window.c
index ad8d61c0ba..3ce4ba51fb 100644
--- a/src/video_output/window.c
+++ b/src/video_output/window.c
@@ -201,7 +201,7 @@ static void vout_display_window_MouseEvent(vout_window_t *window,
              && ev->button_mask == MOUSE_BUTTON_LEFT
              && !vlc_mouse_IsLeftPressed(m))
             {
-                const vlc_tick_t now = mdate();
+                const vlc_tick_t now = vlc_tick_now();
 
                 if (state->last_left_press != INT64_MIN
                  && now - state->last_left_press < DOUBLE_CLICK_TIME)
diff --git a/src/win32/thread.c b/src/win32/thread.c
index f4ee5b65bf..9b74f220eb 100644
--- a/src/win32/thread.c
+++ b/src/win32/thread.c
@@ -771,7 +771,7 @@ static vlc_tick_t mdate_default(void)
 
 static vlc_tick_t (*mdate_selected) (void) = mdate_default;
 
-vlc_tick_t mdate (void)
+vlc_tick_t vlc_tick_now (void)
 {
     return mdate_selected ();
 }
@@ -782,7 +782,7 @@ void (vlc_tick_wait)(vlc_tick_t deadline)
     vlc_tick_t delay;
 
     vlc_testcancel();
-    while ((delay = (deadline - mdate())) > 0)
+    while ((delay = (deadline - vlc_tick_now())) > 0)
     {
         delay = (delay + 999) / 1000;
         if (unlikely(delay > 0x7fffffff))
@@ -795,7 +795,7 @@ void (vlc_tick_wait)(vlc_tick_t deadline)
 
 void (vlc_tick_sleep)(vlc_tick_t delay)
 {
-    vlc_tick_wait (mdate () + delay);
+    vlc_tick_wait (vlc_tick_now () + delay);
 }
 #endif
 
diff --git a/src/win32/timer.c b/src/win32/timer.c
index a76ad88ab9..767430a515 100644
--- a/src/win32/timer.c
+++ b/src/win32/timer.c
@@ -75,7 +75,7 @@ void vlc_timer_schedule (vlc_timer_t timer, bool absolute,
 
     if (absolute)
     {
-        value -= mdate ();
+        value -= vlc_tick_now ();
         if (value < 0)
             value = 0;
     }
-- 
2.17.0




More information about the vlc-devel mailing list