[vlc-commits] input: use vlc_tick_t for the input "time" variable

Steve Lhomme git at videolan.org
Thu Sep 20 12:43:54 CEST 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Sat May  5 17:51:16 2018 +0200| [f04e6ce332a460fd94a3778a97de88f25a528a89] | committer: Steve Lhomme

input: use vlc_tick_t for the input "time" variable

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

 modules/control/hotkeys.c                       | 2 +-
 modules/gui/macosx/applescript.m                | 4 ++--
 modules/gui/qt/components/controller.cpp        | 4 ++--
 modules/gui/qt/components/interface_widgets.cpp | 8 ++++----
 modules/gui/qt/components/interface_widgets.hpp | 4 ++--
 modules/gui/qt/dialogs/gototime.cpp             | 2 +-
 modules/gui/qt/input_manager.cpp                | 6 +++---
 modules/gui/qt/input_manager.hpp                | 2 +-
 modules/gui/qt/util/input_slider.cpp            | 2 +-
 modules/gui/qt/util/input_slider.hpp            | 2 +-
 src/input/input.c                               | 2 +-
 src/input/var.c                                 | 2 +-
 src/input/vlm.c                                 | 6 +++---
 13 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/modules/control/hotkeys.c b/modules/control/hotkeys.c
index 94cf44f9a5..ae61de4a65 100644
--- a/modules/control/hotkeys.c
+++ b/modules/control/hotkeys.c
@@ -1525,7 +1525,7 @@ static void DisplayPosition( vout_thread_t *p_vout, int slider_chan,
 
     ClearChannels( p_vout, slider_chan );
 
-    int64_t t = var_GetInteger( p_input, "time" ) / CLOCK_FREQ;
+    int64_t t = SEC_FROM_VLC_TICK(var_GetInteger( p_input, "time" ));
     int64_t l = var_GetInteger( p_input, "length" ) / CLOCK_FREQ;
 
     secstotimestr( psz_time, t );
diff --git a/modules/gui/macosx/applescript.m b/modules/gui/macosx/applescript.m
index 55bba6e155..e7618719b0 100644
--- a/modules/gui/macosx/applescript.m
+++ b/modules/gui/macosx/applescript.m
@@ -223,10 +223,10 @@
 
 - (int) currentTime {
     input_thread_t * p_input = pl_CurrentInput(getIntf());
-    int i_currentTime = -1;
+    vlc_tick_t i_currentTime;
 
     if (!p_input)
-        return i_currentTime;
+        return -1;
 
     i_currentTime = var_GetInteger(p_input, "time");
     vlc_object_release(p_input);
diff --git a/modules/gui/qt/components/controller.cpp b/modules/gui/qt/components/controller.cpp
index 254ded051f..63ac60dd77 100644
--- a/modules/gui/qt/components/controller.cpp
+++ b/modules/gui/qt/components/controller.cpp
@@ -356,8 +356,8 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options )
         slider->setChapters( chapters );
 
         /* Update the position when the IM has changed */
-        CONNECT( THEMIM->getIM(), positionUpdated( float, int64_t, int ),
-                slider, setPosition( float, int64_t, int ) );
+        CONNECT( THEMIM->getIM(), positionUpdated( float, vlc_tick_t, int ),
+                slider, setPosition( float, vlc_tick_t, int ) );
         /* And update the IM, when the position has changed */
         CONNECT( slider, sliderDragged( float ),
                  THEMIM->getIM(), sliderUpdate( float ) );
diff --git a/modules/gui/qt/components/interface_widgets.cpp b/modules/gui/qt/components/interface_widgets.cpp
index 6eebd0ba8c..03519a7b21 100644
--- a/modules/gui/qt/components/interface_widgets.cpp
+++ b/modules/gui/qt/components/interface_widgets.cpp
@@ -957,8 +957,8 @@ TimeLabel::TimeLabel( intf_thread_t *_p_intf, TimeLabel::Display _displayType  )
     CONNECT( THEMIM->getIM(), seekRequested( float ),
              this, setDisplayPosition( float ) );
 
-    CONNECT( THEMIM->getIM(), positionUpdated( float, int64_t, int ),
-              this, setDisplayPosition( float, int64_t, int ) );
+    CONNECT( THEMIM->getIM(), positionUpdated( float, vlc_tick_t, int ),
+              this, setDisplayPosition( float, vlc_tick_t, int ) );
 
     connect( this, SIGNAL( broadcastRemainingTime( bool ) ),
          THEMIM->getIM(), SIGNAL( remainingTimeChanged( bool ) ) );
@@ -983,7 +983,7 @@ void TimeLabel::refresh()
     setDisplayPosition( cachedPos, cachedTime, cachedLength );
 }
 
