rtpsession: mt-safe event-push
authorIdar Tollefsen <itollefs@cisco.com>
Mon, 17 Oct 2011 21:45:37 +0000 (23:45 +0200)
committerOlivier CrĂȘte <olivier.crete@collabora.com>
Mon, 28 Jan 2013 22:34:50 +0000 (17:34 -0500)
By taking a ref of the sink-pad under lock, it won't dissappear
while the push is taking place

https://bugzilla.gnome.org/show_bug.cgi?id=667816

gst/rtpmanager/gstrtpsession.c

index 88e76a6c679598da4938c903e88b32448ddbc941..78007f5b8b2b6af2ec764f61108b7273a0983f4c 100644 (file)
@@ -2212,10 +2212,18 @@ gst_rtp_session_request_key_unit (RTPSession * sess,
   GstRtpSession *rtpsession = GST_RTP_SESSION (user_data);
   GstEvent *event;
 
-  event = gst_event_new_custom (GST_EVENT_CUSTOM_UPSTREAM,
-      gst_structure_new ("GstForceKeyUnit",
-          "all-headers", G_TYPE_BOOLEAN, all_headers, NULL));
-  gst_pad_push_event (rtpsession->send_rtp_sink, event);
+  GST_RTP_SESSION_LOCK (rtpsession);
+  if (rtpsession->send_rtp_sink)
+    send_rtp_sink = gst_object_ref (rtpsession->send_rtp_sink);
+  GST_RTP_SESSION_UNLOCK (rtpsession);
+
+  if (send_rtp_sink) {
+    GstEvent *event = gst_event_new_custom (GST_EVENT_CUSTOM_UPSTREAM,
+        gst_structure_new ("GstForceKeyUnit",
+            "all-headers", G_TYPE_BOOLEAN, all_headers, NULL));
+    gst_pad_push_event (send_rtp_sink, event);
+    gst_object_unref (send_rtp_sink);
+  }
 }
 
 static GstClockTime