media: limit the time to wait to something huge

Avoid waiting forever but limit the timeout to 20 seconds.
This commit is contained in:
Wim Taymans 2010-03-05 18:23:18 +01:00
parent f90c422e62
commit 83ed258684

View file

@ -1115,12 +1115,18 @@ static GstRTSPMediaStatus
gst_rtsp_media_get_status (GstRTSPMedia *media) gst_rtsp_media_get_status (GstRTSPMedia *media)
{ {
GstRTSPMediaStatus result; GstRTSPMediaStatus result;
GTimeVal timeout;
g_mutex_lock (media->lock); 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 we are preparing, wait */
while (media->status == GST_RTSP_MEDIA_STATUS_PREPARING) { while (media->status == GST_RTSP_MEDIA_STATUS_PREPARING) {
GST_DEBUG ("waiting for status change"); 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 */ /* could be success or error */
result = media->status; result = media->status;