[vlc-commits] chromecast: queue stop only when needed

Thomas Guillem git at videolan.org
Thu Feb 22 11:59:57 CET 2018


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Feb 20 17:01:53 2018 +0100| [4eca90c1b8acab4cc219235c44a220c49e442be9] | committer: Thomas Guillem

chromecast: queue stop only when needed

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

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

diff --git a/modules/stream_out/chromecast/chromecast.h b/modules/stream_out/chromecast/chromecast.h
index 3b8df10768..232d72202b 100644
--- a/modules/stream_out/chromecast/chromecast.h
+++ b/modules/stream_out/chromecast/chromecast.h
@@ -199,6 +199,7 @@ private:
     bool isStatePlaying() const;
     bool isStateReady() const;
     void tryLoad();
+    void doStop();
 
     void setMeta( vlc_meta_t *p_meta );
 
diff --git a/modules/stream_out/chromecast/chromecast_ctrl.cpp b/modules/stream_out/chromecast/chromecast_ctrl.cpp
index 9ebb6e55a2..e98b171300 100644
--- a/modules/stream_out/chromecast/chromecast_ctrl.cpp
+++ b/modules/stream_out/chromecast/chromecast_ctrl.cpp
@@ -496,16 +496,7 @@ void intf_sys_t::mainLoop()
             switch ( msg )
             {
                 case Stop:
-                    if( isStatePlaying() )
-                    {
-                        if ( m_mediaSessionId == 0 )
-                            m_request_stop = true;
-                        else
-                        {
-                            m_communication.msgPlayerStop( m_appTransportId, m_mediaSessionId );
-                            setState( Stopping );
-                        }
-                    }
+                    doStop();
                     break;
             }
             m_msgQueue.pop();
@@ -909,16 +900,37 @@ bool intf_sys_t::handleMessages()
     return true;
 }
 
+void intf_sys_t::doStop()
+{
+    if( !isStatePlaying() )
+        return;
+
+    if ( m_mediaSessionId == 0 )
+        m_request_stop = true;
+    else
+    {
+        m_communication.msgPlayerStop( m_appTransportId, m_mediaSessionId );
+        setState( Stopping );
+    }
+}
+
 void intf_sys_t::requestPlayerStop()
 {
     vlc_mutex_locker locker(&m_lock);
 
-    m_request_load = false;
+    std::queue<QueueableMessages> empty;
+    std::swap(m_msgQueue, empty);
 
-    if( !isStatePlaying() )
-        return;
+    m_request_load = false;
 
-    queueMessage( Stop );
+    if( vlc_killed() )
+    {
+        if( !isStatePlaying() )
+            return;
+        queueMessage( Stop );
+    }
+    else
+        doStop();
 }
 
 States intf_sys_t::state() const



More information about the vlc-commits mailing list