[vlc-commits] chromecast: simplify the message sending loop

Steve Lhomme git at videolan.org
Tue May 3 13:22:59 CEST 2016


vlc | branch: master | Steve Lhomme <robux4 at videolabs.io> | Thu Apr 28 14:18:42 2016 +0200| [9e5c50057d69a455afecc9a2db44cfe8bc1f795e] | committer: Thomas Guillem

chromecast: simplify the message sending loop

Signed-off-by: Thomas Guillem <thomas at gllm.fr>

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

 modules/stream_out/chromecast/chromecast.h        |    2 +-
 modules/stream_out/chromecast/chromecast_ctrl.cpp |   17 +++++------------
 2 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/modules/stream_out/chromecast/chromecast.h b/modules/stream_out/chromecast/chromecast.h
index 833339c..a76cc56 100644
--- a/modules/stream_out/chromecast/chromecast.h
+++ b/modules/stream_out/chromecast/chromecast.h
@@ -106,7 +106,7 @@ private:
     void msgAuth();
     void msgReceiverClose(std::string destinationId);
 
-    void handleMessages();
+    bool handleMessages();
 
     connection_status getConnectionStatus() const
     {
diff --git a/modules/stream_out/chromecast/chromecast_ctrl.cpp b/modules/stream_out/chromecast/chromecast_ctrl.cpp
index c9ac020..de0e6d1 100644
--- a/modules/stream_out/chromecast/chromecast_ctrl.cpp
+++ b/modules/stream_out/chromecast/chromecast_ctrl.cpp
@@ -846,19 +846,12 @@ void* intf_sys_t::ChromecastThread(void* p_data)
     p_sys->msgAuth();
     vlc_restorecancel(canc);
 
-    while (1)
-    {
-        p_sys->handleMessages();
-
-        vlc_mutex_locker locker(&p_sys->lock);
-        if ( p_sys->getConnectionStatus() == CHROMECAST_CONNECTION_DEAD )
-            break;
-    }
+    while ( p_sys->handleMessages() );
 
     return NULL;
 }
 
-void intf_sys_t::handleMessages()
+bool intf_sys_t::handleMessages()
 {
     unsigned i_received = 0;
     uint8_t p_packet[PACKET_MAX_LEN];
@@ -885,8 +878,6 @@ void intf_sys_t::handleMessages()
         msg_Err( p_module, "The connection to the Chromecast died (receiving).");
         vlc_mutex_locker locker(&lock);
         setConnectionStatus(CHROMECAST_CONNECTION_DEAD);
-        vlc_restorecancel(canc);
-        return;
     }
 
     if (b_pingTimeout)
@@ -901,6 +892,8 @@ void intf_sys_t::handleMessages()
         msg.ParseFromArray(p_packet + PACKET_HEADER_LEN, i_payloadSize);
         processMessage(msg);
     }
-
     vlc_restorecancel(canc);
+
+    vlc_mutex_locker locker(&lock);
+    return conn_status != CHROMECAST_CONNECTION_DEAD;
 }



More information about the vlc-commits mailing list