From 283e4e4afdf7c5a6b2a93ee95d6b3de0aebf1120 Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Wed, 6 Apr 2011 15:51:49 +0200 Subject: [PATCH] rtspsrc: ensure proper closing and cleanup ... since the TEARDOWN sequence might not have had a chance to even start, but at least connections should be closed (synchronously) and state cleaned up. See #632504. --- gst/rtsp/gstrtspsrc.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/gst/rtsp/gstrtspsrc.c b/gst/rtsp/gstrtspsrc.c index 82743147fa..46996c9087 100644 --- a/gst/rtsp/gstrtspsrc.c +++ b/gst/rtsp/gstrtspsrc.c @@ -251,7 +251,8 @@ static GstRTSPResult gst_rtspsrc_play (GstRTSPSrc * src, GstSegment * segment, gboolean async); static GstRTSPResult gst_rtspsrc_pause (GstRTSPSrc * src, gboolean idle, gboolean async); -static GstRTSPResult gst_rtspsrc_close (GstRTSPSrc * src, gboolean async); +static GstRTSPResult gst_rtspsrc_close (GstRTSPSrc * src, gboolean async, + gboolean only_close); static gboolean gst_rtspsrc_uri_set_uri (GstURIHandler * handler, const gchar * uri); @@ -3927,7 +3928,7 @@ gst_rtspsrc_reconnect (GstRTSPSrc * src, gboolean async) src->cur_protocols = GST_RTSP_LOWER_TRANS_TCP; /* close and cleanup our state */ - if ((res = gst_rtspsrc_close (src, async)) < 0) + if ((res = gst_rtspsrc_close (src, async, FALSE)) < 0) goto done; /* see if we have TCP left to try. Also don't try TCP when we were configured @@ -5724,7 +5725,7 @@ open_failed: } static GstRTSPResult -gst_rtspsrc_close (GstRTSPSrc * src, gboolean async) +gst_rtspsrc_close (GstRTSPSrc * src, gboolean async, gboolean only_close) { GstRTSPMessage request = { 0 }; GstRTSPMessage response = { 0 }; @@ -5739,6 +5740,9 @@ gst_rtspsrc_close (GstRTSPSrc * src, gboolean async) goto close; } + if (only_close) + goto close; + /* construct a control url */ if (src->control) control = src->control; @@ -6426,7 +6430,7 @@ gst_rtspsrc_thread (GstRTSPSrc * src) running = TRUE; break; case CMD_CLOSE: - ret = gst_rtspsrc_close (src, TRUE); + ret = gst_rtspsrc_close (src, TRUE, FALSE); break; case CMD_LOOP: running = gst_rtspsrc_loop (src); @@ -6510,6 +6514,9 @@ gst_rtspsrc_stop (GstRTSPSrc * src) } GST_OBJECT_UNLOCK (src); + /* ensure synchronously all is closed and clean */ + gst_rtspsrc_close (src, FALSE, TRUE); + return TRUE; }