Commit graph

391 commits

Author SHA1 Message Date
Niels De Graef
4812c4087f Don't pass default GLib marshallers for signals
By passing NULL to `g_signal_new` instead of a marshaller, GLib will
actually internally optimize the signal (if the marshaller is available
in GLib itself) by also setting the valist marshaller. This makes the
signal emission a bit more performant than the regular marshalling,
which still needs to box into `GValue` and call libffi in case of a
generic marshaller.

Note that for custom marshallers, one would use
`g_signal_set_va_marshaller()` with the valist marshaller instead.
2019-09-09 12:16:24 +00:00
Håvard Graff
3260b2f630 queue: don't report 0 max-latency for leaky queue if max was already 0. 2019-06-13 15:21:03 +00:00
Thibault Saunier
5b2da0835e doc: Fix and add some missing docstrings 2019-05-13 11:33:49 -04:00
Olivier Crête
23b32d5600 queue: Ignore thresholds if a query is queued
The queue gets filled by the tail, so a query will always be the tail
object, not the head object. Also add a _peek_tail_struct() method to the
GstQueueArray to enable looking at the tail.

With unit test to prevent future regression.

https://bugzilla.gnome.org/show_bug.cgi?id=762875
2018-03-01 16:31:57 -05:00
Edward Hervey
922e048379 queue: Only calculate level if we have valid levels
Doing calculations with GST_CLOCK_STIME_NONE would result in
completely bogus levels
2017-11-23 15:28:39 +01:00
Tim-Philipp Müller
c2917b1ae2 plugins: use new gst_buffer_list_calculate_size() 2017-09-17 12:36:03 +01:00
Sebastian Dröge
36372a9f4c queue: Allow re-usability after EOS
After EOS, it is possible for a pad to be resetted by sending
either a STREAM_START or SEGMENT event

Mimic the same behaviour when receiving STREAM_START/SEGMENT events
in queue if we are EOS'd

https://bugzilla.gnome.org/show_bug.cgi?id=786056
2017-08-11 11:12:09 +03:00
Edward Hervey
e2f8dc0aef plugins: *queue* elements: Handle STREAM_START in EOS situation
When queue-like elements are in "EOS" situation (received GST_FLOW_EOS
from downstream or EOS was pushed), they drain buffers/events that
wouldn't be processed anyway and let through events that might
modify the EOS situation.

Previously only GST_EVENT_EOS and GST_EVENT_SEGMENT events were let
through, but we also need to allow GST_EVENT_STREAM_START to go
through since it resets the EOS state of pads since 1.6

https://bugzilla.gnome.org/show_bug.cgi?id=786034
2017-08-09 10:54:17 +02:00
Thiago Santos
058bdcfe6b queue: avoid return flushing if we have a not-linked
Return the correct flow return instead of returning always flushing.
This would cause queue to convert not-linked to flushing and making
upstream elements stop.

Based on the previous patch for queue2.

https://bugzilla.gnome.org/show_bug.cgi?id=776999
2017-03-14 22:20:04 -07:00
Thibault Saunier
a87b4551a6 Port gtk-doc comments to their equivalent markdown syntax
Modernizing our documentation and preparing a possible move to hotdoc.
This commits also adds missing @title metadatas to all SECTIONs
2017-01-27 16:36:38 -03:00
Jan Schmidt
748687fc30 queue: Don't generate GST_FLOW_ERROR without logging
At least log a message to the debug log when generating
a GST_FLOW_ERROR, to make it possible to find where it came from.
2017-01-03 02:21:10 +11:00
Sebastian Dröge
3fab00b46a queue/queue2: Protect against spurious condition variable wakeups
Make sure that we only wake up when we have to flush, or when this
specific query was handled.

https://bugzilla.gnome.org/show_bug.cgi?id=776039
2016-12-13 21:03:54 +02:00
Sebastian Dröge
33c239828b queue/queue2: Ensure that the streaming thread is unlocked after deactivating the srcpad
It might happen that the srcpad task function is never called at all, in
which case unlocking everything from there will never happen.

Make sure to unlock everything another time after the task function is
definitely stopped.

https://bugzilla.gnome.org/show_bug.cgi?id=776039
2016-12-13 21:03:54 +02:00
Jan Schmidt
a6ca8dfb42 queues: Don't return negative position queries.
When subtracting queued data sizes from upstream queries
in queue, queue2, downloadbuffer and typefind, clamp the
result to not go negative, in case upstream returned
a nonsense value that's too small (as could happen if
upstream is estimating, or just broken)
2016-11-16 00:12:22 +11:00
Sebastian Dröge
cfdb97a135 Revert "queue: Fix race when calculating cur_level.time"
This reverts commit d03bd54780.

