rtsp-server: media: First set state to PLAYING again temporarily, then send EOS
authorSebastian Dröge <sebastian@centricular.com>
Tue, 4 Apr 2023 17:03:31 +0000 (20:03 +0300)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 5 Apr 2023 13:17:16 +0000 (13:17 +0000)
Sending the EOS event while the pipeline is PAUSED can deadlock on the
stream lock if a sink is currently blocked because of pre-rolling.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4345>

subprojects/gst-rtsp-server/gst/rtsp-server/rtsp-media.c

index b5c300d..8c62b0d 100644 (file)
@@ -4102,12 +4102,12 @@ default_unprepare (GstRTSPMedia * media)
   gst_rtsp_media_set_status (media, GST_RTSP_MEDIA_STATUS_UNPREPARING);
 
   if (priv->eos_shutdown) {
-    GST_DEBUG ("sending EOS for shutdown");
-    /* ref so that we don't disappear */
-    gst_element_send_event (priv->pipeline, gst_event_new_eos ());
     /* we need to go to playing again for the EOS to propagate, normally in this
      * state, nothing is receiving data from us anymore so this is ok. */
+    GST_DEBUG ("Temporarily go to PLAYING again for sending EOS");
     set_state (media, GST_STATE_PLAYING);
+    GST_DEBUG ("sending EOS for shutdown");
+    gst_element_send_event (priv->pipeline, gst_event_new_eos ());
   } else {
     finish_unprepare (media);
   }