[vlc-commits] chromecast: postpone stop when loading

Thomas Guillem git at videolan.org
Mon Feb 5 19:21:13 CET 2018


vlc/vlc-3.0 | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Feb  5 17:31:52 2018 +0100| [0e311eb6e4ae6a00729d55de3559e5aa63c0c2fd] | committer: Jean-Baptiste Kempf

chromecast: postpone stop when loading

The cc on the nvidia shield can buffer a lot before sending a Buffering/Playing
event. If you stopped during this period (m_mediaSessionId=0), the cc could
play around 5 seconds of video/sound before draining its buffers.

(cherry picked from commit 3b1359ae207eb9e473f4225b454177a54d8360c0)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/stream_out/chromecast/chromecast.h        |  1 +
 modules/stream_out/chromecast/chromecast_ctrl.cpp | 20 ++++++++++++++++++--
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/modules/stream_out/chromecast/chromecast.h b/modules/stream_out/chromecast/chromecast.h
index cad32ebbb1..b477d2a578 100644
--- a/modules/stream_out/chromecast/chromecast.h
+++ b/modules/stream_out/chromecast/chromecast.h
@@ -234,6 +234,7 @@ private:
     ChromecastCommunication m_communication;
     std::queue<QueueableMessages> m_msgQueue;
     States m_state;
+    bool m_request_stop;
     bool m_eof;
 
     vlc_meta_t *m_meta;
diff --git a/modules/stream_out/chromecast/chromecast_ctrl.cpp b/modules/stream_out/chromecast/chromecast_ctrl.cpp
index aecdc8e353..98b1d6c61a 100644
--- a/modules/stream_out/chromecast/chromecast_ctrl.cpp
+++ b/modules/stream_out/chromecast/chromecast_ctrl.cpp
@@ -92,6 +92,7 @@ intf_sys_t::intf_sys_t(vlc_object_t * const p_this, int port, std::string device
  , m_mediaSessionId( 0 )
  , m_communication( p_this, device_addr.c_str(), device_port )
  , m_state( Authenticating )
+ , m_request_stop( false )
  , m_eof( false )
  , m_meta( NULL )
  , m_ctl_thread_interrupt(p_interrupt)
@@ -269,6 +270,8 @@ void intf_sys_t::setHasInput( const std::string mime_type )
     vlc_mutex_locker locker(&m_lock);
     msg_Dbg( m_module, "Loading content" );
 
+    m_request_stop = false;
+
     this->m_mime = mime_type;
 
     /* new input: clear message queue */
@@ -604,7 +607,13 @@ void intf_sys_t::processMediaMessage( const castchannel::CastMessage& msg )
                 msg_Dbg( m_module, "New mediaSessionId: %" PRId64, m_mediaSessionId );
             }
 
-            if (newPlayerState == "PLAYING")
+            if (m_request_stop)
+            {
+                m_request_stop = false;
+                m_communication.msgPlayerStop( m_appTransportId, m_mediaSessionId );
+                setState( Stopping );
+            }
+            else if (newPlayerState == "PLAYING")
             {
                 msg_Dbg( m_module, "Playback started now:%" PRId64 " i_ts_local_start:%" PRId64,
                          m_time_playback_started, m_ts_local_start);
@@ -790,8 +799,15 @@ void intf_sys_t::requestPlayerStop()
         m_art_stream = NULL;
     }
 
-    if ( m_mediaSessionId == 0 || m_state == TakenOver )
+    if ( m_state == TakenOver )
         return;
+
+    if ( m_mediaSessionId == 0 )
+    {
+        m_request_stop = true;
+        return;
+    }
+
     queueMessage( Stop );
 }
 



More information about the vlc-commits mailing list