Protect the ->removed field with the object lock as well. Take the DYN lock
earlier so that we can mark the pad removed and avoid a race in pad_alloc.
Fixes#606435
gstfilesink.c:399: error: format ‘%d’ expects type ‘int’, but argument 8 has type ‘size_t’
gstfilesink.c:399: error: format ‘%d’ expects type ‘int’, but argument 9 has type ‘gsize’
gstfilesrc.c:588: error: format ‘%08llx’ expects type ‘long long unsigned int’, but argument 8 has type ‘off_t’
It is not easy to setup a tee on the fly, thus apps need to add them always if
they might need them. This changes the code so, that if only one src-pad is
active, we push buffers directly. In the normal code path all buffers are pushed
with an extra ref, that forces followup inplace elements to copy the data.
Cast the variable to gint to conform to the printf format used.
It is casted rather than changing the format because the
message is created with a cast to gint too.
queue2 would crash when using small buffer sizes because
it would overflow when calculating the percentage, resulting
in the buffering GstMessage not being created and trying to be
used. This patch uses a gint64 instead of a gint to do the
percentage math, making it harder to overflow.
Using the current fill level of the queue, and the average input
rate, we can determine how long it will take to finish downloading
the whole stream to the temporary file.
Fixes#600726
There's not much point in using GST_DEBUG_FUNCPTR with GObject
virtual functions such as get_property, set_propery, finalize and
dispose, since they'll never be used by anyone anyway. Saves a
few bytes and possibly a tenth of a polar bear.
Add support for buffering mode where we post BUFFERING messages based on the
level of the queues. It currently operates on the first queue that goes over or
under the high/low thresholds.
In buffering mode we want to ignore the max visible items to decide when the
queue is filled. Instead, we only look at the number of bytes and/or time in the
queue.
Don't shadow the sq argument in the underrun_cb function but use
a different variable name to iterate the other queues.
Use the same variable name in the overrun_cb function.
Split gst_queue_locked_enqueue() into variant for buffer and event to get rid of
the if() and make the code more readable (constant boolean parameters are never
nice). Removes the if (item) checks as we dereference the pointer before anyway.
Also apply the same idea of reusing the previous knowledge in
gst_queue_locked_dequeue to remove more type checks.
We know earlier on in the code whether we're handling an event or a buffer,
just pass that information through.
This commit and the previous commit reduce instruction fetch:
* when pushing buffer (_chain) by 10%
* when popping buffer (_loop) by 3%
The task will always exist as long as its owner (i.e. the pad) and that
owner's owner (i.e. multiqueue) exist.
Reduces the number of instruction fetches by 36%.
We know whether we have a buffer or an event, use that instead of going
trough the expensive GLib typecheck.
The overall instruction fetch reduction introduced by this commit and the
2 previous commits:
* receiving a buffer (_chain) by 20%
* popping a buffer (_loop) by 14%
Numbers acquired through callgrind passing 100000 buffers through queue.
Pads have their GstSingleQueue stored as element private data
so there's no need to iterate over the list of single queues
every time. Also every pad only has a single internal link so
use a single iterator instead of a complex custom iterator.
Set the element private data of the pad to NULL when freeing the
single queue.
If downstream returns error and upstream has already delivered
everything (including EOS) and will no longer be around to find
out that we paused (and why), post error message. Fixes#589991.
When we have an input buffer with caps and when those caps are different from
the caps we want, only then make a writable copy of the input buffer as the
output buffer and set the caps on that output buffer. This avoids some cases
where we took a subbuffer for setting caps that were the same.
Users should never see the term 'file descriptor', much less a file
descriptor number, in an error message. Put that into the debug
string instead and use the default error message.
The compiler suggests to add some () to indicate if the && or the || takes
priority, so reflow code a bit so we don't have to add yet another layer
of (). Hopefully this was the intended meaning of the code.
When min-threshold is set on a queue, it is possible that one of
the minima remains unsatisfied while one of the maxima is already
reached. Therefore, always consider the queue non-empty if it is full.
Fixes#585433.
Out-of-band events might lead to us calling g_object_notify() from a
non-streaming thread, which can cause crashes if g_object_notify() is
being called from the streaming thread at the same time. See #554460.
GObject may crash if two threads do concurrent g_object_notify() on the same
object. This may happen if fakesink receives an out-of-band event such as
FLUSH_START while processing a buffer or serialised event in the streaming
thread. Since this may happen with the default settings during a common
operation like a seek, and there seems to be little chance of a timely fix
in GObject (see #166020), we should hack around this issue by protecting all
of fakesink's direct g_object_notify() calls with a lock.
Also add unit test for the above.
Fixes#554460.