diff options
author | Matej Knopp <matej.knopp@gmail.com> | 2014-09-27 20:10:34 +0200 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2014-10-02 10:56:03 +0300 |
commit | b5bf41a771c8e3c3a5afa2ea8049f1779a270c74 (patch) | |
tree | 5d8b3a0e4e6406f12cde43d54174668daec0ccb9 | |
parent | 5e8b4bf085180f7a4c7ae6ec0f525baeaedd4df8 (diff) |
multiqueue: update segment position on GAP events to calculate levels properly
https://bugzilla.gnome.org/show_bug.cgi?id=737498
-rw-r--r-- | plugins/elements/gstmultiqueue.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/plugins/elements/gstmultiqueue.c b/plugins/elements/gstmultiqueue.c index 9cd30f2f42..589053e693 100644 --- a/plugins/elements/gstmultiqueue.c +++ b/plugins/elements/gstmultiqueue.c @@ -1117,6 +1117,38 @@ apply_buffer (GstMultiQueue * mq, GstSingleQueue * sq, GstClockTime timestamp, gst_multi_queue_post_buffering (mq); } +static void +apply_gap (GstMultiQueue * mq, GstSingleQueue * sq, GstEvent * event, + GstSegment * segment) +{ + GstClockTime timestamp; + GstClockTime duration; + + GST_MULTI_QUEUE_MUTEX_LOCK (mq); + + gst_event_parse_gap (event, ×tamp, &duration); + + if (GST_CLOCK_TIME_IS_VALID (timestamp)) { + + if (GST_CLOCK_TIME_IS_VALID (duration)) { + timestamp += duration; + } + + segment->position = timestamp; + + if (segment == &sq->sink_segment) + sq->sink_tainted = TRUE; + else + sq->src_tainted = TRUE; + + /* calc diff with other end */ + update_time_level (mq, sq); + } + + GST_MULTI_QUEUE_MUTEX_UNLOCK (mq); + gst_multi_queue_post_buffering (mq); +} + static GstClockTime get_running_time (GstSegment * segment, GstMiniObject * object, gboolean end) { @@ -1212,6 +1244,11 @@ gst_single_queue_push_one (GstMultiQueue * mq, GstSingleQueue * sq, /* Applying the segment may have made the queue non-full again, unblock it if needed */ gst_data_queue_limits_changed (sq->queue); break; + case GST_EVENT_GAP: + apply_gap (mq, sq, event, &sq->src_segment); + /* Applying the gap may have made the queue non-full again, unblock it if needed */ + gst_data_queue_limits_changed (sq->queue); + break; default: break; } @@ -1697,7 +1734,9 @@ gst_multi_queue_sink_event (GstPad * pad, GstObject * parent, GstEvent * event) gst_single_queue_flush (mq, sq, FALSE, FALSE); goto done; + case GST_EVENT_SEGMENT: + case GST_EVENT_GAP: /* take ref because the queue will take ownership and we need the event * afterwards to update the segment */ sref = gst_event_ref (event); @@ -1759,6 +1798,9 @@ gst_multi_queue_sink_event (GstPad * pad, GstObject * parent, GstEvent * event) apply_segment (mq, sq, sref, &sq->sink_segment); gst_event_unref (sref); break; + case GST_EVENT_GAP: + apply_gap (mq, sq, sref, &sq->sink_segment); + gst_event_unref (sref); default: break; } |