rtspsrc: ensure proper closing and cleanup
authorMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
Wed, 6 Apr 2011 13:51:49 +0000 (15:51 +0200)
committerMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
Tue, 17 May 2011 09:56:38 +0000 (11:56 +0200)
... 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

index 8274314..46996c9 100644 (file)
@@ -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;
 }