plugins/elements/gsttee.c: Always prefer an actual return value from a src pad in...
authorJan Schmidt <thaytan@mad.scientist.com>
Fri, 27 Jan 2006 16:59:57 +0000 (16:59 +0000)
committerJan Schmidt <thaytan@mad.scientist.com>
Fri, 27 Jan 2006 16:59:57 +0000 (16:59 +0000)
Original commit message from CVS:
* plugins/elements/gsttee.c: (gst_tee_do_push),
(gst_tee_handle_buffer):
Always prefer an actual return value from a src
pad in place of NOT_LINKED. This means we return
WRONG_STATE when all src pads are WRONG_STATE
instead of NOT_LINKED.

Lock when replacing the last message to prevent
racing with the get_property method.

Add debug output

ChangeLog
plugins/elements/gsttee.c

index 3cacb55..3ec9974 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 2006-01-27  Jan Schmidt  <thaytan@mad.scientist.com>
 
+       * plugins/elements/gsttee.c: (gst_tee_do_push),
+       (gst_tee_handle_buffer):
+       Always prefer an actual return value from a src
+       pad in place of NOT_LINKED. This means we return
+       WRONG_STATE when all src pads are WRONG_STATE
+       instead of NOT_LINKED.
+
+       Lock when replacing the last message to prevent
+       racing with the get_property method.
+
+       Add debug output
+
+2006-01-27  Jan Schmidt  <thaytan@mad.scientist.com>
+
        * tests/check/Makefile.am:
        * tests/check/gst/gstquery.c: (GST_START_TEST), (gstquery_suite),
        (main):
index e10e08a..5632a42 100644 (file)
@@ -265,24 +265,32 @@ static gboolean
 gst_tee_do_push (GstPad * pad, GValue * ret, PushData * data)
 {
   GstFlowReturn res;
+  GstTee *tee = data->tee;
 
   if (G_UNLIKELY (!data->tee->silent)) {
-    GstTee *tee = data->tee;
     GstBuffer *buf = data->buffer;
 
+    GST_OBJECT_LOCK (tee);
     g_free (tee->last_message);
     tee->last_message =
         g_strdup_printf ("chain        ******* (%s:%s)t (%d bytes, %"
         G_GUINT64_FORMAT ") %p", GST_DEBUG_PAD_NAME (pad),
         GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf), buf);
+    GST_OBJECT_UNLOCK (tee);
     g_object_notify (G_OBJECT (tee), "last_message");
   }
 
   /* Push */
   res = gst_pad_push (pad, gst_buffer_ref (data->buffer));
-
-  /* If it's fatal or OK we overwrite the previous value */
-  if (GST_FLOW_IS_FATAL (res) || (res == GST_FLOW_OK)) {
+  GST_LOG_OBJECT (tee, "Pushing buffer %p to %" GST_PTR_FORMAT
+      " yielded result=%d", data->buffer, pad, res);
+
+  /* If it's fatal or OK, or if ret is currently
+   * not-linked, we overwrite the previous value */
+  if (GST_FLOW_IS_FATAL (res) || (res == GST_FLOW_OK) ||
+      (g_value_get_enum (ret) == GST_FLOW_NOT_LINKED)) {
+    GST_LOG_OBJECT (tee, "Replacing ret val %d with %d",
+        g_value_get_enum (ret), res);
     g_value_set_enum (ret, res);
   }
 
@@ -308,10 +316,16 @@ gst_tee_handle_buffer (GstTee * tee, GstBuffer * buffer)
   data.tee = tee;
   data.buffer = buffer;
 
+  GST_LOG_OBJECT (tee, "Starting to push buffer %p", buffer);
+  /* FIXME: Not sure how tee would handle RESEND buffer from some of the
+   * pads but not from others. */
   res = gst_iterator_fold (iter, (GstIteratorFoldFunction) gst_tee_do_push,
       &ret, &data);
   gst_iterator_free (iter);
 
+  GST_LOG_OBJECT (tee, "Pushing buffer %p yielded result=%d", buffer,
+      g_value_get_enum (&ret));
+
   gst_buffer_unref (buffer);
 
   /* no need to unset gvalue */