pad: Print debug output from gst_pad_link_full() if preparing linking failed
[platform/upstream/gstreamer.git] / gst / gstpad.c
index 32d6756..b762465 100644 (file)
@@ -2355,8 +2355,12 @@ gst_pad_link_full (GstPad * srcpad, GstPad * sinkpad, GstPadLinkCheck flags)
   /* prepare will also lock the two pads */
   result = gst_pad_link_prepare (srcpad, sinkpad, flags);
 
-  if (G_UNLIKELY (result != GST_PAD_LINK_OK))
+  if (G_UNLIKELY (result != GST_PAD_LINK_OK)) {
+    GST_CAT_INFO (GST_CAT_PADS, "link between %s:%s and %s:%s failed: %s",
+        GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad),
+        gst_pad_link_get_name (result));
     goto done;
+  }
 
   /* must set peers before calling the link function */
   GST_PAD_PEER (srcpad) = sinkpad;
@@ -2884,7 +2888,7 @@ event_forward_func (GstPad * pad, EventData * data)
  * The EOS event will pause the task associated with @pad before it is forwarded
  * to all internally linked pads,
  *
- * The the event is sent to all pads internally linked to @pad. This function
+ * The event is sent to all pads internally linked to @pad. This function
  * takes ownership of @event.
  *
  * Returns: %TRUE if the event was sent successfully.
@@ -3061,13 +3065,19 @@ static gboolean
 query_latency_default_fold (const GValue * item, GValue * ret,
     gpointer user_data)
 {
-  GstPad *pad = g_value_get_object (item);
+  GstPad *pad = g_value_get_object (item), *peer;
   LatencyFoldData *fold_data = user_data;
   GstQuery *query;
-  gboolean res;
+  gboolean res = FALSE;
 
   query = gst_query_new_latency ();
-  res = gst_pad_peer_query (pad, query);
+
+  peer = gst_pad_get_peer (pad);
+  if (peer) {
+    res = gst_pad_peer_query (pad, query);
+  } else {
+    GST_LOG_OBJECT (pad, "No peer pad found, ignoring this pad");
+  }
 
   if (res) {
     gboolean live;
@@ -3089,9 +3099,14 @@ query_latency_default_fold (const GValue * item, GValue * ret,
 
       fold_data->live = TRUE;
     }
-    g_value_set_boolean (ret, TRUE);
+  } else if (peer) {
+    GST_DEBUG_OBJECT (pad, "latency query failed");
+    g_value_set_boolean (ret, FALSE);
   }
+
   gst_query_unref (query);
+  if (peer)
+    gst_object_unref (peer);
 
   return TRUE;
 }
@@ -3111,13 +3126,14 @@ gst_pad_query_latency_default (GstPad * pad, GstQuery * query)
     return FALSE;
   }
 
+  g_value_init (&ret, G_TYPE_BOOLEAN);
+
 retry:
   fold_data.live = FALSE;
   fold_data.min = 0;
   fold_data.max = GST_CLOCK_TIME_NONE;
 
-  g_value_init (&ret, G_TYPE_BOOLEAN);
-  g_value_set_boolean (&ret, FALSE);
+  g_value_set_boolean (&ret, TRUE);
   res = gst_iterator_fold (it, query_latency_default_fold, &ret, &fold_data);
   switch (res) {
     case GST_ITERATOR_OK:
@@ -3258,6 +3274,7 @@ probe_hook_marshal (GHook * hook, ProbeMarshall * data)
   GstPadProbeType type, flags;
   GstPadProbeCallback callback;
   GstPadProbeReturn ret;
+  gpointer original_data;
 
   /* if we have called this callback, do nothing */
   if (PROBE_COOKIE (hook) == data->cookie) {
@@ -3271,6 +3288,7 @@ probe_hook_marshal (GHook * hook, ProbeMarshall * data)
 
   flags = hook->flags >> G_HOOK_FLAG_USER_SHIFT;
   type = info->type;
+  original_data = info->data;
 
   /* one of the data types for non-idle probes */
   if ((type & GST_PAD_PROBE_TYPE_IDLE) == 0
@@ -3309,6 +3327,12 @@ probe_hook_marshal (GHook * hook, ProbeMarshall * data)
 
   GST_OBJECT_LOCK (pad);
 
+  if (original_data != NULL && info->data == NULL) {
+    GST_DEBUG_OBJECT (pad, "data item in pad probe info was dropped");
+    info->type = GST_PAD_PROBE_TYPE_INVALID;
+    data->dropped = TRUE;
+  }
+
   switch (ret) {
     case GST_PAD_PROBE_REMOVE:
       /* remove the probe */
@@ -4087,7 +4111,7 @@ gst_pad_chain_list_default (GstPad * pad, GstObject * parent,
   GstBuffer *buffer;
   GstFlowReturn ret;
 
-  GST_INFO_OBJECT (pad, "chaining each group in list as a merged buffer");
+  GST_INFO_OBJECT (pad, "chaining each buffer in list individually");
 
   len = gst_buffer_list_length (list);
 
@@ -4253,7 +4277,8 @@ probe_stopped:
     GST_OBJECT_UNLOCK (pad);
     pad->ABI.abi.last_flowret =
         ret == GST_FLOW_CUSTOM_SUCCESS ? GST_FLOW_OK : ret;
-    gst_mini_object_unref (GST_MINI_OBJECT_CAST (data));
+    if (data != NULL)
+      gst_mini_object_unref (GST_MINI_OBJECT_CAST (data));
 
     switch (ret) {
       case GST_FLOW_CUSTOM_SUCCESS: