diff options
author | Lasse Laukkanen <ext-lasse.2.laukkanen@nokia.com> | 2009-06-01 16:31:42 +0300 |
---|---|---|
committer | Stefan Kost <ensonic@users.sf.net> | 2009-06-05 10:00:38 +0300 |
commit | d8013c1b76acdafd86af5aed7e176d73c881daf9 (patch) | |
tree | 0a064c9b01cfdf7823c4006edf8959e3c95049bc | |
parent | 97ccdf9460549c04c2db5a6fae6633fa7d99c740 (diff) | |
download | gst-plugins-bad-d8013c1b76acdafd86af5aed7e176d73c881daf9.tar.gz gst-plugins-bad-d8013c1b76acdafd86af5aed7e176d73c881daf9.tar.bz2 gst-plugins-bad-d8013c1b76acdafd86af5aed7e176d73c881daf9.zip |
output-selector: serialize setting and actual changing of new active pad
-rw-r--r-- | gst/selector/gstoutputselector.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/gst/selector/gstoutputselector.c b/gst/selector/gstoutputselector.c index 5635ab78..6e93a0a4 100644 --- a/gst/selector/gstoutputselector.c +++ b/gst/selector/gstoutputselector.c @@ -330,14 +330,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 +359,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; } @@ -393,7 +396,7 @@ gst_output_selector_chain (GstPad * pad, GstBuffer * buf) gst_buffer_unref (osel->latest_buffer); 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); |