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

Thomas Guillem git at videolan.org
Fri Feb 23 08:29:51 CET 2018


vlc/vlc-3.0 | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Feb 22 16:55:52 2018 +0100| [4c8ab8448ebb758a9c03c5b784425f74215585c2] | committer: Thomas Guillem

chromecast: late init of demux time/position

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

(cherry picked from commit 731ec2ff86223b7bb712a732ca503d1f23b5d5a8)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>

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

 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 bc85cf1271..65e64cf629 100644
--- a/modules/stream_out/chromecast/chromecast_demux.cpp
+++ b/modules/stream_out/chromecast/chromecast_demux.cpp
@@ -144,10 +144,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;
     }
@@ -188,6 +189,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();
 
@@ -199,7 +203,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;
@@ -258,6 +262,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;
@@ -302,8 +308,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