[vlc-commits] chromecast: use the enum to handle the connection status

Steve Lhomme git at videolan.org
Wed Dec 23 20:28:23 CET 2015


vlc | branch: master | Steve Lhomme <robUx4 at videolabs.io> | Wed Dec 23 12:58:28 2015 +0100| [f2993b77797bee330e7fad933bead5db5b3a5ecb] | committer: Jean-Baptiste Kempf

chromecast: use the enum to handle the connection status

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/stream_out/chromecast/cast.cpp            |   14 +++++++-------
 modules/stream_out/chromecast/chromecast.h        |    4 ++--
 modules/stream_out/chromecast/chromecast_ctrl.cpp |   18 +++++++++---------
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/modules/stream_out/chromecast/cast.cpp b/modules/stream_out/chromecast/cast.cpp
index cf4c966..fed230c 100644
--- a/modules/stream_out/chromecast/cast.cpp
+++ b/modules/stream_out/chromecast/cast.cpp
@@ -212,7 +212,7 @@ static int Open(vlc_object_t *p_this)
         Clean(p_stream);
         return VLC_EGENERIC;
     }
-    p_sys->p_intf->i_status = CHROMECAST_TLS_CONNECTED;
+    p_sys->p_intf->conn_status = CHROMECAST_TLS_CONNECTED;
 
     char psz_localIP[NI_MAXNUMERICHOST];
     if (net_GetSockAddress(p_sys->i_sock_fd, psz_localIP, NULL))
@@ -265,7 +265,7 @@ static int Open(vlc_object_t *p_this)
     int i_ret = 0;
     const mtime_t deadline = mdate() + 6 * CLOCK_FREQ;
     vlc_mutex_lock(&p_intf->lock);
-    while (p_sys->p_intf->i_status != CHROMECAST_MEDIA_LOAD_SENT)
+    while (p_sys->p_intf->conn_status != CHROMECAST_MEDIA_LOAD_SENT)
     {
         i_ret = vlc_cond_timedwait(&p_sys->p_intf->loadCommandCond, &p_intf->lock, deadline);
         if (i_ret == ETIMEDOUT)
@@ -305,7 +305,7 @@ static void Close(vlc_object_t *p_this)
     vlc_cancel(p_sys->chromecastThread);
     vlc_join(p_sys->chromecastThread, NULL);
 
-    switch (p_sys->p_intf->i_status)
+    switch (p_sys->p_intf->conn_status)
     {
     case CHROMECAST_MEDIA_LOAD_SENT:
     case CHROMECAST_APP_STARTED:
@@ -387,7 +387,7 @@ static void disconnectChromecast(sout_stream_t *p_stream)
         vlc_tls_SessionDelete(p_sys->p_tls);
         vlc_tls_Delete(p_sys->p_creds);
         p_sys->p_tls = NULL;
-        p_sys->p_intf->i_status = CHROMECAST_DISCONNECTED;
+        p_sys->p_intf->conn_status = CHROMECAST_DISCONNECTED;
     }
 }
 
@@ -599,7 +599,7 @@ static void* chromecastThread(void* p_data)
         {
             msg_Err(p_stream, "The connection to the Chromecast died.");
             vlc_mutex_locker locker(&p_sys->p_intf->lock);
-            p_sys->p_intf->i_status = CHROMECAST_CONNECTION_DEAD;
+            p_sys->p_intf->conn_status = CHROMECAST_CONNECTION_DEAD;
             break;
         }
 
@@ -628,12 +628,12 @@ static void* chromecastThread(void* p_data)
             {
                 msg_Err(p_stream, "The connection to the Chromecast died.");
                 vlc_mutex_locker locker(&p_sys->p_intf->lock);
-                p_sys->p_intf->i_status = CHROMECAST_CONNECTION_DEAD;
+                p_sys->p_intf->conn_status = CHROMECAST_CONNECTION_DEAD;
             }
         }
 
         vlc_mutex_lock(&p_sys->p_intf->lock);