It breaks the unit test, although it ensures that only correct values
are used for calculations. Needs to be fixed up.

https://bugzilla.gnome.org/show_bug.cgi?id=773096
2016-10-21 15:23:14 +03:00
Stian Selnes
d03bd54780 queue: Fix race when calculating cur_level.time
On the first buffer, it's possible that sink_segment is set but
src_segment has not been set yet. If this is the case, we should not
calculate cur_level.time since sink_segment.position may be large and
src_segment.position default is 0, with the resulting diff being larger
than max-size-time, causing the queue to start leaking (if
leaky=downstream).

One potential consequence of this is that the segment event may be
stored on the srcpad before the caps event is pushed downstream, causing
a g_warning ("Sticky event misordering, got 'segment' before 'caps'").

https://bugzilla.gnome.org/show_bug.cgi?id=773096
2016-10-20 14:14:20 +03:00
Thibault Saunier
4714ef2f8e Make use of the new GST_ELEMENT_FLOW_ERROR API all around.
https://bugzilla.gnome.org/show_bug.cgi?id=770158
2016-08-27 09:33:20 -03:00
Sebastian Dröge
722ad08733 queue: Only unblock upstream waiting for the query once downstream is finished
... when flushing and deactivating pads. Otherwise downstream might have a
query that was already unreffed by upstream, causing crashes or other
interesting effects.

https://bugzilla.gnome.org/show_bug.cgi?id=763496
2016-05-15 11:06:08 +03:00
Edward Hervey
f87ec5e014 queue: Use full running time for level calculation
Ensures we have proper time level estimation for the cases where
the incoming buffers have PTS/DTS outside of the segment start/stop
values.

https://bugzilla.gnome.org/show_bug.cgi?id=762995
2016-03-24 14:42:31 +02:00
Tim-Philipp Müller
cf0680017e elements: use new gst_element_class_add_static_pad_template()
https://bugzilla.gnome.org/show_bug.cgi?id=762778
2016-02-28 13:10:07 +00:00
Sebastian Dröge
33ded76ab8 queue/multiqueue: Don't special-case CAPS events in the event handlers
For CAPS events we will never ever have a FALSE return value here, so just
remove the dead code instead of causing future confusion.
2015-12-14 11:20:43 +01:00
Sebastian Dröge
0636fe1391 Revert "queue: Illegal memory access of sink event"
This reverts commit 78614c505a.

The code it was fixing does not have any effect anyway and will be removed in
the next commit.
2015-12-14 11:20:22 +01:00
Vineeth TM
78614c505a queue: Illegal memory access of sink event
Once event is pushed to pad, then queue should not access the event.
This is leading to invalid read valgrind errors

https://bugzilla.gnome.org/show_bug.cgi?id=759430
2015-12-14 10:41:50 +01:00
Edward Hervey
56d4650789 pad: Implement GstPadEventFullFunction
API: GstPadEventFullFunction

Returns a GstFlowReturn, allows asynchronous elements to properly
propagate flow returns

https://bugzilla.gnome.org/show_bug.cgi?id=757821
2015-12-02 16:04:03 +01:00
Edward Hervey
a9c923d585 queue/queue2: Use GST_BUFFER_DTS_OR_PTS
The input of queue/queue2 might have DTS set, in which cas we want
to take that into account (instead of the PTS) to calculate position
and queue levels.

https://bugzilla.gnome.org/show_bug.cgi?id=756507
2015-10-27 08:49:02 +01:00
Tim-Philipp Müller
41fdf21a60 queue: avoid slice allocs/frees for each item
Microoptimisation: Let GstQueueArray store our
item struct. That way we don't have to alloc/free
temporary QueueItem slices for every item we want
to put into the queue.

https://bugzilla.gnome.org/show_bug.cgi?id=750149
2015-07-04 11:07:19 +01:00
Sebastian Dröge
a941b4651c queue: Wake up the query function on errors from the loop function
Otherwise we might wait forever for serialized queries to be handled as the
loop function is stopped and as such we will never ever dequeue the query and
handle it.

https://bugzilla.gnome.org/show_bug.cgi?id=745319
2015-03-03 12:49:47 +01:00
Sebastian Dröge
f2b27d3962 queue: Remove unused boolean parameter from internal functions 2015-02-18 11:05:19 +02:00
Sebastian Dröge
6369ba06ff queue: Add support for buffer lists 2015-02-18 11:03:08 +02:00
Sebastian Dröge
4a5ce862a2 Improve and fix LATENCY query handling
This now follows the design docs everywhere.

