[vlc-commits] chromecast: late init of demux time/position

Thomas Guillem git at videolan.org
Thu Feb 22 16:59:18 CET 2018


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Feb 22 16:55:52 2018 +0100| [731ec2ff86223b7bb712a732ca503d1f23b5d5a8] | committer: Thomas Guillem

chromecast: late init of demux time/position

init time/position from the first demux call if they failed from Open/Seek.

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

 modules/stream_out/chromecast/chromecast_demux.cpp | 23 +++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/modules/stream_out/chromecast/chromecast_demux.cpp b/modules/stream_out/chromecast/chromecast_demux.cpp
index 891e85caa1..638ef82904 100644
--- a/modules/stream_out/chromecast/chromecast_demux.cpp
+++ b/modules/stream_out/chromecast/chromecast_demux.cpp
@@ -143,10 +143,11 @@ struct demux_sys_t
     void initTimes()
     {
         if( demux_Control( p_demux->p_next, DEMUX_GET_TIME, &m_start_time ) != VLC_SUCCESS )
-            m_start_time = 0;
+            m_start_time = -1;
 
         if( demux_Control( p_demux->p_next, DEMUX_GET_POSITION, &m_start_pos ) != VLC_SUCCESS )
-            m_start_pos = 0.0f;
+            m_start_pos = -1.0f;
+
         m_last_time = m_start_time;
         m_last_pos = m_start_pos;
     }
@@ -187,6 +188,9 @@ struct demux_sys_t
 
     mtime_t getTime()
     {
+        if( m_start_time < 0 )
+            return -1;
+
         int64_t time = m_start_time;
         mtime_t cc_time = getCCTime();
 
@@ -198,7 +202,7 @@ struct demux_sys_t
 
     double getPosition()
     {
-        if( m_length >= 0 )
+        if( m_length >= 0 && m_start_pos >= 0 )
         {
             m_last_pos = ( getCCTime() / double( m_length ) ) + m_start_pos;
             return m_last_pos;
@@ -257,6 +261,8 @@ struct demux_sys_t
         int ret = VLC_DEMUXER_SUCCESS;
         if( !m_demux_eof )
         {
+            if( m_start_time < 0 || m_start_pos < 0.0f )
+                initTimes();
             ret = demux_Demux( p_demux->p_next );
             if( ret == VLC_DEMUXER_EOF )
                 m_demux_eof = true;
@@ -301,8 +307,15 @@ struct demux_sys_t
             return VLC_EGENERIC;
         }
         case DEMUX_GET_TIME:
-            *va_arg(args, int64_t *) = getTime();
-            return VLC_SUCCESS;
+        {
+            mtime_t time = getTime();
+            if( time >= 0 )
+            {
+                *va_arg(args, int64_t *) = time;
+                return VLC_SUCCESS;
+            }
+            return VLC_EGENERIC;
+        }
         case DEMUX_GET_LENGTH:
         {
             int ret;



More information about the vlc-commits mailing list