[gst-cvs] gst-plugins-bad: resindvd: Remove extra new-segment in rsnstreamselector. Send discont.

Jan Schmidt thaytan at kemper.freedesktop.org
Tue Oct 27 05:24:04 PDT 2009


Module: gst-plugins-bad
Branch: master
Commit: 4a394cd8cfa7f99a7a2d025eddd8d5a7f7b08c5d
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/commit/?id=4a394cd8cfa7f99a7a2d025eddd8d5a7f7b08c5d

Author: Jan Schmidt <thaytan at noraisin.net>
Date:   Tue Oct 27 00:22:42 2009 +0000

resindvd: Remove extra new-segment in rsnstreamselector. Send discont.

All the input pads for the resin stream selectors have the same source,
and receive/send the same segment info, so there's no need to send a
segment when switching and activating a different pad. Removing it makes
on-the-fly audio track switching work properly.

After switching audio track, mark the next buffer discont.

---

 ext/resindvd/rsnstreamselector.c |   23 ++++++++++++-----------
 ext/resindvd/rsnstreamselector.h |    1 +
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/ext/resindvd/rsnstreamselector.c b/ext/resindvd/rsnstreamselector.c
index 30c29a4..6171c68 100644
--- a/ext/resindvd/rsnstreamselector.c
+++ b/ext/resindvd/rsnstreamselector.c
@@ -92,7 +92,6 @@ struct _RsnSelectorPad
 
   gboolean active;
   gboolean eos;
-  gboolean segment_pending;
   GstSegment segment;
   GstTagList *tags;
 };
@@ -270,10 +269,6 @@ gst_selector_pad_event (GstPad * pad, GstEvent * event)
 
       gst_segment_set_newsegment_full (&selpad->segment, update,
           rate, arate, format, start, stop, time);
-      /* if we are not going to forward the segment, mark the segment as
-       * pending */
-      if (!forward)
-        selpad->segment_pending = TRUE;
       break;
     }
     case GST_EVENT_TAG:
@@ -388,6 +383,7 @@ gst_selector_pad_chain (GstPad * pad, GstBuffer * buf)
   RsnSelectorPad *selpad;
   GstClockTime timestamp;
   GstSegment *seg;
+  gboolean discont;
 
   sel = RSN_STREAM_SELECTOR (gst_pad_get_parent (pad));
   selpad = GST_SELECTOR_PAD_CAST (pad);
@@ -406,13 +402,16 @@ gst_selector_pad_chain (GstPad * pad, GstBuffer * buf)
   if (pad != active_sinkpad)
     goto ignore;
 
-  /* if we have a pending segment, push it out now */
-  if (selpad->segment_pending) {
-    gst_pad_push_event (sel->srcpad, gst_event_new_new_segment_full (FALSE,
-            seg->rate, seg->applied_rate, seg->format, seg->start, seg->stop,
-            seg->time));
+  /* If we just switched pads, mark a discont buffer */
+  GST_OBJECT_LOCK (sel);
+  discont = sel->mark_discont;
+  sel->mark_discont = FALSE;
+  GST_OBJECT_UNLOCK (sel);
 
-    selpad->segment_pending = FALSE;
+  if (discont) {
+    GST_DEBUG_OBJECT (sel, "Marking buffer discont due to pad switch");
+    buf = gst_buffer_make_metadata_writable (buf);
+    GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT);
   }
 
   /* forward */
@@ -711,6 +710,8 @@ rsn_stream_selector_set_active (RsnStreamSelector * sel, GstPad * pad)
       GST_DEBUG_OBJECT (sel, "New active pad is %" GST_PTR_FORMAT,
           sel->active_sinkpad);
     }
+    /* Mark the next buffer as discontinuous */
+    sel->mark_discont = TRUE;
   }
   GST_OBJECT_UNLOCK (GST_OBJECT_CAST (sel));
 }
diff --git a/ext/resindvd/rsnstreamselector.h b/ext/resindvd/rsnstreamselector.h
index aa51699..a8ff1af 100644
--- a/ext/resindvd/rsnstreamselector.h
+++ b/ext/resindvd/rsnstreamselector.h
@@ -49,6 +49,7 @@ struct _RsnStreamSelector {
   guint padcount;
 
   GstSegment segment;
+  gboolean mark_discont;
 };
 
 struct _RsnStreamSelectorClass {





More information about the Gstreamer-commits mailing list