pad: Keep an extra ref of the pad when calling an IDLE probe immediately
authorSebastian Dröge <sebastian@centricular.com>
Mon, 30 Dec 2013 18:03:22 +0000 (19:03 +0100)
committerSebastian Dröge <sebastian@centricular.com>
Tue, 31 Dec 2013 10:28:34 +0000 (11:28 +0100)
The callback might destroy the pad.

gst/gstpad.c

index e1bf71bb8cb880392d689aa704f2355d13d6c8cf..35215c7e0a4647993bbc486280757d13574e38b2 100644 (file)
@@ -1285,6 +1285,9 @@ gst_pad_add_probe (GstPad * pad, GstPadProbeType mask,
       GstPadProbeInfo info = { GST_PAD_PROBE_TYPE_IDLE, res, };
       GstPadProbeReturn ret;
 
+      /* Keep another ref, the callback could destroy the pad */
+      gst_object_ref (pad);
+
       /* the pad is idle now, we can signal the idle callback now */
       GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad,
           "pad is idle, trigger idle callback");
@@ -1314,6 +1317,8 @@ gst_pad_add_probe (GstPad * pad, GstPadProbeType mask,
           break;
       }
       GST_OBJECT_UNLOCK (pad);
+
+      gst_object_unref (pad);
     }
   } else {
     GST_OBJECT_UNLOCK (pad);