From b3e56e19f53ade895be2c4f21776eebbfceb44ae Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Tue, 17 Mar 2009 12:05:33 +0200 Subject: [PATCH] bin: forward segment-start like segment-done if parent is also a bin, fixes #575598. Bin collects segment-start messages and segent-done messages. it posts a segment-done message to its parent, once it has received a segment-done for each segment-start. Imho it should also send a segment-start if it receives the first segment start and if parent is !=NULL. This is needed for bins in bins, so that also higher order bins can group segment-starts and segment-dones. Right now higher order bins will post a segment-done for each segment-done received. --- gst/gstbin.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/gst/gstbin.c b/gst/gstbin.c index 16b4c579a0..20de90518a 100644 --- a/gst/gstbin.c +++ b/gst/gstbin.c @@ -2922,13 +2922,37 @@ gst_bin_handle_message_func (GstBin * bin, GstMessage * message) gst_message_unref (message); break; } - case GST_MESSAGE_SEGMENT_START: + case GST_MESSAGE_SEGMENT_START:{ + gboolean post = FALSE; + GstFormat format; + gint64 position; + + gst_message_parse_segment_start (message, &format, &position); + seqnum = gst_message_get_seqnum (message); + GST_OBJECT_LOCK (bin); + /* if this is the first segment-start, post to parent but not to the + * application */ + if (!find_message (bin, NULL, GST_MESSAGE_SEGMENT_START) && + (GST_OBJECT_PARENT (bin) != NULL)) { + post = TRUE; + } /* replace any previous segment_start message from this source * with the new segment start message */ bin_replace_message (bin, message, GST_MESSAGE_SEGMENT_START); GST_OBJECT_UNLOCK (bin); + if (post) { + tmessage = gst_message_new_segment_start (GST_OBJECT_CAST (bin), + format, position); + gst_message_set_seqnum (tmessage, seqnum); + + /* post segment start with initial format and position. */ + GST_DEBUG_OBJECT (bin, "posting SEGMENT_START (%u) bus message: %p", + seqnum, message); + gst_element_post_message (GST_ELEMENT_CAST (bin), tmessage); + } break; + } case GST_MESSAGE_SEGMENT_DONE: { gboolean post = FALSE; @@ -2957,6 +2981,8 @@ gst_bin_handle_message_func (GstBin * bin, GstMessage * message) gst_message_set_seqnum (tmessage, seqnum); /* post segment done with latest format and position. */ + GST_DEBUG_OBJECT (bin, "posting SEGMENT_DONE (%u) bus message: %p", + seqnum, message); gst_element_post_message (GST_ELEMENT_CAST (bin), tmessage); } break;