[vlc-commits] core: use vlc_tick_t for DEMUX_SET_TIME officially

Steve Lhomme git at videolan.org
Thu Sep 20 10:09:18 CEST 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Sat May  5 16:49:15 2018 +0200| [929f09bfc0b99865471e36abc25f3316562cb883] | committer: Steve Lhomme

core: use vlc_tick_t for DEMUX_SET_TIME officially

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

 include/vlc_demux.h                                |  2 +-
 modules/access/bluray.c                            |  3 +--
 modules/access/dcp/dcp.cpp                         |  8 +++-----
 modules/access/live555.cpp                         |  4 +---
 modules/access/timecode.c                          |  2 +-
 modules/demux/adaptive/PlaylistManager.cpp         |  2 +-
 modules/demux/asf/asf.c                            |  4 ++--
 modules/demux/avformat/demux.c                     |  4 ++--
 modules/demux/avi/avi.c                            |  2 +-
 modules/demux/caf.c                                |  5 ++---
 modules/demux/flac.c                               |  5 ++---
 modules/demux/gme.c                                |  2 +-
 modules/demux/image.c                              |  2 +-
 modules/demux/mkv/mkv.cpp                          |  4 ++--
 modules/demux/mod.c                                | 15 ++++++++-------
 modules/demux/mp4/heif.c                           |  2 +-
 modules/demux/mp4/mp4.c                            |  6 +++---
 modules/demux/mpc.c                                |  6 ++++--
 modules/demux/mpeg/es.c                            |  2 +-
 modules/demux/mpeg/ps.c                            |  8 +++++---
 modules/demux/mpeg/ts.c                            |  8 +++++---
 modules/demux/nuv.c                                |  9 ++++-----
 modules/demux/ogg.c                                | 12 +++++++-----
 modules/demux/smf.c                                |  2 +-
 modules/demux/stl.c                                |  2 +-
 modules/demux/subtitle.c                           | 11 ++++++-----
 modules/demux/ttml.c                               |  3 +--
 modules/demux/ty.c                                 |  4 ++--
 modules/demux/vobsub.c                             |  6 +++---
 modules/demux/webvtt.c                             | 15 ++++++---------
 modules/stream_out/chromecast/chromecast_demux.cpp |  2 +-
 src/input/demux.c                                  |  4 ++--
 32 files changed, 82 insertions(+), 84 deletions(-)

diff --git a/include/vlc_demux.h b/include/vlc_demux.h
index 13ce0df760..3078d04079 100644
--- a/include/vlc_demux.h
+++ b/include/vlc_demux.h
@@ -178,7 +178,7 @@ enum demux_query_e
     /* LENGTH/TIME in microsecond, 0 if unknown */
     DEMUX_GET_LENGTH,           /* arg1= vlc_tick_t *   res=    */
     DEMUX_GET_TIME,             /* arg1= vlc_tick_t *   res=    */