https://bugzilla.gnome.org/show_bug.cgi?id=744106
2015-02-11 17:53:04 +02:00
Sebastian Dröge
917e4cd985 queue: Add missing break in switch 2014-10-02 14:55:22 +03:00
Sebastian Dröge
594e2f0668 queue: update segment position on GAP events to calculate levels properly
https://bugzilla.gnome.org/show_bug.cgi?id=737498
2014-10-02 11:00:32 +03:00
Thibault Saunier
97a6bb377b queue: Do not forget to release the QUEUE_LOCK in the out_flow_error path
Avoiding deadlocks!
2014-09-23 14:45:43 +02:00
Thibault Saunier
38657bff51 queue: Do not hold GST_QUEUE_LOCK while posting ERROR messages
This might create deadlocks and we need to avoid holding element
specific lock while posting messages

For example a deadlock will happen if while posting the message,
someone connected on the bus (sync) tries to DOT the pipeline.

https://bugzilla.gnome.org/show_bug.cgi?id=737102
2014-09-22 16:13:44 +02:00
Tim-Philipp Müller
49c6f923de coreelements: mark properties with MUTABLE_PLAYING 2014-09-14 16:08:07 +01:00
Tim-Philipp Müller
93d8679b00 queue: fix race when flush-stop event comes in whilst shutting down
Don't re-start the queue push task on the source pad when a
flush-stop event comes in and we're in the process of shutting
down, otherwise that task will never be stopped again.

When the element is set to READY state, the pads get de-activated.
The source pad gets deactivated before the queue's own activate_mode
function on the source pads gets called (which will stop the thread),
so checking whether the pad is active before re-starting the task on
receiving flush-stop should be fine. The problem would happen when the
flush-stop handler was called just after the queue's activate mode
function had stopped the task.

Spotted and debugged by Linus Svensson <linux.svensson@axis.com>

https://bugzilla.gnome.org/show_bug.cgi?id=734688
2014-08-23 11:43:20 +01:00
Sebastian Dröge
6a261b1fc2 queue: Post errors when receiving EOS after downstream returned an error
There might be no further data flow that would allow us to propagate the
error upstream, causing nobody to post an error at all.
2014-08-13 12:18:37 +03:00
Thiago Santos
3ed2507ebc queue: queue2: preserve last flow result when pushing events
Avoids mistakenly returning _OK when downstream is still
_NOT_LINKED on subsequent received pad pushes

https://bugzilla.gnome.org/show_bug.cgi?id=725917
2014-03-10 10:10:20 -03:00
Edward Hervey
af6fd4f5bb queue: Remove unneeded checks
item is guaranteed to be non-null.

COVERITY CID 1037152
COVERITY CID 1037153
2013-12-30 16:51:01 +01:00
Wim Taymans
e5a73cc2ff queue: don't ignore event return value
Pass the event return value upstream.
Remove strange goto construct.
2013-12-11 14:52:25 +01:00
Sebastian Rasmussen
53ae1b2c9c docs: Fix typos in function/object descriptions
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=720029
2013-12-07 17:11:12 +00:00
Edward Hervey
74a1970101 queue: Don't use gst_buffer_get_size() when possible
Makes qst_queue_locked_dequeue 20% faster
2013-11-11 13:28:14 +01:00
Sebastian Dröge
14f817d723 queue: Properly unlock the sinkpad streaming thread when deactivating the pad
https://bugzilla.gnome.org/show_bug.cgi?id=705835
2013-08-20 10:16:41 +02:00
Sebastian Dröge
ec1dd125c7 queue: Clean up after the streaming thread has stopped
https://bugzilla.gnome.org/show_bug.cgi?id=705835
2013-08-19 16:38:16 +02:00
Sebastian Dröge
2f8e572887 queue: Don't hold the queue mutex while doing serialized queries downstream
https://bugzilla.gnome.org/show_bug.cgi?id=702520
2013-06-19 10:53:21 +02:00
Sebastian Dröge
ab6a1085ee (multi)queue: Don't access query items during flushing 2013-05-27 16:38:18 +02:00
Sebastian Dröge
6f042f13ae queue: Fix handling of serialized queries
During FLUSH_START the query needs to be unblocked already, otherwise
it can lead to deadlocks if the FLUSH_START is the result of something
done from the streaming thread of the srcpad (the queue will never be
emptied!).
2013-05-27 15:59:07 +02:00
Sebastian Dröge
b6fac17502 queue/queue2/multiqueue: When flushing, make sure to not lose any sticky events
https://bugzilla.gnome.org/show_bug.cgi?id=688824
2013-05-27 13:01:43 +02:00
Sebastian Dröge
46270f8925 queue: Set the last serialized query result to FALSE when flushing 2013-05-24 18:47:24 +02:00
Sebastian Dröge
8e1f70473b queue: Store sticky events on the srcpad if we're dropping them because of leaking 2013-05-09 12:50:20 +02:00