-void TimeLabel::setDisplayPosition( float pos, int64_t t, int length )
+void TimeLabel::setDisplayPosition( float pos, vlc_tick_t t, int length )
 {
     cachedPos = pos;
     if( pos == -1.f )
@@ -1052,7 +1052,7 @@ void TimeLabel::setDisplayPosition( float pos, int64_t t, int length )
 
 void TimeLabel::setDisplayPosition( float pos )
 {
-    int64_t time = pos * cachedLength * 1000000;
+    vlc_tick_t time = vlc_tick_from_sec(pos * cachedLength);
     setDisplayPosition( pos, time, cachedLength );
 }
 
diff --git a/modules/gui/qt/components/interface_widgets.hpp b/modules/gui/qt/components/interface_widgets.hpp
index 232ffe3e91..76a9e3b5d5 100644
--- a/modules/gui/qt/components/interface_widgets.hpp
+++ b/modules/gui/qt/components/interface_widgets.hpp
@@ -206,7 +206,7 @@ private:
     intf_thread_t *p_intf;
     bool b_remainingTime;
     float cachedPos;
-    int64_t cachedTime;
+    vlc_tick_t cachedTime;
     int cachedLength;
     TimeLabel::Display displayType;
 
@@ -216,7 +216,7 @@ private:
     void refresh();
 private slots:
     void setRemainingTime( bool );
-    void setDisplayPosition( float pos, int64_t time, int length );
+    void setDisplayPosition( float pos, vlc_tick_t time, int length );
     void setDisplayPosition( float pos );
 signals:
     void broadcastRemainingTime( bool );
diff --git a/modules/gui/qt/dialogs/gototime.cpp b/modules/gui/qt/dialogs/gototime.cpp
index 1a96c83afd..3bfd9a4394 100644
--- a/modules/gui/qt/dialogs/gototime.cpp
+++ b/modules/gui/qt/dialogs/gototime.cpp
@@ -88,7 +88,7 @@ void GotoTimeDialog::toggleVisible()
     reset();
     if ( !isVisible() && THEMIM->getIM()->hasInput() )
     {
-        int64_t i_time = var_GetInteger( THEMIM->getInput(), "time" );
+        vlc_tick_t i_time = var_GetInteger( THEMIM->getInput(), "time" );
         timeEdit->setTime( timeEdit->time().addSecs( SEC_FROM_VLC_TICK(i_time) ) );
     }
     QVLCDialog::toggleVisible();
diff --git a/modules/gui/qt/input_manager.cpp b/modules/gui/qt/input_manager.cpp
index 67ff65e2ca..0e6d3ff61c 100644
--- a/modules/gui/qt/input_manager.cpp
+++ b/modules/gui/qt/input_manager.cpp
@@ -423,7 +423,7 @@ void InputManager::UpdatePosition()
 {
     /* Update position */
     vlc_tick_t i_length = var_GetInteger(  p_input , "length" );
-    int64_t i_time = var_GetInteger(  p_input , "time");
+    vlc_tick_t i_time = var_GetInteger(  p_input , "time");
     float f_pos = var_GetFloat(  p_input , "position" );
     emit positionUpdated( f_pos, i_time, SEC_FROM_VLC_TICK(i_length) );
 }
@@ -946,14 +946,14 @@ void InputManager::setAtoB()
     {
         timeB = var_GetInteger( p_mim->getInput(), "time"  );
         var_SetInteger( p_mim->getInput(), "time" , timeA );
-        CONNECT( this, positionUpdated( float, int64_t, int ),
+        CONNECT( this, positionUpdated( float, vlc_tick_t, int ),
                  this, AtoBLoop( float, vlc_tick_t, int ) );
     }
     else
     {
         timeA = VLC_TICK_INVALID;
         timeB = VLC_TICK_INVALID;
-        disconnect( this, SIGNAL( positionUpdated( float, int64_t, int ) ),
+        disconnect( this, SIGNAL( positionUpdated( float, vlc_tick_t, int ) ),
                     this, SLOT( AtoBLoop( float, vlc_tick_t, int ) ) );
     }
     emit AtoBchanged( (timeA != VLC_TICK_INVALID ), (timeB != VLC_TICK_INVALID ) );
diff --git a/modules/gui/qt/input_manager.hpp b/modules/gui/qt/input_manager.hpp
index 3960499224..51a7342cbe 100644
--- a/modules/gui/qt/input_manager.hpp
+++ b/modules/gui/qt/input_manager.hpp
@@ -215,7 +215,7 @@ private slots:
 
 signals:
     /// Send new position, new time and new length
-    void positionUpdated( float , int64_t, int );
+    void positionUpdated( float , vlc_tick_t, int );
     void remainingTimeChanged( bool );
     void seekRequested( float pos );
     void rateChanged( float );
diff --git a/modules/gui/qt/util/input_slider.cpp b/modules/gui/qt/util/input_slider.cpp
index 1620bdf300..8754961257 100644
--- a/modules/gui/qt/util/input_slider.cpp
+++ b/modules/gui/qt/util/input_slider.cpp
@@ -200,7 +200,7 @@ void SeekSlider::setChapters( SeekPoints *chapters_ )
  * \param time Elapsed time. Unused
  * \param legnth Duration time.
  ***/
-void SeekSlider::setPosition( float pos, int64_t time, int length )
+void SeekSlider::setPosition( float pos, vlc_tick_t time, int length )
 {
     VLC_UNUSED(time);
     if( pos == -1.0  || ! b_seekable )
diff --git a/modules/gui/qt/util/input_slider.hpp b/modules/gui/qt/util/input_slider.hpp
index aad65ce4d4..ff4f3133bb 100644
--- a/modules/gui/qt/util/input_slider.hpp
+++ b/modules/gui/qt/util/input_slider.hpp
@@ -118,7 +118,7 @@ private:
     QTimer *startAnimLoadingTimer;
 
 public slots:
-    void setPosition( float, int64_t, int );
+    void setPosition( float, vlc_tick_t, int );
     void setSeekable( bool b ) { b_seekable = b ; }
     void updateBuffering( float );
     void hideHandle();
diff --git a/src/input/input.c b/src/input/input.c
index e6aaaccc7c..3edd5844b0 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -2157,7 +2157,7 @@ static bool Control( input_thread_t *p_input,
             if( i_type == INPUT_CONTROL_SET_SEEKPOINT_PREV )
             {
                 vlc_tick_t i_seekpoint_time = priv->master->title[i_title]->seekpoint[i_seekpoint]->i_time_offset;
-                int64_t i_input_time = var_GetInteger( p_input, "time" );
+                vlc_tick_t i_input_time = var_GetInteger( p_input, "time" );
                 if( i_seekpoint_time >= 0 && i_input_time >= 0 )
                 {
                     if( i_input_time < i_seekpoint_time + VLC_TICK_FROM_SEC(3) )
diff --git a/src/input/var.c b/src/input/var.c
index 0abb0f9875..ca674a0a25 100644
--- a/src/input/var.c
+++ b/src/input/var.c
@@ -890,7 +890,7 @@ static int TimeOffsetCallback( vlc_object_t *obj, char const *varname,
 {
     VLC_UNUSED(varname); VLC_UNUSED(prev); VLC_UNUSED(data);
 
-    int64_t i_time = var_GetInteger( obj, "time" ) + cur.i_int;
+    vlc_tick_t i_time = var_GetInteger( obj, "time" ) + cur.i_int;
     if( i_time < 0 )
         i_time = 0;
     var_SetInteger( obj, "time", i_time );
diff --git a/src/input/vlm.c b/src/input/vlm.c
index 05d4533a02..4faac54146 100644
--- a/src/input/vlm.c
+++ b/src/input/vlm.c
@@ -1079,7 +1079,7 @@ static int vlm_ControlMediaInstanceGetTimePosition( vlm_t *p_vlm, int64_t id, co
         return VLC_EGENERIC;
 
     if( pi_time )
-        *pi_time = var_GetInteger( p_instance->p_input, "time" );
+        *pi_time = US_FROM_VLC_TICK(var_GetInteger( p_instance->p_input, "time" ));
     if( pd_position )
         *pd_position = var_GetFloat( p_instance->p_input, "position" );
     return VLC_SUCCESS;
@@ -1097,7 +1097,7 @@ static int vlm_ControlMediaInstanceSetTimePosition( vlm_t *p_vlm, int64_t id, co
         return VLC_EGENERIC;
 
     if( i_time >= 0 )
-        return var_SetInteger( p_instance->p_input, "time", i_time );
+        return var_SetInteger( p_instance->p_input, "time", VLC_TICK_FROM_US(i_time) );
     else if( d_position >= 0 && d_position <= 100 )
         return var_SetFloat( p_instance->p_input, "position", d_position );
     return VLC_EGENERIC;
@@ -1122,7 +1122,7 @@ static int vlm_ControlMediaInstanceGets( vlm_t *p_vlm, int64_t id, vlm_media_ins
             p_idsc->psz_name = strdup( p_instance->psz_name );
         if( p_instance->p_input )
         {
-            p_idsc->i_time = var_GetInteger( p_instance->p_input, "time" );
+            p_idsc->i_time = US_FROM_VLC_TICK(var_GetInteger( p_instance->p_input, "time" ));
             p_idsc->i_length = var_GetInteger( p_instance->p_input, "length" );
             p_idsc->d_position = var_GetFloat( p_instance->p_input, "position" );
             if( var_GetInteger( p_instance->p_input, "state" ) == PAUSE_S )



More information about the vlc-commits mailing list