webrtcbin: Make sure PC_LOCK is release when replying to promise
authorOlivier Crête <olivier.crete@collabora.com>
Thu, 1 Apr 2021 18:41:11 +0000 (14:41 -0400)
committerOlivier Crête <olivier.crete@collabora.com>
Mon, 12 Apr 2021 22:37:27 +0000 (18:37 -0400)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2104>

ext/webrtc/gstwebrtcbin.c

index 3041294..4b28a10 100644 (file)
@@ -759,6 +759,8 @@ _execute_op (GstWebRTCBinTask * op)
 {
   PC_LOCK (op->webrtc);
   if (op->webrtc->priv->is_closed) {
+    PC_UNLOCK (op->webrtc);
+
     if (op->promise) {
       GError *error =
           g_error_new (GST_WEBRTC_BIN_ERROR, GST_WEBRTC_BIN_ERROR_CLOSED,
@@ -778,8 +780,9 @@ _execute_op (GstWebRTCBinTask * op)
 
   op->op (op->webrtc, op->data);
 
-out:
   PC_UNLOCK (op->webrtc);
+
+out:
   return G_SOURCE_REMOVE;
 }
 
@@ -5462,11 +5465,16 @@ _free_get_stats (struct get_stats *stats)
 static void
 _get_stats_task (GstWebRTCBin * webrtc, struct get_stats *stats)
 {
+  GstStructure *s;
   /* Our selector is the pad,
    * https://www.w3.org/TR/webrtc/#dfn-stats-selection-algorithm
    */
-  gst_promise_reply (stats->promise, gst_webrtc_bin_create_stats (webrtc,
-          stats->pad));
+
+  s = gst_webrtc_bin_create_stats (webrtc, stats->pad);
+
+  PC_UNLOCK (webrtc);
+  gst_promise_reply (stats->promise, s);
+  PC_LOCK (webrtc);
 }
 
 static void