diff options
author | Wim Taymans <wim.taymans@collabora.co.uk> | 2012-07-20 13:12:44 +0200 |
---|---|---|
committer | Wim Taymans <wim.taymans@collabora.co.uk> | 2012-07-20 15:39:18 +0200 |
commit | e652109b81c202db36a37973b24b46736c796a8d (patch) | |
tree | f9c705db382f7f59a37458c037c4ec06c78c82ce | |
parent | 8137d201a80c24fc5daca88005a119a089152f29 (diff) |
interleave: try to fix segment handling
-rw-r--r-- | gst/interleave/interleave.c | 59 | ||||
-rw-r--r-- | gst/interleave/interleave.h | 5 |
2 files changed, 32 insertions, 32 deletions
diff --git a/gst/interleave/interleave.c b/gst/interleave/interleave.c index 262fe83a8..09a9e0c98 100644 --- a/gst/interleave/interleave.c +++ b/gst/interleave/interleave.c @@ -623,10 +623,7 @@ gst_interleave_change_state (GstElement * element, GstStateChange transition) case GST_STATE_CHANGE_READY_TO_PAUSED: self->timestamp = 0; self->offset = 0; - self->segment_pending = TRUE; - self->segment_position = 0; - self->segment_rate = 1.0; - gst_segment_init (&self->segment, GST_FORMAT_UNDEFINED); + gst_event_replace (&self->pending_segment, NULL); gst_collect_pads2_start (self->collect); break; case GST_STATE_CHANGE_PAUSED_TO_PLAYING: @@ -650,6 +647,7 @@ gst_interleave_change_state (GstElement * element, GstStateChange transition) case GST_STATE_CHANGE_PAUSED_TO_READY: gst_pad_set_caps (self->src, NULL); gst_caps_replace (&self->sinkcaps, NULL); + gst_event_replace (&self->pending_segment, NULL); break; case GST_STATE_CHANGE_READY_TO_NULL: break; @@ -876,7 +874,14 @@ gst_interleave_sink_event (GstPad * pad, GstEvent * event) * assume the collectpads forwarded the FLUSH_STOP past us * and downstream (using our source pad, the bastard!). */ - self->segment_pending = TRUE; + GST_OBJECT_LOCK (self); + gst_event_replace (&self->pending_segment, NULL); + GST_OBJECT_UNLOCK (self); + break; + case GST_EVENT_NEWSEGMENT: + GST_OBJECT_LOCK (self); + gst_event_replace (&self->pending_segment, event); + GST_OBJECT_UNLOCK (self); break; default: break; @@ -1153,12 +1158,8 @@ gst_interleave_src_event (GstPad * pad, GstEvent * event) case GST_EVENT_SEEK: { GstSeekFlags flags; - GstSeekType curtype; - gint64 cur; - /* parse the seek parameters */ - gst_event_parse_seek (event, &self->segment_rate, NULL, &flags, &curtype, - &cur, NULL, NULL); + gst_event_parse_seek (event, NULL, NULL, &flags, NULL, NULL, NULL, NULL); /* check if we are flushing */ if (flags & GST_SEEK_FLAG_FLUSH) { @@ -1169,17 +1170,6 @@ gst_interleave_src_event (GstPad * pad, GstEvent * event) * when all pads received a FLUSH_STOP. */ gst_pad_push_event (self->src, gst_event_new_flush_start ()); } - - /* now wait for the collected to be finished and mark a new - * segment */ - GST_OBJECT_LOCK (self->collect); - if (curtype == GST_SEEK_TYPE_SET) - self->segment_position = cur; - else - self->segment_position = 0; - self->segment_pending = TRUE; - GST_OBJECT_UNLOCK (self->collect); - result = forward_event (self, event); break; } @@ -1208,6 +1198,7 @@ gst_interleave_collected (GstCollectPads2 * pads, GstInterleave * self) guint ncollected = 0; gboolean empty = TRUE; gint width = self->width / 8; + GstClockTime timestamp = -1; size = gst_collect_pads2_available (pads); if (size == 0) @@ -1256,6 +1247,9 @@ gst_interleave_collected (GstCollectPads2 * pads, GstInterleave * self) } ncollected++; + if (timestamp == -1) + timestamp = GST_BUFFER_TIMESTAMP (inbuf); + if (GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_GAP)) goto next; @@ -1274,15 +1268,24 @@ gst_interleave_collected (GstCollectPads2 * pads, GstInterleave * self) if (ncollected == 0) goto eos; - if (self->segment_pending) { + GST_OBJECT_LOCK (self); + if (self->pending_segment) { GstEvent *event; - event = gst_event_new_new_segment_full (FALSE, self->segment_rate, - 1.0, GST_FORMAT_TIME, self->timestamp, -1, self->segment_position); + event = self->pending_segment; + self->pending_segment = NULL; + GST_OBJECT_UNLOCK (self); gst_pad_push_event (self->src, event); - self->segment_pending = FALSE; - self->segment_position = 0; + + GST_OBJECT_LOCK (self); + } + GST_OBJECT_UNLOCK (self); + + if (timestamp != -1) { + self->offset = gst_util_uint64_scale_int (timestamp, self->rate, + GST_SECOND); + self->timestamp = timestamp; } GST_BUFFER_TIMESTAMP (outbuf) = self->timestamp; @@ -1292,8 +1295,8 @@ gst_interleave_collected (GstCollectPads2 * pads, GstInterleave * self) self->timestamp = gst_util_uint64_scale_int (self->offset, GST_SECOND, self->rate); - GST_BUFFER_DURATION (outbuf) = self->timestamp - - GST_BUFFER_TIMESTAMP (outbuf); + GST_BUFFER_DURATION (outbuf) = + self->timestamp - GST_BUFFER_TIMESTAMP (outbuf); if (empty) GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_GAP); diff --git a/gst/interleave/interleave.h b/gst/interleave/interleave.h index abe3439e4..5c6bf6b29 100644 --- a/gst/interleave/interleave.h +++ b/gst/interleave/interleave.h @@ -65,10 +65,7 @@ struct _GstInterleave GstClockTime timestamp; guint64 offset; - gboolean segment_pending; - guint64 segment_position; - gdouble segment_rate; - GstSegment segment; + GstEvent *pending_segment; GstPadEventFunction collect_event; |