-        if ( p_sys->p_intf->i_status == CHROMECAST_CONNECTION_DEAD )
+        if ( p_sys->p_intf->conn_status == CHROMECAST_CONNECTION_DEAD )
         {
             vlc_mutex_unlock(&p_sys->p_intf->lock);
             break;
diff --git a/modules/stream_out/chromecast/chromecast.h b/modules/stream_out/chromecast/chromecast.h
index 239321a..e982a38 100644
--- a/modules/stream_out/chromecast/chromecast.h
+++ b/modules/stream_out/chromecast/chromecast.h
@@ -47,7 +47,7 @@ static const std::string NAMESPACE_MEDIA            = "urn:x-cast:com.google.cas
 
 
 // Status
-enum
+enum connection_status
 {
     CHROMECAST_DISCONNECTED,
     CHROMECAST_TLS_CONNECTED,
@@ -80,7 +80,7 @@ struct intf_sys_t
 
     void msgPlayerLoad();
 
-    int i_status;
+    enum connection_status conn_status;
 
     std::queue<castchannel::CastMessage> messagesToSend;
     unsigned i_requestId;
diff --git a/modules/stream_out/chromecast/chromecast_ctrl.cpp b/modules/stream_out/chromecast/chromecast_ctrl.cpp
index 865a0d2..e7dcc55 100644
--- a/modules/stream_out/chromecast/chromecast_ctrl.cpp
+++ b/modules/stream_out/chromecast/chromecast_ctrl.cpp
@@ -73,7 +73,7 @@ static castchannel::CastMessage buildMessage(std::string namespace_,
 
 intf_sys_t::intf_sys_t(sout_stream_t * const p_this)
  : p_stream(p_this)
- , i_status(CHROMECAST_DISCONNECTED)
+ , conn_status(CHROMECAST_DISCONNECTED)
  , i_requestId(0)
 {
     vlc_mutex_init(&lock);
@@ -111,7 +111,7 @@ void intf_sys_t::processMessage(const castchannel::CastMessage &msg)
         else
         {
             vlc_mutex_locker locker(&lock);
-            i_status = CHROMECAST_AUTHENTICATED;
+            conn_status = CHROMECAST_AUTHENTICATED;
             msgConnect(DEFAULT_CHOMECAST_RECEIVER);
             msgReceiverLaunchApp();
         }
@@ -164,25 +164,25 @@ void intf_sys_t::processMessage(const castchannel::CastMessage &msg)
             if ( p_app )
             {
                 if (!appTransportId.empty()
-                        && i_status == CHROMECAST_AUTHENTICATED)
+                        && conn_status == CHROMECAST_AUTHENTICATED)
                 {
-                    i_status = CHROMECAST_APP_STARTED;
+                    conn_status = CHROMECAST_APP_STARTED;
                     msgConnect(appTransportId);
                     msgPlayerLoad();
-                    i_status = CHROMECAST_MEDIA_LOAD_SENT;
+                    conn_status = CHROMECAST_MEDIA_LOAD_SENT;
                     vlc_cond_signal(&loadCommandCond);
                 }
             }
             else
             {
-                switch(i_status)
+                switch(conn_status)
                 {
                 /* If the app is no longer present */
                 case CHROMECAST_APP_STARTED:
                 case CHROMECAST_MEDIA_LOAD_SENT:
                     msg_Warn(p_stream, "app is no longer present. closing");
                     msgReceiverClose(appTransportId);
-                    i_status = CHROMECAST_CONNECTION_DEAD;
+                    conn_status = CHROMECAST_CONNECTION_DEAD;
                 default:
                     break;
                 }
@@ -214,7 +214,7 @@ void intf_sys_t::processMessage(const castchannel::CastMessage &msg)
             msg_Err(p_stream, "Media load failed");
             msgReceiverClose(appTransportId);
             vlc_mutex_lock(&lock);
-            i_status = CHROMECAST_CONNECTION_DEAD;
+            conn_status = CHROMECAST_CONNECTION_DEAD;
             vlc_mutex_unlock(&lock);
         }
         else
@@ -235,7 +235,7 @@ void intf_sys_t::processMessage(const castchannel::CastMessage &msg)
         {
             msg_Warn(p_stream, "received close message");
             vlc_mutex_lock(&lock);
-            i_status = CHROMECAST_CONNECTION_DEAD;
+            conn_status = CHROMECAST_CONNECTION_DEAD;
             vlc_mutex_unlock(&lock);
         }
         else



More information about the vlc-commits mailing list