diff options
author | Dave Robillard <dave@drobilla.net> | 2009-06-19 21:01:54 -0400 |
---|---|---|
committer | Dave Robillard <dave@drobilla.net> | 2009-06-19 21:01:54 -0400 |
commit | 925e83ee60c5406b2e5f0f39b0da0f90370efc27 (patch) | |
tree | ce01d298ed0c5d31853fa43aedc2af0779417816 /gst/selector | |
parent | 7f3bcd484b465d8216ac419754450adf07e9b0d2 (diff) | |
parent | c70dbe94b5ff9a0993d852605d40c21020c59552 (diff) | |
download | gst-plugins-bad-925e83ee60c5406b2e5f0f39b0da0f90370efc27.tar.gz gst-plugins-bad-925e83ee60c5406b2e5f0f39b0da0f90370efc27.tar.bz2 gst-plugins-bad-925e83ee60c5406b2e5f0f39b0da0f90370efc27.zip |
Merge branch 'master' of git://anongit.freedesktop.org/gstreamer/gst-plugins-bad into fdo
Diffstat (limited to 'gst/selector')
-rw-r--r-- | gst/selector/gstinputselector.c | 3 | ||||
-rw-r--r-- | gst/selector/gstoutputselector.c | 51 |
2 files changed, 36 insertions, 18 deletions
diff --git a/gst/selector/gstinputselector.c b/gst/selector/gstinputselector.c index 08d3d497..832707d0 100644 --- a/gst/selector/gstinputselector.c +++ b/gst/selector/gstinputselector.c @@ -420,6 +420,8 @@ gst_selector_pad_event (GstPad * pad, GstEvent * event) gst_tag_list_free (oldtags); GST_DEBUG_OBJECT (pad, "received tags %" GST_PTR_FORMAT, newtags); GST_OBJECT_UNLOCK (selpad); + + g_object_notify (G_OBJECT (selpad), "tags"); break; } case GST_EVENT_EOS: @@ -1415,6 +1417,7 @@ gst_input_selector_check_eos (GstElement * selector) if (!pad->eos) { done = TRUE; } + gst_object_unref (pad); break; case GST_ITERATOR_RESYNC: gst_iterator_resync (it); diff --git a/gst/selector/gstoutputselector.c b/gst/selector/gstoutputselector.c index bf354a74..15c0a726 100644 --- a/gst/selector/gstoutputselector.c +++ b/gst/selector/gstoutputselector.c @@ -196,7 +196,7 @@ gst_output_selector_set_property (GObject * object, guint prop_id, next_pad = g_value_get_object (value); - GST_LOG_OBJECT (sel, "Activating pad %s:%s", + GST_INFO_OBJECT (sel, "Activating pad %s:%s", GST_DEBUG_PAD_NAME (next_pad)); GST_OBJECT_LOCK (object); @@ -262,11 +262,11 @@ gst_output_selector_buffer_alloc (GstPad * pad, guint64 offset, guint size, GstPad *allocpad; sel = GST_OUTPUT_SELECTOR (GST_PAD_PARENT (pad)); - res = GST_FLOW_NOT_LINKED; GST_OBJECT_LOCK (sel); - if ((allocpad = sel->active_srcpad)) { + allocpad = sel->pending_srcpad ? sel->pending_srcpad : sel->active_srcpad; + if (allocpad) { /* if we had a previous pad we used for allocating a buffer, continue using * it. */ GST_DEBUG_OBJECT (sel, "using pad %s:%s for alloc", @@ -278,9 +278,16 @@ gst_output_selector_buffer_alloc (GstPad * pad, guint64 offset, guint size, gst_object_unref (allocpad); GST_OBJECT_LOCK (sel); + } else { + /* fallback case, allocate a buffer of our own, add pad caps. */ + GST_DEBUG_OBJECT (pad, "fallback buffer alloc"); + *buf = NULL; + res = GST_FLOW_OK; } GST_OBJECT_UNLOCK (sel); + GST_DEBUG_OBJECT (sel, "buffer alloc finished: %s", gst_flow_get_name (res)); + return res; } @@ -330,14 +337,24 @@ gst_output_selector_release_pad (GstElement * element, GstPad * pad) static gboolean gst_output_selector_switch (GstOutputSelector * osel) { - gboolean res = TRUE; + gboolean res = FALSE; GstEvent *ev = NULL; GstSegment *seg = NULL; gint64 start = 0, position = 0; + /* Switch */ + GST_OBJECT_LOCK (GST_OBJECT (osel)); GST_INFO ("switching to pad %" GST_PTR_FORMAT, osel->pending_srcpad); - if (gst_pad_is_linked (osel->pending_srcpad)) { + osel->active_srcpad = osel->pending_srcpad; + res = TRUE; + } + gst_object_unref (osel->pending_srcpad); + osel->pending_srcpad = NULL; + GST_OBJECT_UNLOCK (GST_OBJECT (osel)); + + /* Send NEWSEGMENT event and latest buffer if switching succeeded */ + if (res) { /* Send NEWSEGMENT to the pad we are going to switch to */ seg = &osel->segment; /* If resending then mark newsegment start and position accordingly */ @@ -349,29 +366,22 @@ gst_output_selector_switch (GstOutputSelector * osel) } ev = gst_event_new_new_segment (TRUE, seg->rate, seg->format, start, seg->stop, position); - if (!gst_pad_push_event (osel->pending_srcpad, ev)) { + if (!gst_pad_push_event (osel->active_srcpad, ev)) { GST_WARNING_OBJECT (osel, "newsegment handling failed in %" GST_PTR_FORMAT, - osel->pending_srcpad); + osel->active_srcpad); } /* Resend latest buffer to newly switched pad */ if (osel->resend_latest && osel->latest_buffer) { GST_INFO ("resending latest buffer"); - gst_pad_push (osel->pending_srcpad, osel->latest_buffer); + gst_pad_push (osel->active_srcpad, osel->latest_buffer); osel->latest_buffer = NULL; } - - /* Switch */ - osel->active_srcpad = osel->pending_srcpad; } else { GST_WARNING_OBJECT (osel, "switch failed, pad not linked"); - res = FALSE; } - gst_object_unref (osel->pending_srcpad); - osel->pending_srcpad = NULL; - return res; } @@ -389,10 +399,15 @@ gst_output_selector_chain (GstPad * pad, GstBuffer * buf) gst_output_selector_switch (osel); } - /* Keep reference to latest buffer to resend it after switch */ - if (osel->latest_buffer) + if (osel->latest_buffer) { gst_buffer_unref (osel->latest_buffer); - osel->latest_buffer = gst_buffer_ref (buf); + osel->latest_buffer = NULL; + } + + if (osel->resend_latest) { + /* Keep reference to latest buffer to resend it after switch */ + osel->latest_buffer = gst_buffer_ref (buf); + } /* Keep track of last stop and use it in NEWSEGMENT start after switching to a new src pad */ |