-    DEMUX_SET_TIME,             /* arg1= int64_t arg2= bool b_precise   res=can fail    */
+    DEMUX_SET_TIME,             /* arg1= vlc_tick_t arg2= bool b_precise   res=can fail    */
 
     /**
      * \todo Document
diff --git a/modules/access/bluray.c b/modules/access/bluray.c
index 3fdebeca1c..ee589e41b0 100644
--- a/modules/access/bluray.c
+++ b/modules/access/bluray.c
@@ -1943,8 +1943,7 @@ static int blurayControl(demux_t *p_demux, int query, va_list args)
     }
     case DEMUX_SET_TIME:
     {
-        int64_t i_time = va_arg(args, int64_t);
-        bd_seek_time(p_sys->bluray, TO_SCALE_NZ(i_time));
+        bd_seek_time(p_sys->bluray, TO_SCALE_NZ(va_arg(args, vlc_tick_t)));
         notifyDiscontinuity( p_sys );
         return VLC_SUCCESS;
     }
diff --git a/modules/access/dcp/dcp.cpp b/modules/access/dcp/dcp.cpp
index 110a4dda73..b8f615237e 100644
--- a/modules/access/dcp/dcp.cpp
+++ b/modules/access/dcp/dcp.cpp
@@ -777,7 +777,6 @@ static int Control( demux_t *p_demux, int query, va_list args )
 {
     double f,*pf;
     bool *pb;
-    int64_t i64;
     demux_sys_t *p_sys = (demux_sys_t *)p_demux->p_sys;
 
     switch ( query )
@@ -824,12 +823,11 @@ static int Control( demux_t *p_demux, int query, va_list args )
             break;
 
         case DEMUX_SET_TIME:
-            i64 = va_arg( args, int64_t );
+            p_sys->i_pts = va_arg( args, vlc_tick_t );
             msg_Warn( p_demux, "DEMUX_SET_TIME"  );
-            p_sys->frame_no = i64 * p_sys->frame_rate_num / ( CLOCK_FREQ * p_sys->frame_rate_denom );
-            p_sys->i_pts= i64;
+            p_sys->frame_no = p_sys->i_pts * p_sys->frame_rate_num / ( CLOCK_FREQ * p_sys->frame_rate_denom );
             es_out_SetPCR(p_demux->out, p_sys->i_pts);
-            es_out_Control( p_demux->out, ES_OUT_SET_NEXT_DISPLAY_TIME, ( vlc_tick_t ) i64 );
+            es_out_Control( p_demux->out, ES_OUT_SET_NEXT_DISPLAY_TIME, p_sys->i_pts );
             break;
         case DEMUX_GET_PTS_DELAY:
             *va_arg( args, vlc_tick_t * ) =
diff --git a/modules/access/live555.cpp b/modules/access/live555.cpp
index 606bdc46b2..4601c4ae17 100644
--- a/modules/access/live555.cpp
+++ b/modules/access/live555.cpp
@@ -1518,7 +1518,6 @@ static int Demux( demux_t *p_demux )
 static int Control( demux_t *p_demux, int i_query, va_list args )
 {
     demux_sys_t *p_sys = (demux_sys_t *)p_demux->p_sys;
-    int64_t i64;
     double  *pf, f;
     bool *pb;
 
@@ -1562,8 +1561,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
 
                 if( (i_query == DEMUX_SET_TIME) && (p_sys->f_npt > 0) )
                 {
-                    i64 = va_arg( args, int64_t );
-                    time = (float)(i64 / 1000000.0); /* in second */
+                    time = secf_from_vlc_tick(va_arg( args, vlc_tick_t )); /* in second */
                 }
                 else if( i_query == DEMUX_SET_TIME )
                     return VLC_EGENERIC;
diff --git a/modules/access/timecode.c b/modules/access/timecode.c
index dbe6535e37..d2c5819d84 100644
--- a/modules/access/timecode.c
+++ b/modules/access/timecode.c
@@ -129,7 +129,7 @@ static int Control (demux_t *demux, int query, va_list args)
             break;
 
         case DEMUX_SET_TIME:
-            date_Set (&sys->date, va_arg (args, int64_t));
+            date_Set (&sys->date, va_arg (args, vlc_tick_t));
             break;
 
         case DEMUX_SET_NEXT_DEMUX_TIME:
diff --git a/modules/demux/adaptive/PlaylistManager.cpp b/modules/demux/adaptive/PlaylistManager.cpp
index 74ffda70c6..3861e55e98 100644
--- a/modules/demux/adaptive/PlaylistManager.cpp
+++ b/modules/demux/adaptive/PlaylistManager.cpp
@@ -584,7 +584,7 @@ int PlaylistManager::doControl(int i_query, va_list args)
                 return VLC_EGENERIC;
             }
 
