From 56e63b44885808845f99fd3b6424bd9eeee8f2f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tommi=20My=C3=B6h=C3=A4nen?= Date: Mon, 22 Oct 2007 16:44:48 +0000 Subject: [PATCH] gst/rtsp/gstrtspsrc.c: Fix race when pausing a RTSP stream in interleaved. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Original commit message from CVS: Patch by: Tommi Myöhänen * gst/rtsp/gstrtspsrc.c: (gst_rtspsrc_loop_interleaved): Fix race when pausing a RTSP stream in interleaved. Fixes #475784. --- ChangeLog | 8 ++++++++ gst/rtsp/gstrtspsrc.c | 17 +++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/ChangeLog b/ChangeLog index eaed420cad..59d29a8b0a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-10-22 Wim Taymans + + Patch by: Tommi Myöhänen + + * gst/rtsp/gstrtspsrc.c: (gst_rtspsrc_loop_interleaved): + Fix race when pausing a RTSP stream in interleaved. + Fixes #475784. + 2007-10-22 Wim Taymans Patch by: Peter Kjellerstedt diff --git a/gst/rtsp/gstrtspsrc.c b/gst/rtsp/gstrtspsrc.c index 34b4358022..8a85c0b56c 100644 --- a/gst/rtsp/gstrtspsrc.c +++ b/gst/rtsp/gstrtspsrc.c @@ -2459,9 +2459,21 @@ gst_rtspsrc_loop_interleaved (GstRTSPSrc * src) GST_DEBUG_OBJECT (src, "doing receive"); + /* We need to check if playback has been paused while we have been + * doing something else in our own GstTask (e.g. pushing buffer). There + * is a slight chance that we have just received data buffer when PAUSE + * state change happens (in another thread). In this case we well be + * totally ignorant of that unless we explicitly check it here. */ + GST_RTSP_STATE_LOCK (src); + if (src->state == GST_RTSP_STATE_READY) { + /* We are looping in a paused mode */ + GST_RTSP_STATE_UNLOCK (src); + goto already_paused; + } /* protect the connection with the connection lock so that we can see when * we are finished doing server communication */ res = gst_rtspsrc_connection_receive (src, &message, src->ptcp_timeout); + GST_RTSP_STATE_UNLOCK (src); switch (res) { case GST_RTSP_OK: @@ -2634,6 +2646,11 @@ interrupt: gst_rtsp_connection_flush (src->connection, FALSE); return GST_FLOW_WRONG_STATE; } +already_paused: + { + GST_DEBUG_OBJECT (src, "got interrupted: playback already paused"); + return GST_FLOW_WRONG_STATE; + } receive_error: { gchar *str = gst_rtsp_strresult (res);