[vlc-commits] chromecast: Fix playback position when starting during playback

Hugo Beauzée-Luyssen git at videolan.org
Tue Sep 19 11:49:36 CEST 2017


vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Mon Sep 11 17:21:02 2017 +0200| [881e1eca6c41ea2d417ff5f1b0efcdbd8dd50dbd] | committer: Hugo Beauzée-Luyssen

chromecast: Fix playback position when starting during playback

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

 modules/stream_out/chromecast/chromecast.h         |  3 +++
 modules/stream_out/chromecast/chromecast_common.h  |  1 +
 modules/stream_out/chromecast/chromecast_ctrl.cpp  | 15 ++++++++++++++-
 modules/stream_out/chromecast/chromecast_demux.cpp | 10 ++++++++++
 4 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/modules/stream_out/chromecast/chromecast.h b/modules/stream_out/chromecast/chromecast.h
index 1dba135997..0e493a9c16 100644
--- a/modules/stream_out/chromecast/chromecast.h
+++ b/modules/stream_out/chromecast/chromecast.h
@@ -173,6 +173,8 @@ private:
     mtime_t getPlaybackTimestamp() const;
 
     double getPlaybackPosition() const;
+
+    void setInitialTime( mtime_t time );
     // Sets the current state and signal the associated wait cond.
     // This must be called with the lock held
     void setState( States state );
@@ -190,6 +192,7 @@ private:
     static void set_length(void*, mtime_t length);
     static mtime_t get_time(void*);
     static double get_position(void*);
+    static void set_initial_time( void*, mtime_t time );
 
     static void wait_app_started(void*);
 
diff --git a/modules/stream_out/chromecast/chromecast_common.h b/modules/stream_out/chromecast/chromecast_common.h
index 65b2b83067..0a96f81cf8 100644
--- a/modules/stream_out/chromecast/chromecast_common.h
+++ b/modules/stream_out/chromecast/chromecast_common.h
@@ -40,6 +40,7 @@ typedef struct
     void (*pf_set_length)(void*, mtime_t length);
     mtime_t (*pf_get_time)(void*);
     double (*pf_get_position)(void*);
+    void (*pf_set_initial_time)( void*, mtime_t time );
 
     void (*pf_wait_app_started)(void*);
 
diff --git a/modules/stream_out/chromecast/chromecast_ctrl.cpp b/modules/stream_out/chromecast/chromecast_ctrl.cpp
index 75241c688c..425032dcae 100644
--- a/modules/stream_out/chromecast/chromecast_ctrl.cpp
+++ b/modules/stream_out/chromecast/chromecast_ctrl.cpp
@@ -95,6 +95,7 @@ intf_sys_t::intf_sys_t(vlc_object_t * const p_this, int port, std::string device
     m_common.pf_get_position     = get_position;
     m_common.pf_get_time         = get_time;
     m_common.pf_set_length       = set_length;
+    m_common.pf_set_initial_time = set_initial_time;
     m_common.pf_wait_app_started = wait_app_started;
     m_common.pf_request_seek     = request_seek;
     m_common.pf_wait_seek_done   = wait_seek_done;
@@ -164,7 +165,6 @@ void intf_sys_t::setHasInput( const std::string mime_type )
     // We should now be in the ready state, and therefor have a valid transportId
     assert( m_state == Ready && m_appTransportId.empty() == false );
     // we cannot start a new load when the last one is still processing
-    m_ts_local_start = VLC_TS_0;
     m_communication.msgPlayerLoad( m_appTransportId, m_streaming_port, m_title, m_artwork, mime_type );
     setState( Loading );
 }
@@ -730,6 +730,12 @@ double intf_sys_t::getPlaybackPosition() const
     return 0.0;
 }
 
+void intf_sys_t::setInitialTime(mtime_t time)
+{
+    if( time )
+        m_ts_local_start = time;
+}
+
 void intf_sys_t::setState( States state )
 {
     if ( m_state != state )
@@ -756,6 +762,13 @@ double intf_sys_t::get_position(void *pt)
     return p_this->getPlaybackPosition();
 }
 
+void intf_sys_t::set_initial_time(void *pt, mtime_t time )
+{
+    intf_sys_t *p_this = static_cast<intf_sys_t*>(pt);
+    vlc_mutex_locker locker( &p_this->m_lock );
+    return p_this->setInitialTime( time );
+}
+
 void intf_sys_t::set_length(void *pt, mtime_t length)
 {
     intf_sys_t *p_this = static_cast<intf_sys_t*>(pt);
diff --git a/modules/stream_out/chromecast/chromecast_demux.cpp b/modules/stream_out/chromecast/chromecast_demux.cpp
index 0ef9637dea..8eda508aa3 100644
--- a/modules/stream_out/chromecast/chromecast_demux.cpp
+++ b/modules/stream_out/chromecast/chromecast_demux.cpp
@@ -45,6 +45,7 @@ struct demux_sys_t
         ,demuxReady(false)
         ,m_seektime( VLC_TS_INVALID )
         ,m_enabled( true )
+        ,m_startTime( VLC_TS_INVALID )
     {
         vlc_meta_t *p_meta = vlc_meta_New();
         if( likely(p_meta != NULL) )
@@ -134,6 +135,13 @@ struct demux_sys_t
             demuxReady = true;
             msg_Dbg(p_demux, "ready to demux");
         }
+        if( m_startTime == VLC_TS_INVALID )
+        {
+            if( demux_Control( p_demux->p_next, DEMUX_GET_TIME,
+                               &m_startTime ) == VLC_SUCCESS )
+                p_renderer->pf_set_initial_time( p_renderer->p_opaque,
+                                                 m_startTime );
+        }
 
         /* hold the data while seeking */
         /* wait until the device is buffering for data after the seek command */
@@ -250,6 +258,7 @@ struct demux_sys_t
         case DEMUX_FILTER_DISABLE:
             m_enabled = false;
             p_renderer = NULL;
+            m_startTime = VLC_TS_INVALID;
             return VLC_SUCCESS;
         }
 
@@ -265,6 +274,7 @@ protected:
     /* seek time kept while waiting for the chromecast to "seek" */
     mtime_t       m_seektime;
     bool          m_enabled;
+    mtime_t       m_startTime;
 };
 
 static int Demux( demux_t *p_demux_filter )



More information about the vlc-commits mailing list