rtspsrc: Do not wait for response while flushing

Due to the may_cancel flag in GstRTSPConnection, receiving might not get
cancelled when supposed to. In this case, gst_rtsp_src_receive_response
will have to wait until timeout instead but if busy receiving RTP
data, this timeout will never occur.

With this patch, gst_rtsp_src_receive_response returns GST_RTSP_EINTR
if flushing is set to TRUE instead of continuing to receive.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/831>
This commit is contained in:
Tobias Ronge 2020-12-07 10:01:53 +01:00 committed by GStreamer Merge Bot
parent c854e6bd39
commit 706d91371c

View file

@ -5596,11 +5596,15 @@ gst_rtspsrc_loop_interleaved (GstRTSPSrc * src)
while (TRUE) { while (TRUE) {
gst_rtsp_message_unset (&message); gst_rtsp_message_unset (&message);
/* protect the connection with the connection lock so that we can see when if (src->conninfo.flushing) {
* we are finished doing server communication */ /* do not attempt to receive if flushing */
res = res = GST_RTSP_EINTR;
gst_rtspsrc_connection_receive (src, &src->conninfo, } else {
&message, src->tcp_timeout); /* 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, &src->conninfo, &message,
src->tcp_timeout);
}
switch (res) { switch (res) {
case GST_RTSP_OK: case GST_RTSP_OK:
@ -5715,8 +5719,13 @@ gst_rtspsrc_loop_udp (GstRTSPSrc * src)
/* we should continue reading the TCP socket because the server might /* we should continue reading the TCP socket because the server might
* send us requests. When the session timeout expires, we need to send a * send us requests. When the session timeout expires, we need to send a
* keep-alive request to keep the session open. */ * keep-alive request to keep the session open. */
res = gst_rtspsrc_connection_receive (src, &src->conninfo, &message, if (src->conninfo.flushing) {
timeout); /* do not attempt to receive if flushing */
res = GST_RTSP_EINTR;
} else {
res = gst_rtspsrc_connection_receive (src, &src->conninfo, &message,
timeout);
}
switch (res) { switch (res) {
case GST_RTSP_OK: case GST_RTSP_OK:
@ -6363,8 +6372,13 @@ gst_rtsp_src_receive_response (GstRTSPSrc * src, GstRTSPConnInfo * conninfo,
GstRTSPResult res; GstRTSPResult res;
next: next:
res = gst_rtspsrc_connection_receive (src, conninfo, response, if (conninfo->flushing) {
src->tcp_timeout); /* do not attempt to receive if flushing */
res = GST_RTSP_EINTR;
} else {
res = gst_rtspsrc_connection_receive (src, conninfo, response,
src->tcp_timeout);
}
if (res < 0) if (res < 0)
goto receive_error; goto receive_error;