summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleix Conchillo FlaquƩ <aleix@oblong.com>2018-10-05 12:10:06 -0700
committerMatthew Waters <matthew@centricular.com>2018-10-08 13:46:55 +1100
commitc4fe52395b21b54fd6ee6b9a5010737404889242 (patch)
tree42477d4317362bcef311fbb8f25977a5ae241c6a
parentd5da9e080aae464a110834fcae55c5a7e39a21c5 (diff)
webrtcbin: start and stop thread when changing state
It might be possible that if we set webrtcbin to the NULL state some tasks (idle sources) are still executed and they might even freeze. The freeze is caused because the webrtcbin tasks don't hold a reference to webrtcbin and if it's last unref inside the idle source itself this will not allow the main loop to finish because the main loop is waiting on the idle source to finish. We now start and stop webrtcbin thread when changing states. This will allow the idle sources to finish properly. https://bugzilla.gnome.org/show_bug.cgi?id=797251
-rw-r--r--ext/webrtc/gstwebrtcbin.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/ext/webrtc/gstwebrtcbin.c b/ext/webrtc/gstwebrtcbin.c
index 60614b829..d7c1d479b 100644
--- a/ext/webrtc/gstwebrtcbin.c
+++ b/ext/webrtc/gstwebrtcbin.c
@@ -4476,6 +4476,7 @@ gst_webrtc_bin_change_state (GstElement * element, GstStateChange transition)
case GST_STATE_CHANGE_NULL_TO_READY:{
if (!_have_nice_elements (webrtc) || !_have_dtls_elements (webrtc))
return GST_STATE_CHANGE_FAILURE;
+ _start_thread (webrtc);
_update_need_negotiation (webrtc);
break;
}
@@ -4501,6 +4502,9 @@ gst_webrtc_bin_change_state (GstElement * element, GstStateChange transition)
case GST_STATE_CHANGE_PAUSED_TO_READY:
webrtc->priv->running = FALSE;
break;
+ case GST_STATE_CHANGE_READY_TO_NULL:
+ _stop_thread (webrtc);
+ break;
default:
break;
}
@@ -4663,8 +4667,6 @@ gst_webrtc_bin_dispose (GObject * object)
{
GstWebRTCBin *webrtc = GST_WEBRTC_BIN (object);
- _stop_thread (webrtc);
-
if (webrtc->priv->ice)
gst_object_unref (webrtc->priv->ice);
webrtc->priv->ice = NULL;
@@ -5110,8 +5112,6 @@ gst_webrtc_bin_init (GstWebRTCBin * webrtc)
g_mutex_init (PC_GET_LOCK (webrtc));
g_cond_init (PC_GET_COND (webrtc));
- _start_thread (webrtc);
-
webrtc->rtpbin = _create_rtpbin (webrtc);
gst_bin_add (GST_BIN (webrtc), webrtc->rtpbin);