[vlc-commits] chromecast: fix the device loading timeout

Adrien Maglo git at videolan.org
Fri Oct 24 15:51:56 CEST 2014


vlc | branch: master | Adrien Maglo <magsoft at videolan.org> | Wed Oct 22 12:18:41 2014 +0200| [1182e9d4d737a4cf00bf84a2438b5e4f87b101e6] | committer: Jean-Baptiste Kempf

chromecast: fix the device loading timeout

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

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

 modules/stream_out/chromecast/cast.cpp |   25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/modules/stream_out/chromecast/cast.cpp b/modules/stream_out/chromecast/cast.cpp
index b9247d5..b5da717 100644
--- a/modules/stream_out/chromecast/cast.cpp
+++ b/modules/stream_out/chromecast/cast.cpp
@@ -284,20 +284,21 @@ static int Open(vlc_object_t *p_this)
 
     // Lock the sout thread until we have sent the media loading command to the Chromecast.
     int i_ret = 0;
+    const mtime_t deadline = mdate() + 6 * CLOCK_FREQ;
+    vlc_mutex_lock(&p_sys->lock);
+    while (p_sys->i_status != CHROMECAST_MEDIA_LOAD_SENT)
     {
-        const mtime_t deadline = mdate() + 6 * CLOCK_FREQ;
-        vlc_mutex_locker locker(&p_sys->lock);
-        while (p_sys->i_status != CHROMECAST_MEDIA_LOAD_SENT)
-            i_ret = vlc_cond_timedwait(&p_sys->loadCommandCond, &p_sys->lock, deadline);
-    }
-    if (i_ret == ETIMEDOUT)
-    {
-        msg_Err(p_stream, "Timeout reached before sending the media loading command");
-        vlc_cancel(p_sys->chromecastThread);
-        vlc_join(p_sys->chromecastThread, NULL);
-        Clean(p_stream);
-        return VLC_EGENERIC;
+        i_ret = vlc_cond_timedwait(&p_sys->loadCommandCond, &p_sys->lock, deadline);
+        if (i_ret == ETIMEDOUT)
+        {
+            msg_Err(p_stream, "Timeout reached before sending the media loading command");
+            vlc_mutex_unlock(&p_sys->lock);
+            vlc_cancel(p_sys->chromecastThread);
+            Clean(p_stream);
+            return VLC_EGENERIC;
+        }
     }
+    vlc_mutex_unlock(&p_sys->lock);
 
     /* Even uglier: sleep more to let to the Chromecast initiate the connection
      * to the http server. */



More information about the vlc-commits mailing list