plugins/elements/gstinputselector.c: Ensure we emit notify::active-pad when auto...
authorMichael Smith <msmith@xiph.org>
Thu, 4 Dec 2008 17:51:37 +0000 (17:51 +0000)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Fri, 31 Dec 2010 00:53:48 +0000 (00:53 +0000)
Original commit message from CVS:
* plugins/elements/gstinputselector.c:
Ensure we emit notify::active-pad when auto-selecting a pad
due to it having activity and us not having an existing active
pad. Fixes #563147

plugins/elements/gstinputselector.c

index c175a5e..b55838a 100644 (file)
@@ -455,6 +455,7 @@ gst_selector_pad_bufferalloc (GstPad * pad, guint64 offset,
   GstInputSelector *sel;
   GstFlowReturn result;
   GstPad *active_sinkpad;
+  GstPad *prev_active_sinkpad;
   GstSelectorPad *selpad;
 
   sel = GST_INPUT_SELECTOR (gst_pad_get_parent (pad));
@@ -463,6 +464,7 @@ gst_selector_pad_bufferalloc (GstPad * pad, guint64 offset,
   GST_DEBUG_OBJECT (pad, "received alloc");
 
   GST_INPUT_SELECTOR_LOCK (sel);
+  prev_active_sinkpad = sel->active_sinkpad;
   active_sinkpad = gst_input_selector_activate_sinkpad (sel, pad);
 
   if (pad != active_sinkpad)
@@ -470,6 +472,9 @@ gst_selector_pad_bufferalloc (GstPad * pad, guint64 offset,
 
   GST_INPUT_SELECTOR_UNLOCK (sel);
 
+  if (prev_active_sinkpad != active_sinkpad && pad == active_sinkpad)
+    g_object_notify (G_OBJECT (sel), "active-pad");
+
   result = gst_pad_alloc_buffer (sel->srcpad, offset, size, caps, buf);
 
 done:
@@ -518,6 +523,7 @@ gst_selector_pad_chain (GstPad * pad, GstBuffer * buf)
   GstInputSelector *sel;
   GstFlowReturn res;
   GstPad *active_sinkpad;
+  GstPad *prev_active_sinkpad;
   GstSelectorPad *selpad;
   GstClockTime end_time, duration;
   GstSegment *seg;
@@ -534,6 +540,7 @@ gst_selector_pad_chain (GstPad * pad, GstBuffer * buf)
 
   GST_DEBUG_OBJECT (pad, "getting active pad");
 
+  prev_active_sinkpad = sel->active_sinkpad;
   active_sinkpad = gst_input_selector_activate_sinkpad (sel, pad);
 
   /* update the segment on the srcpad */
@@ -586,6 +593,9 @@ gst_selector_pad_chain (GstPad * pad, GstBuffer * buf)
   }
   GST_INPUT_SELECTOR_UNLOCK (sel);
 
+  if (prev_active_sinkpad != active_sinkpad && pad == active_sinkpad)
+    g_object_notify (G_OBJECT (sel), "active-pad");
+
   if (close_event)
     gst_pad_push_event (sel->srcpad, close_event);
 
@@ -912,6 +922,7 @@ gst_input_selector_set_active_pad (GstInputSelector * self,
     /* schedule a last_stop update if one isn't already scheduled, and a
        segment has been pushed before. */
     memcpy (&self->segment, &old->segment, sizeof (self->segment));
+
     GST_DEBUG_OBJECT (self, "setting stop_time to %" G_GINT64_FORMAT,
         stop_time);
     gst_segment_set_stop (&self->segment, stop_time);