From 0b9cfcfbcd63446e2d52fcdbc40618d840d6493c Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Wed, 20 Feb 2008 15:44:33 +0000 Subject: [PATCH] plugins/elements/gstqueue.*: When dropping buffers in leaky modes, mark next buffers we sent as Original commit message from CVS: * plugins/elements/gstqueue.c: * plugins/elements/gstqueue.h: When dropping buffers in leaky modes, mark next buffers we sent as DISCONT. --- ChangeLog | 7 +++++++ plugins/elements/gstqueue.c | 16 ++++++++++++++++ plugins/elements/gstqueue.h | 2 ++ 3 files changed, 25 insertions(+) diff --git a/ChangeLog b/ChangeLog index 67a63d0..a7f8e2b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-02-20 Stefan Kost + + * plugins/elements/gstqueue.c: + * plugins/elements/gstqueue.h: + When dropping buffers in leaky modes, mark next buffers we sent as + DISCONT. + 2008-02-20 Tim-Philipp Müller * plugins/elements/gstfilesrc.c: (gst_file_src_map_region): diff --git a/plugins/elements/gstqueue.c b/plugins/elements/gstqueue.c index 5b16068..3a06a28 100644 --- a/plugins/elements/gstqueue.c +++ b/plugins/elements/gstqueue.c @@ -398,6 +398,7 @@ gst_queue_init (GstQueue * queue, GstQueueClass * g_class) GST_QUEUE_CLEAR_LEVEL (queue->orig_min_threshold); gst_segment_init (&queue->sink_segment, GST_FORMAT_TIME); gst_segment_init (&queue->src_segment, GST_FORMAT_TIME); + queue->head_needs_discont = queue->tail_needs_discont = FALSE; queue->leaky = GST_QUEUE_NO_LEAK; queue->srcresult = GST_FLOW_WRONG_STATE; @@ -601,6 +602,7 @@ gst_queue_locked_flush (GstQueue * queue) queue->min_threshold.time = queue->orig_min_threshold.time; gst_segment_init (&queue->sink_segment, GST_FORMAT_TIME); gst_segment_init (&queue->src_segment, GST_FORMAT_TIME); + queue->head_needs_discont = queue->tail_needs_discont = FALSE; /* we deleted a lot of something */ GST_QUEUE_SIGNAL_DEL (queue); @@ -865,6 +867,8 @@ gst_queue_chain (GstPad * pad, GstBuffer * buffer) /* how are we going to make space for this buffer? */ switch (queue->leaky) { case GST_QUEUE_LEAK_UPSTREAM: + /* next buffer needs to get a DISCONT flag */ + queue->tail_needs_discont = TRUE; /* leak current buffer */ GST_CAT_DEBUG_OBJECT (queue_dataflow, queue, "queue is full, leaking buffer on upstream end"); @@ -886,6 +890,8 @@ gst_queue_chain (GstPad * pad, GstBuffer * buffer) "queue is full, leaking item %p on downstream end", leak); gst_buffer_unref (leak); } while (gst_queue_is_filled (queue)); + /* last buffer needs to get a DISCONT flag */ + queue->head_needs_discont = TRUE; break; } default: @@ -912,6 +918,11 @@ gst_queue_chain (GstPad * pad, GstBuffer * buffer) } } + if (queue->tail_needs_discont) { + GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DISCONT); + queue->tail_needs_discont = FALSE; + } + /* put buffer in queue now */ gst_queue_locked_enqueue (queue, buffer); GST_QUEUE_MUTEX_UNLOCK (queue); @@ -979,6 +990,11 @@ next: buffer = GST_BUFFER_CAST (data); caps = GST_BUFFER_CAPS (buffer); + if (queue->head_needs_discont) { + GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DISCONT); + queue->head_needs_discont = FALSE; + } + GST_QUEUE_MUTEX_UNLOCK (queue); /* set the right caps on the pad now. We do this before pushing the buffer * because the pad_push call will check (using acceptcaps) if the buffer can diff --git a/plugins/elements/gstqueue.h b/plugins/elements/gstqueue.h index aaff87c..e2f65d9 100644 --- a/plugins/elements/gstqueue.h +++ b/plugins/elements/gstqueue.h @@ -105,6 +105,8 @@ struct _GstQueue { GMutex *qlock; /* lock for queue (vs object lock) */ GCond *item_add; /* signals buffers now available for reading */ GCond *item_del; /* signals space now available for writing */ + + gboolean head_needs_discont, tail_needs_discont; }; struct _GstQueueClass { -- 2.7.4