-            int64_t time = va_arg(args, int64_t);// + getFirstPlaybackTime();
+            vlc_tick_t time = va_arg(args, vlc_tick_t);// + getFirstPlaybackTime();
             if(!setPosition(time))
             {
                 setBufferingRunState(true);
diff --git a/modules/demux/asf/asf.c b/modules/demux/asf/asf.c
index 24bcc0339e..3a7b1c1082 100644
--- a/modules/demux/asf/asf.c
+++ b/modules/demux/asf/asf.c
@@ -413,7 +413,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
     vlc_meta_t  *p_meta;
-    int64_t     i64;
+    vlc_tick_t  i64;
     int         i;
     double      f, *pf;
 
@@ -439,7 +439,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
         {
             va_list acpy;
             va_copy( acpy, args );
-            i64 = va_arg( acpy, int64_t );
+            i64 = va_arg( acpy, vlc_tick_t );
             va_end( acpy );
 
             if( !SeekIndex( p_demux, i64, -1 ) )
diff --git a/modules/demux/avformat/demux.c b/modules/demux/avformat/demux.c
index cbedd7f109..8bdaed0afc 100644
--- a/modules/demux/avformat/demux.c
+++ b/modules/demux/avformat/demux.c
@@ -1070,12 +1070,12 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
 
         case DEMUX_SET_TIME:
         {
-            i64 = va_arg( args, int64_t );
+            i64 = TO_AV_TS(va_arg( args, vlc_tick_t ));
             bool precise = va_arg( args, int );
 
             msg_Warn( p_demux, "DEMUX_SET_TIME: %"PRId64, i64 );
 
-            if( av_seek_frame( p_sys->ic, -1, TO_AV_TS(i64) + i_start_time, AVSEEK_FLAG_BACKWARD ) < 0 )
+            if( av_seek_frame( p_sys->ic, -1, i64 + i_start_time, AVSEEK_FLAG_BACKWARD ) < 0 )
             {
                 return VLC_EGENERIC;
             }
diff --git a/modules/demux/avi/avi.c b/modules/demux/avi/avi.c
index fec84cee6c..22b9c0a842 100644
--- a/modules/demux/avi/avi.c
+++ b/modules/demux/avi/avi.c
@@ -1625,7 +1625,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
         {
             f = 0;
 
-            i64 = va_arg( args, int64_t );
+            i64 = va_arg( args, vlc_tick_t );
             b = va_arg( args, int );
             if( !p_sys->b_seekable )
             {
diff --git a/modules/demux/caf.c b/modules/demux/caf.c
index 44df146d04..c48114aa19 100644
--- a/modules/demux/caf.c
+++ b/modules/demux/caf.c
@@ -1002,7 +1002,7 @@ static int Demux( demux_t *p_demux )
  *****************************************************************************/
 static int Control( demux_t *p_demux, int i_query, va_list args )
 {
-    int64_t i64, i_sample;
+    int64_t i_sample;
     double f, *pf;
     frame_span_t position;
 
@@ -1039,8 +1039,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             return VLC_SUCCESS;
 
         case DEMUX_SET_TIME:
-            i64 = va_arg( args, int64_t );
-            i_sample = i64 * p_sys->fmt.audio.i_rate / CLOCK_FREQ;
+            i_sample = va_arg( args, vlc_tick_t ) * p_sys->fmt.audio.i_rate / CLOCK_FREQ;
             if( SetSpanWithSample( p_demux, &position, i_sample ))
                 return VLC_EGENERIC;
             p_sys->position = position;
diff --git a/modules/demux/flac.c b/modules/demux/flac.c
index 0ed521db2a..3790131841 100644
--- a/modules/demux/flac.c
+++ b/modules/demux/flac.c
@@ -440,7 +440,7 @@ static vlc_tick_t ControlGetTime( demux_t *p_demux )
     return p_sys->i_pts;
 }
 
-static int ControlSetTime( demux_t *p_demux, int64_t i_time )
+static int ControlSetTime( demux_t *p_demux, vlc_tick_t i_time )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
     bool b_seekable;
@@ -526,8 +526,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
     }
     else if( i_query == DEMUX_SET_TIME )
     {
-        int64_t i_time = va_arg( args, int64_t );
-        return ControlSetTime( p_demux, i_time );
+        return ControlSetTime( p_demux, va_arg( args, vlc_tick_t ) );
     }
     else if( i_query == DEMUX_SET_POSITION )
     {
diff --git a/modules/demux/gme.c b/modules/demux/gme.c
index efff60ac0c..5bf2244b8b 100644
--- a/modules/demux/gme.c
+++ b/modules/demux/gme.c
@@ -295,7 +295,7 @@ static int Control (demux_t *demux, int query, va_list args)
 
         case DEMUX_SET_TIME:
         {
-            int64_t v = va_arg (args, int64_t) / 1000;
+            int64_t v = MS_FROM_VLC_TICK( va_arg (args, vlc_tick_t) );
             if (v > INT_MAX || gme_seek (sys->emu, v))
                 break;
             return VLC_SUCCESS;
diff --git a/modules/demux/image.c b/modules/demux/image.c
index 536ce681d9..384c7b2222 100644
--- a/modules/demux/image.c
+++ b/modules/demux/image.c
@@ -261,7 +261,7 @@ static int Control(demux_t *demux, int query, va_list args)
     case DEMUX_SET_TIME: {
         if (sys->duration < 0 || sys->is_realtime)
             return VLC_EGENERIC;
-        int64_t time = va_arg(args, int64_t);
+        vlc_tick_t time = va_arg(args, vlc_tick_t);
         date_Set(&sys->pts, VLC_CLIP(time - sys->pts_offset, VLC_TICK_0, sys->duration));
         return VLC_SUCCESS;
     }
diff --git a/modules/demux/mkv/mkv.cpp b/modules/demux/mkv/mkv.cpp
index f6a2112afb..84c56590c9 100644
--- a/modules/demux/mkv/mkv.cpp
+++ b/modules/demux/mkv/mkv.cpp
@@ -284,7 +284,7 @@ static void Close( vlc_object_t *p_this )
 static int Control( demux_t *p_demux, int i_query, va_list args )
 {
     demux_sys_t *p_sys = (demux_sys_t *)p_demux->p_sys;
-    int64_t     i64;
+    vlc_tick_t  i64;
     double      *pf, f;
     int         i_skp;
     size_t      i_idx;
@@ -451,7 +451,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             return VLC_SUCCESS;
 
         case DEMUX_SET_TIME:
-            i64 = va_arg( args, int64_t );
+            i64 = va_arg( args, vlc_tick_t );
             b = va_arg( args, int ); /* precise? */
             msg_Dbg(p_demux,"SET_TIME to %" PRId64, i64 );
             return Seek( p_demux, i64, -1, NULL, b );
diff --git a/modules/demux/mod.c b/modules/demux/mod.c
index 40dbcaa00f..b82553c391 100644
--- a/modules/demux/mod.c
+++ b/modules/demux/mod.c
@@ -115,7 +115,7 @@ typedef struct
     es_out_id_t *es;
 
     date_t      pts;
-    int64_t     i_length;
+    vlc_tick_t  i_length;
 
     int         i_data;
     uint8_t     *p_data;
@@ -218,11 +218,11 @@ static int Open( vlc_object_t *p_this )
     /* init time */
     date_Init( &p_sys->pts, settings.mFrequency, 1 );
     date_Set( &p_sys->pts, VLC_TICK_0 );
-    p_sys->i_length = ModPlug_GetLength( p_sys->f ) * INT64_C(1000);
+    p_sys->i_length = VLC_TICK_FROM_MS( ModPlug_GetLength( p_sys->f ) );
 
     msg_Dbg( p_demux, "MOD loaded name=%s length=%"PRId64"ms",
              ModPlug_GetName( p_sys->f ),
-             p_sys->i_length );
+             MS_FROM_VLC_TICK( p_sys->i_length ) );
 
 #ifdef WORDS_BIGENDIAN
     es_format_Init( &p_sys->fmt, AUDIO_ES, VLC_FOURCC( 't', 'w', 'o', 's' ) );
@@ -292,7 +292,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
     double f, *pf;
-    int64_t i64;
+    vlc_tick_t i64;
     vlc_tick_t *pi64;
 
     switch( i_query )
@@ -330,15 +330,16 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
         return VLC_SUCCESS;
 
     case DEMUX_GET_LENGTH:
-        *va_arg( args, vlc_tick_t * ) = p_sys->i_length;
+        pi64 = va_arg( args, vlc_tick_t * );
+        *pi64 = p_sys->i_length;
         return VLC_SUCCESS;
 
     case DEMUX_SET_TIME:
-        i64 = va_arg( args, int64_t );
+        i64 = va_arg( args, vlc_tick_t );
 
         if( i64 >= 0 && i64 <= p_sys->i_length )
         {
-            ModPlug_Seek( p_sys->f, i64 / 1000 );
+            ModPlug_Seek( p_sys->f, MS_FROM_VLC_TICK( i64 ) );
             date_Set( &p_sys->pts, VLC_TICK_0 + i64 );
 
             return VLC_SUCCESS;
diff --git a/modules/demux/mp4/heif.c b/modules/demux/mp4/heif.c
index e2ea427608..ad9dd6a9ac 100644
--- a/modules/demux/mp4/heif.c
+++ b/modules/demux/mp4/heif.c
@@ -185,7 +185,7 @@ static int ControlHEIF( demux_t *p_demux, int i_query, va_list args )
             return VLC_SUCCESS;
         case DEMUX_SET_TIME:
         {
-            SeekToPrevImageEnd( p_sys, va_arg(args, int64_t) /
+            SeekToPrevImageEnd( p_sys, va_arg(args, vlc_tick_t) /
                                 p_sys->i_image_duration );
             return VLC_SUCCESS;
         }
diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index 3b89e64faf..e9f5fd6049 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -1946,7 +1946,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
     demux_sys_t *p_sys = p_demux->p_sys;
 
     double f, *pf;
-    int64_t i64;
+    vlc_tick_t i64;
     bool b;
 
     const uint64_t i_duration = __MAX(p_sys->i_duration, p_sys->i_cumulated_duration);
@@ -1981,7 +1981,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
                 return FragSeekToPos( p_demux, f, b );
             else if( p_sys->i_timescale > 0 )
             {
-                i64 = (int64_t)( f * MP4_rescale_mtime( p_sys->i_duration,
+                i64 = (vlc_tick_t)( f * MP4_rescale_mtime( p_sys->i_duration,
                                                         p_sys->i_timescale ) );
                 return Seek( p_demux, i64, b );
             }
@@ -1992,7 +1992,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             return VLC_SUCCESS;
 
         case DEMUX_SET_TIME:
-            i64 = va_arg( args, int64_t );
+            i64 = va_arg( args, vlc_tick_t );
             b = va_arg( args, int );
             if ( p_demux->pf_demux == DemuxFrag )
                 return FragSeekToTime( p_demux, i64, b );
diff --git a/modules/demux/mpc.c b/modules/demux/mpc.c
index 3148710ad7..d422e870f4 100644
--- a/modules/demux/mpc.c
+++ b/modules/demux/mpc.c
@@ -260,7 +260,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
     double   f, *pf;
-    int64_t i64;
+    vlc_tick_t i64;
     vlc_tick_t *pi64;
     bool *pb_bool;
 
@@ -304,13 +304,15 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             return VLC_EGENERIC;
 
         case DEMUX_SET_TIME:
-            i64 = va_arg( args, int64_t );
+        {
+            vlc_tick_t i64 = va_arg( args, vlc_tick_t );
             if( mpc_decoder_seek_sample( &p_sys->decoder, i64 ) )
             {
                 p_sys->i_position = i64;
                 return VLC_SUCCESS;
             }
             return VLC_EGENERIC;
+        }
 
         case DEMUX_CAN_PAUSE:
         case DEMUX_SET_PAUSE_STATE:
diff --git a/modules/demux/mpeg/es.c b/modules/demux/mpeg/es.c
index e82a716cbb..4650b95d23 100644
--- a/modules/demux/mpeg/es.c
+++ b/modules/demux/mpeg/es.c
@@ -436,7 +436,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
         case DEMUX_SET_TIME:
             if( p_sys->mllt.p_bits )
             {
-                int64_t i_time = va_arg(args, int64_t);
+                vlc_tick_t i_time = va_arg(args, vlc_tick_t);
                 uint64_t i_pos = SeekByMlltTable( p_demux, &i_time );
                 int i_ret = vlc_stream_Seek( p_demux->s, p_sys->i_stream_offset + i_pos );
                 if( i_ret != VLC_SUCCESS )
diff --git a/modules/demux/mpeg/ps.c b/modules/demux/mpeg/ps.c
index d3045423f3..342fcadfba 100644
--- a/modules/demux/mpeg/ps.c
+++ b/modules/demux/mpeg/ps.c
@@ -764,14 +764,16 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             break;
 
         case DEMUX_SET_TIME:
-            i64 = va_arg( args, int64_t );
+        {
             if( p_sys->i_time_track_index >= 0 && p_sys->i_current_pts != VLC_TICK_INVALID &&
                 p_sys->i_length > VLC_TICK_0)
             {
-                i64 -= p_sys->tk[p_sys->i_time_track_index].i_first_pts;
-                return demux_Control( p_demux, DEMUX_SET_POSITION, (double) i64 / p_sys->i_length );
+                vlc_tick_t i_time = va_arg( args, vlc_tick_t );
+                i_time -= p_sys->tk[p_sys->i_time_track_index].i_first_pts;
+                return demux_Control( p_demux, DEMUX_SET_POSITION, (double) i_time / p_sys->i_length );
             }
             break;
+        }
 
         case DEMUX_GET_TITLE_INFO:
         {
diff --git a/modules/demux/mpeg/ts.c b/modules/demux/mpeg/ts.c
index fa733292da..128c815269 100644
--- a/modules/demux/mpeg/ts.c
+++ b/modules/demux/mpeg/ts.c
@@ -997,17 +997,19 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
         break;
 
     case DEMUX_SET_TIME:
-        i64 = va_arg( args, int64_t );
+    {
+        vlc_tick_t i_time = va_arg( args, vlc_tick_t );
 
         if( p_sys->b_canseek && p_pmt && p_pmt->pcr.i_first > -1 &&
-           !SeekToTime( p_demux, p_pmt, p_pmt->pcr.i_first + TO_SCALE(i64) ) )
+           !SeekToTime( p_demux, p_pmt, p_pmt->pcr.i_first + TO_SCALE(i_time) ) )
         {
             ReadyQueuesPostSeek( p_demux );
             es_out_Control( p_demux->out, ES_OUT_SET_NEXT_DISPLAY_TIME,
-                            FROM_SCALE(p_pmt->pcr.i_first) + i64 - VLC_TICK_0 );
+                            FROM_SCALE(p_pmt->pcr.i_first) + i_time - VLC_TICK_0 );
             return VLC_SUCCESS;
         }
         break;
+    }
 
     case DEMUX_GET_TIME:
         if( p_sys->b_access_control )
diff --git a/modules/demux/nuv.c b/modules/demux/nuv.c
index 4e76c229ee..ab2cb29a32 100644
--- a/modules/demux/nuv.c
+++ b/modules/demux/nuv.c
@@ -62,7 +62,7 @@ static int Control( demux_t *, int, va_list );
 /* */
 typedef struct
 {
-    int64_t i_time;
+    vlc_tick_t i_time;
     int64_t i_offset;
 
 } demux_index_entry_t;
@@ -81,7 +81,7 @@ static void demux_IndexClean( demux_index_t * );
 static void demux_IndexAppend( demux_index_t *,
                                int64_t i_time, int64_t i_offset );
 /* Convert a time into offset */
-static int64_t demux_IndexConvertTime( demux_index_t *, int64_t i_time );
+static int64_t demux_IndexConvertTime( demux_index_t *, vlc_tick_t i_time );
 /* Find the nearest offset in the index */
 static int64_t demux_IndexFindOffset( demux_index_t *, int64_t i_offset );
 
@@ -509,11 +509,10 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
         case DEMUX_SET_TIME:
         {
             int64_t i_pos;
-            i64 = va_arg( args, int64_t );
 
             p_sys->i_pcr = -1;
 
-            i_pos = demux_IndexConvertTime( &p_sys->idx, i64 );
+            i_pos = demux_IndexConvertTime( &p_sys->idx, va_arg( args, vlc_tick_t ) );
             if( i_pos < 0 )
                 return VLC_EGENERIC;
             else
@@ -957,7 +956,7 @@ static void demux_IndexAppend( demux_index_t *p_idx,
 
     p_idx->i_idx++;
 }
-static int64_t demux_IndexConvertTime( demux_index_t *p_idx, int64_t i_time )
+static int64_t demux_IndexConvertTime( demux_index_t *p_idx, vlc_tick_t i_time )
 {
     int i_min = 0;
     int i_max = p_idx->i_idx-1;
diff --git a/modules/demux/ogg.c b/modules/demux/ogg.c
index 62db4aaa4c..c05733df9a 100644
--- a/modules/demux/ogg.c
+++ b/modules/demux/ogg.c
@@ -671,9 +671,10 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
 {
     demux_sys_t *p_sys  = p_demux->p_sys;
     vlc_meta_t *p_meta;
-    int64_t i64;
+    vlc_tick_t i64;
     double *pf, f;
     bool *pb_bool, b, acc;
+    logical_stream_t *p_stream;
 
     switch( i_query )
     {
@@ -704,9 +705,10 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             return VLC_EGENERIC;
 
         case DEMUX_SET_TIME:
-            i64 = va_arg( args, int64_t );
+        {
+            i64 = va_arg( args, vlc_tick_t );
             acc = va_arg( args, int );
-            logical_stream_t *p_stream = Ogg_GetSelectedStream( p_demux );
+            p_stream = Ogg_GetSelectedStream( p_demux );
             if ( !p_stream )
             {
                 msg_Err( p_demux, "No selected seekable stream found" );
@@ -723,6 +725,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             }
             else
                 return VLC_EGENERIC;
+        }
 
         case DEMUX_GET_ATTACHMENTS:
         {
@@ -751,8 +754,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             }
             else if( stream_Size( p_demux->s ) > 0 )
             {
-                i64 = vlc_stream_Tell( p_demux->s );
-                *pf = (double) i64 / stream_Size( p_demux->s );
+                *pf = (double) vlc_stream_Tell( p_demux->s ) / stream_Size( p_demux->s );
             }
             else *pf = 0.0;
             return VLC_SUCCESS;
diff --git a/modules/demux/smf.c b/modules/demux/smf.c
index d60f2f0ec4..ce2bba810e 100644
--- a/modules/demux/smf.c
+++ b/modules/demux/smf.c
@@ -523,7 +523,7 @@ static int Control (demux_t *demux, int i_query, va_list args)
             *va_arg (args, vlc_tick_t *) = sys->tick - VLC_TICK_0;
             break;
         case DEMUX_SET_TIME:
-            return Seek (demux, va_arg (args, int64_t));
+            return Seek (demux, va_arg (args, vlc_tick_t));
 
         case DEMUX_CAN_PAUSE:
         case DEMUX_SET_PAUSE_STATE:
diff --git a/modules/demux/stl.c b/modules/demux/stl.c
index cf5210234e..af20931638 100644
--- a/modules/demux/stl.c
+++ b/modules/demux/stl.c
@@ -119,7 +119,7 @@ static int Control(demux_t *demux, int query, va_list args)
         return VLC_SUCCESS;
     }
     case DEMUX_SET_TIME: {
-        int64_t t = va_arg(args, int64_t);
+        vlc_tick_t t = va_arg(args, vlc_tick_t);
         for( size_t i = 0; i + 1< sys->count; i++ )
         {
             if( sys->index[i + 1].start >= t &&
diff --git a/modules/demux/subtitle.c b/modules/demux/subtitle.c
index 2e6d767b73..dc2df5fc3c 100644
--- a/modules/demux/subtitle.c
+++ b/modules/demux/subtitle.c
@@ -752,7 +752,6 @@ static void Close( vlc_object_t *p_this )
 static int Control( demux_t *p_demux, int i_query, va_list args )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
-    int64_t i64;
     double *pf, f;
 
     switch( i_query )
@@ -772,16 +771,18 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             return VLC_SUCCESS;
 
         case DEMUX_SET_TIME:
-            i64 = va_arg( args, int64_t );
+        {
             p_sys->b_first_time = true;
-            p_sys->i_next_demux_date = i64;
+            p_sys->i_next_demux_date = va_arg( args, vlc_tick_t );
             for( size_t i = 0; i < p_sys->subtitles.i_count; i++ )
             {
-                if( p_sys->subtitles.p_array[i].i_start > i64 && i > 0 )
+                if( p_sys->subtitles.p_array[i].i_start > p_sys->i_next_demux_date &&
+                    i > 0 )
                     break;
                 p_sys->subtitles.i_current = i;
             }
             return VLC_SUCCESS;
+        }
 
         case DEMUX_GET_POSITION:
             pf = va_arg( args, double * );
@@ -806,7 +807,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             f = va_arg( args, double );
             if( p_sys->subtitles.i_count && p_sys->i_length )
             {
-                i64 = VLC_TICK_0 + f * p_sys->i_length;
+                vlc_tick_t i64 = VLC_TICK_0 + f * p_sys->i_length;
                 return demux_Control( p_demux, DEMUX_SET_TIME, i64 );
             }
             break;
diff --git a/modules/demux/ttml.c b/modules/demux/ttml.c
index 4fd7d92c91..4e834e1a3b 100644
--- a/modules/demux/ttml.c
+++ b/modules/demux/ttml.c
@@ -220,10 +220,9 @@ static int Control( demux_t* p_demux, int i_query, va_list args )
             *va_arg( args, vlc_tick_t * ) = p_sys->i_next_demux_time;
             return VLC_SUCCESS;
         case DEMUX_SET_TIME:
-            i64 = va_arg( args, int64_t );
             if( p_sys->times.i_count )
             {
-                tt_time_t t = tt_time_Create( i64 - VLC_TICK_0 );
+                tt_time_t t = tt_time_Create( va_arg( args, vlc_tick_t ) - VLC_TICK_0 );
                 size_t i_index = tt_timings_FindLowerIndex( p_sys->times.p_array,
                                                             p_sys->times.i_count, t, &b );
                 p_sys->times.i_current = i_index;
diff --git a/modules/demux/ty.c b/modules/demux/ty.c
index fb83ef451e..bbe4b5719b 100644
--- a/modules/demux/ty.c
+++ b/modules/demux/ty.c
@@ -529,8 +529,8 @@ static int Control(demux_t *p_demux, int i_query, va_list args)
         *va_arg(args, vlc_tick_t *) = 0;
         return VLC_SUCCESS;
     case DEMUX_SET_TIME:      /* arg is time in microsecs */
-        i64 = va_arg( args, int64_t );
-        return ty_stream_seek_time(p_demux, i64 * 1000);
+        return ty_stream_seek_time(p_demux,
+                                   NS_FROM_VLC_TICK(va_arg( args, vlc_tick_t )));
     case DEMUX_CAN_PAUSE:
     case DEMUX_SET_PAUSE_STATE:
     case DEMUX_CAN_CONTROL_PACE:
diff --git a/modules/demux/vobsub.c b/modules/demux/vobsub.c
index b1f939216e..abeacd6cd8 100644
--- a/modules/demux/vobsub.c
+++ b/modules/demux/vobsub.c
@@ -238,7 +238,7 @@ static void Close( vlc_object_t *p_this )
 static int Control( demux_t *p_demux, int i_query, va_list args )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
-    int64_t i64;
+    vlc_tick_t i64;
     int i;
     double *pf, f;
 
@@ -269,7 +269,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             return VLC_EGENERIC;
 
         case DEMUX_SET_TIME:
-            i64 = va_arg( args, int64_t );
+            i64 = va_arg( args, vlc_tick_t );
             for( i = 0; i < p_sys->i_tracks; i++ )
             {
                 p_sys->track[i].i_current_subtitle = 0;
@@ -311,7 +311,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
 
         case DEMUX_SET_POSITION:
             f = va_arg( args, double );
-            i64 = (int64_t) f * p_sys->i_length;
+            i64 = (vlc_tick_t) f * p_sys->i_length;
 
             for( i = 0; i < p_sys->i_tracks; i++ )
             {
diff --git a/modules/demux/webvtt.c b/modules/demux/webvtt.c
index 06f29c6dc2..a4d3639842 100644
--- a/modules/demux/webvtt.c
+++ b/modules/demux/webvtt.c
@@ -439,15 +439,12 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             return VLC_SUCCESS;
 
         case DEMUX_SET_TIME:
-            i64 = va_arg( args, int64_t );
-            {
-                p_sys->index.i_current = getIndexByTime( p_sys, i64 );
-                p_sys->b_first_time = true;
-                p_sys->i_next_demux_time =
-                        p_sys->index.p_array[p_sys->index.i_current].time;
-                p_sys->i_next_block_flags |= BLOCK_FLAG_DISCONTINUITY;
-                return VLC_SUCCESS;
-            }
+            p_sys->index.i_current = getIndexByTime( p_sys, va_arg( args, vlc_tick_t ) );
+            p_sys->b_first_time = true;
+            p_sys->i_next_demux_time =
+                    p_sys->index.p_array[p_sys->index.i_current].time;
+            p_sys->i_next_block_flags |= BLOCK_FLAG_DISCONTINUITY;
+            return VLC_SUCCESS;
 
         case DEMUX_GET_POSITION:
             pf = va_arg( args, double * );
diff --git a/modules/stream_out/chromecast/chromecast_demux.cpp b/modules/stream_out/chromecast/chromecast_demux.cpp
index b82fd74d92..02e20db042 100644
--- a/modules/stream_out/chromecast/chromecast_demux.cpp
+++ b/modules/stream_out/chromecast/chromecast_demux.cpp
@@ -369,7 +369,7 @@ struct demux_cc
         {
             m_pause_delay = m_pause_date = VLC_TICK_INVALID;
 
-            vlc_tick_t time = va_arg( args, int64_t );
+            vlc_tick_t time = va_arg( args, vlc_tick_t );
             /* Force unprecise seek */
             int ret = demux_Control( p_demux->p_next, DEMUX_SET_TIME, time, false );
             if( ret != VLC_SUCCESS )
diff --git a/src/input/demux.c b/src/input/demux.c
index b715e28a1e..31be72cbb2 100644
--- a/src/input/demux.c
+++ b/src/input/demux.c
@@ -275,7 +275,7 @@ int demux_vaControlHelper( stream_t *s,
 {
     int64_t i_tell;
     double  f, *pf;
-    int64_t i64;
+    vlc_tick_t i64;
 
     if( i_end < 0 )    i_end   = stream_Size( s );
     if( i_start < 0 )  i_start = 0;
@@ -351,7 +351,7 @@ int demux_vaControlHelper( stream_t *s,
             return VLC_EGENERIC;
 
         case DEMUX_SET_TIME:
-            i64 = (int64_t)va_arg( args, int64_t );
+            i64 = va_arg( args, vlc_tick_t );
             if( i_bitrate > 0 && i64 >= 0 )
             {
                 int64_t i_block = i64 * i_bitrate / INT64_C(8000000) / i_align;



More information about the vlc-commits mailing list