media: limit the time to wait to something huge
authorWim Taymans <wim.taymans@collabora.co.uk>
Fri, 5 Mar 2010 17:23:18 +0000 (18:23 +0100)
committerWim Taymans <wim.taymans@collabora.co.uk>
Fri, 5 Mar 2010 17:23:18 +0000 (18:23 +0100)
Avoid waiting forever but limit the timeout to 20 seconds.

gst/rtsp-server/rtsp-media.c

index a2fe5d3..116e806 100644 (file)
@@ -1115,12 +1115,18 @@ static GstRTSPMediaStatus
 gst_rtsp_media_get_status (GstRTSPMedia *media)
 {
   GstRTSPMediaStatus result;
+  GTimeVal timeout;
 
   g_mutex_lock (media->lock);
+  g_get_current_time (&timeout);
+  g_time_val_add (&timeout, 20 * G_USEC_PER_SEC);
   /* while we are preparing, wait */
   while (media->status == GST_RTSP_MEDIA_STATUS_PREPARING) {
     GST_DEBUG ("waiting for status change");
-    g_cond_wait (media->cond, media->lock);
+    if (!g_cond_timed_wait (media->cond, media->lock, &timeout)) {
+      GST_DEBUG ("timeout, assuming error status");
+      media->status = GST_RTSP_MEDIA_STATUS_ERROR;
+    }
   }
   /* could be success or error */
   result = media->status;