From db187eec1925f3ecc6c4dbbb60d50bac95bbfa4b Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Thu, 14 Nov 2019 17:33:08 -0500 Subject: [PATCH] rtpjitterbuffer: Check the exit condition after executing timers The do_expected_timeout() function may release the JBUF_LOCK, so we need to check if nothing wanted the timer thread to exit after this call. The side effect was that we may endup going back into waiting for a timer which will cause arbitrary delay on tear down (or deadlock when test clock is used). Fixes #653 --- gst/rtpmanager/gstrtpjitterbuffer.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gst/rtpmanager/gstrtpjitterbuffer.c b/gst/rtpmanager/gstrtpjitterbuffer.c index d20207b271..cefa9259c5 100644 --- a/gst/rtpmanager/gstrtpjitterbuffer.c +++ b/gst/rtpmanager/gstrtpjitterbuffer.c @@ -4044,9 +4044,14 @@ wait_next_timeout (GstRtpJitterBuffer * jitterbuffer) } } while ((timer = rtp_timer_queue_pop_until (priv->timers, now))); - /* execetute the remaining timers */ + /* execute the remaining timers */ while ((timer = (RtpTimer *) g_queue_pop_head_link (&timers))) do_timeout (jitterbuffer, timer, now); + + /* do_expected_timeout(), called by do_timeout will drop the + * JBUF_LOCK, so we need to check if we are still running */ + if (!priv->timer_running) + goto stopping; } timer = rtp_timer_queue_peek_earliest (priv->timers);