Commit graph

2361 commits

Author SHA1 Message Date
dhilshad c8bcb9db18 downloadbuffer:fix pushing buffer before stream start event
downloadbuffer source pad pushes the first buffer before pushing
Stream Start and Segment event, when working in Push mode.

Fix:Pushing Stream Start and Segment after coming out of
wait for data, and before pushing the buffer to next element.

Fixes #534
2020-04-17 15:16:18 +00:00
Vivia Nikolaidou 4679c2ed6f multiqueue: Add current-level-{buffers, bytes, time} pad properties
To get the current buffers/bytes/time levels of the corresponding
internal queue
2020-04-09 18:03:35 +03:00
Vivia Nikolaidou 74938f07c2 multiqueue: Add stats property
The returned "stats" structure contains, for now, one array called
"queues" with one GstStructure per internal queue, containing said
queue's current level of bytes, buffers, and time.
2020-04-09 17:57:43 +03:00
Vivia Nikolaidou cbdc259865 downloadbuffer, multiqueue, queue2: Fix watermark docs
It is not explicitly specified anywhere in the docs that 0% buffering is
at low-watermark and 100% buffering is at high-watermark. It was
specified only in the sources.
2020-04-06 18:19:06 +03:00
Seungha Yang 13bee5ae0c filesink: Fix for updating the index of memory to write in the next iteration
current_buf_mem_idx stands for the index of memory of the corresponding
buffer which is scheduled to be written in the next iteration.
If all memory objects were scheduled to be written in the current
iteration, reset the index to zero so that starting from the first
memory object of the next buffer.
2020-03-31 19:05:30 +09:00
Seungha Yang 5c74c8c4f8 filesink: Fix crash caused by zero-size memory allocation
If size of vector is greater than one, we are allocating zero-size
memory and trying invalid memcpy operation
2020-03-28 16:20:51 +09:00
Sebastian Dröge dcb2be3282 filesink: Add a new full buffer mode to filesink
Previously the default and full modes were the same. Now the default
mode is like before: it accumulates all buffers in a buffer list until
the threshold is reached and then writes them all out, potentially in
multiple writes.

The new full mode works by always copying memory to a single memory area
and writing everything out with a single write once the threshold is
reached.
2020-03-26 11:31:03 +00:00
Sebastian Dröge 93ffec7b2e filesink/fdsink: Write 1 iovec directly without copying if there's no writev() support 2020-03-26 11:31:03 +00:00
Sebastian Dröge c15f1b2bec fdsink/filesink: Refactor writev() code to prevent stack overflows
If buffer lists with too many buffers would be written before, a stack
overflow would happen because of memory linear with the number of
GstMemory would be allocated on the stack. This could happen for example
when filesink is configured with a very big buffer size.

Instead now move the buffer and buffer list writing into the helper
functions and at most write IOV_MAX memories at once. Anything bigger
than that wouldn't be passed to writev() anyway and written differently
in the previous code, so this also potentially speeds up writing for
these cases.

For example the following pipeline would crash with a stackoverflow:
gst-launch-1.0 audiotestsrc ! filesink buffer-size=1073741824 location=/dev/null
2020-03-26 11:31:03 +00:00
Stéphane Cerveau 0b1c2f715a identity: Fix a minor leak using meta_str 2020-03-13 12:14:08 +01:00
Sebastian Dröge 8fb1fe4620 clocksync: Use g_cond_signal() instead of g_cond_broadcast()
There can only be a single waiter: on the streaming thread.
2020-03-09 21:32:28 +02:00
Sebastian Dröge be8a15b0f9 identity: Use g_cond_signal() instead of g_cond_broadcast()
There can only be a single waiter: on the streaming thread.
2020-03-09 21:31:48 +02:00
Sebastian Dröge c7ddc5eb79 identity: Unblock condition variable on FLUSH_START
... and immediately return FLUSHING from the streaming thread instead of
waiting potentially forever.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/516
2020-03-09 20:27:58 +02:00
Tim-Philipp Müller b8f5cb5a3a tracers: rusage: use thread-local storage for per-thread stats
.. instead of looking things up by thread id from a GHashTable,
which also happens to have no locking around insertion/lookup.
2020-02-28 15:54:38 +00:00
Tim-Philipp Müller 04aad3f4cf tracers: rusage: fix minor string leak in constructor 2020-02-28 15:54:38 +00:00
Jan Schmidt 81d55fb479 clocksync: Add new clocksync element
The clocksync element is a generic element that can be
placed in a pipeline to synchronise passing buffers to the
clock at that point. This is similar to 'identity sync=true',
but because it isn't GstBaseTransform-based, it can process
GstBufferLists without breaking them into separate GstBuffers
2020-02-26 16:36:29 +00:00
Olivier Crête 447cae6229 leak tracer: Initialize GValue 2020-02-15 11:19:54 +00:00
Thibault Saunier 14cd8b8348 leaks: Do not trace refs for object we do not follow
When the user sets filters, we should not trace ref counts of object that
are not traced. This optimizes the tracer by potentially avoiding
generating useless backtraces.
2020-02-14 23:07:53 +00:00
Peter Seiderer afa802e4aa filesink: handle fsync interrupted by signal (EINTR)
According to [1] EINTR is a possible errno for fsync() and it happens in
reality on linux (video writing via splitmuxsink with robust muxing enabled
on a cifs mounted network share), so handle it as all other EINTR
(do/while(errno == EINTR)).

Fixes:

  GError.message: Error while writing to file "vidoe_001.mp4". GError.domain: 2372 GError.code: 10 from: FileSink debug: gstfilesink.c(849): gst_file_sink_render (): /GstPipeline:Pipeline/GstSplitMuxSink:SplitMuxSink/GstBin:QueueBin/GstFileSink:FileSink: Interrupted system call

Signed-off-by: Peter Seiderer <ps.report@gmx.net>
2019-12-12 20:49:36 +01:00
Xavier Claessens 4a554a2a68 Meson: Add 'coretracers' feature option
This was the only plugin still built when using
-Dauto_features=disabled, besides coreelements.
2019-12-03 19:01:38 -05:00
Edward Hervey f590a861be tracers: Don't leak temporary GstStructure
CID: 1455462
2019-11-28 08:03:51 +00:00
Niels De Graef 0ca0a9d982 queue2: Use g_object_notify_by_pspec
`g_object_notify()` actually takes a global lock to look up the
`GParamSpec` that corresponds to the given property name. It's not a
huge performance hit, but it's easily avoidable by using the
`_by_pspec()` variant.
2019-10-31 11:06:48 +01:00
Sebastian Dröge d25a88e3a1 tee: First deactivate the pad and then remove it when releasing pads
This reverts a96002bb28, which is not
necessary anymore. If we release the pad after removing it then none of
the deactivation code will actually be called because the pad has no
parent anymore, and we require a parent on the pad for deactivation to
happen.

This can then, among other things, cause a streaming thread to be still
stuck in a pad probe because the pad was never flushed, and waiting
there forever because now the pad will actually never be flushed anymore.
2019-10-24 22:49:41 +00:00
Sebastian Dröge 7f7da6a0d0 tee: Check for the removed pad flag also in the slow pushing path
If a pad is currently being released we don't want to forward the
FLUSHING flow return but instead consider it as NOT_LINKED. FLUSHING
would also cause upstream to be FLUSHING.

This part was missed in a3c4a3201a and
resulted in a different (and wrong) workaround in
a96002bb28.
2019-10-24 22:49:41 +00:00
Sebastian Dröge aa29864317 tee: Lock mutex before reading the removed flag of the pads
Otherwise we're not guaranteed to read the very latest value that
another thread might've written in there when the pad was released, and
could instead work with an old value.
2019-10-24 22:49:41 +00:00
Tim-Philipp Müller 10d9e18f02 Remove autotools build system 2019-10-13 16:10:42 +01:00
Xavier Claessens d109dd2752 dataurisrc: Do not include trailing \0 into buffer 2019-10-07 17:47:47 +00:00
Aaron Boxer 509f6201e1 documentation: fix a number of typos 2019-10-06 11:12:11 -04:00
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
Jim Mason a4aa2256d1 consolidated IOV_MAX/UIO_MAXIOV handling per GLib + legacy behaviour for osx/ios 2019-09-07 12:32:40 +01:00
Jim Mason dc5250e751 gst_writev: respect IOV_MAX for the writev iovec array #439 2019-09-06 19:23:01 +01:00
Matthew Waters 43622119bb file/fdsrc: use struct stat64 on android to match stat64()
Fixes android werror failures:

../plugins/elements/gstfdsrc.c:244:25: error: incompatible pointer types passing 'struct stat *' to parameter of type 'struct stat64 *' [-Werror,-Wincompatible-pointer-types]
    if (fstat (src->fd, &stat_results) < 0)
                        ^~~~~~~~~~~~~
/home/matt/Projects/cerbero/build/android-ndk-18/sysroot/usr/include/sys/stat.h:159:38: note: passing argument to parameter '__buf' here
int fstat64(int __fd, struct stat64* __buf) __RENAME_STAT64(fstat, 3, 21);
                                     ^
../plugins/elements/gstfdsrc.c:560:23: error: incompatible pointer types passing 'struct stat *' to parameter of type 'struct stat64 *' [-Werror,-Wincompatible-pointer-types]
  if (fstat (src->fd, &stat_results) < 0)
                      ^~~~~~~~~~~~~
/home/matt/Projects/cerbero/build/android-ndk-18/sysroot/usr/include/sys/stat.h:159:38: note: passing argument to parameter '__buf' here
int fstat64(int __fd, struct stat64* __buf) __RENAME_STAT64(fstat, 3, 21);
                                     ^

  if (fstat (fd, &stat_results) < 0)
                 ^~~~~~~~~~~~~
/home/matt/Projects/cerbero/build/android-ndk-18/sysroot/usr/include/sys/stat.h:159:38: note: passing argument to parameter '__buf' here
int fstat64(int __fd, struct stat64* __buf) __RENAME_STAT64(fstat, 3, 21);
                                     ^

  if (fstat (src->fd, &stat_results) < 0)
                      ^~~~~~~~~~~~~
../../../../../android-ndk-18/sysroot/usr/include/sys/stat.h:159:38: note: passing argument to parameter '__buf' here
int fstat64(int __fd, struct stat64* __buf) __RENAME_STAT64(fstat, 3, 21);
                                     ^
../plugins/elements/gstfilesrc.c:477:23: error: incompatible pointer types passing 'struct stat *' to parameter of type 'struct stat64 *' [-Werror,-Wincompatible-pointer-types]
  if (fstat (src->fd, &stat_results) < 0)
                      ^~~~~~~~~~~~~
../../../../../android-ndk-18/sysroot/usr/include/sys/stat.h:159:38: note: passing argument to parameter '__buf' here
int fstat64(int __fd, struct stat64* __buf) __RENAME_STAT64(fstat, 3, 21);
                                     ^
2019-08-28 15:46:33 +10:00
Guillaume Desmottes b7c1195f29 latency: fix custom event leaks
If the element before the sink needs $n buffers to produce one output
buffer, we were reffing $n events and unreffing only one.
Prevent this by using g_object_set_qdata_full() to handle the event
unreffing so we're sure no ref will be lost.
2019-08-13 09:09:55 +05:30
Mathieu Duponchelle 3f93290151 funnel: fix documentation
funnel no longer sends its own segment since:

bbb26f8756

Update the documentation to reflect that
2019-08-06 13:30:12 +00:00
Guillaume Desmottes e4cba8a0bf tracers: set MAY_BE_LEAKED on tracer records
The records are static and so appear as false positives when using those
tracers with the leaks tracer as well.
The leaks tracer was already setting this flag on its record so let's
set it on the other ones as well.
2019-08-02 13:07:58 +05:30
Alicia Boya García b50abd9f4e downloadbuffer: Check for flush after seek
In gst_download_buffer_wait_for_data(), when a seek is made with
perform_seek_to_offset() the `qlock` is released temporarily. Therefore,
the flushing condition can be set during this period and should be
checked.

This was not being checked before, causing occasional deadlocks when
GST_DOWNLOAD_BUFFER_WAIT_ADD_CHECK() was called.

GST_DOWNLOAD_BUFFER_WAIT_ADD_CHECK() assumes that the caller has already
checked that we're not flushing before, since this is done when
acquiring the lock; so if we release it temporarily somewhere, we need
to check for flush again.

Without that check, the function would keep waiting for the condition
variable to be notified before checking for flushing condition again,
and that may very well never happen. This was reproduced when during pad
deactivation when running WebKit in gdb.
2019-07-22 15:06:20 +00:00
Nicolas Dufresne 86b9f78788 identity: Non-live upstream have no max latency
sync=TRUE implementation changes the latency query of a non-live
upstream into live, though it wrongly set the upstream max latency to 0.
As non-live sources won't loose data if we wait longer, this should have
been reported as have no max latency limite (-1).
2019-07-19 22:12:29 -04:00
Philippe Normand be56bd9aff identity: Fix the ts-offset property getter
Previous code was a copy/paste from the property setter function.
2019-07-11 17:53:53 +01:00
Thibault Saunier 7a2d32abda multiqueue: Fix possible NULL pointer dereferencing
In the hotdoc inspector for example, pads are instantiated with
g_object_new, other code paths to get/set properties already make
that check.

And update doc cache
2019-07-02 17:27:32 -04:00
Tim-Philipp Müller b5dc8598be leakstracer: Improve notes in the the get-live-objects API docs
It may not be obvious to the user how this action signal is meant to
be called, so document it.
2019-07-02 15:13:26 +05:30
Nirbheek Chauhan 6ccf59ec06 leakstracer: Add API for tracking and checkpointing objects
This feature was previously available only through the SIGUSR2 signal,
which meant it wasn't available on platforms that don't have UNIX
signals, such as Windows and with applications that already use
SIGUSR1 for something else.

Now we have action-signals for doing the same. These action signals
can also be used for fetching the checkpoint information
programmatically instead of printing to the debug log.
2019-07-02 15:13:26 +05:30
Nirbheek Chauhan 6e3565ca86 leakstracer: Add API for logging leaks in the debug log
This is the equivalent of sending SIGUSR1 to the application, and is
useful on platforms where UNIX signals are not available, such as
Windows.
2019-07-02 15:13:26 +05:30
Nirbheek Chauhan 44198ec4d6 leakstracer: Add API for fetching leaked objects
This allows programs to inspect the leaked objects directly, log them,
and so on. Unlike the existing mechanism to use SIGUSR1, this also
works on platforms that do not support UNIX signals, such as Windows
and with applications that already use SIGUSR1 for something else.
2019-07-02 15:13:26 +05:30
Nirbheek Chauhan 5cdf1b7db8 tracers: Allow setting a name for all tracer objects
This will be useful in combination with the next commit when we add
API to get a list of active tracers so that consumers of the API can
easily distinguish tracer objects.
2019-07-02 15:13:26 +05:30
Nirbheek Chauhan 3e2f24955e leakstracer: Get rid of GSlice usage
It's not faster than malloc, and is slower in most cases. Glib is also
getting rid of it entirely: https://gitlab.gnome.org/GNOME/glib/merge_requests/940
2019-07-01 13:33:13 +00:00
Nirbheek Chauhan a1c44cca3a leakstracer: Remove unused and redundant record fields
All leak records are obviously scoped to the process, and nothing in
the GstTracerRecord code uses these fields anyway.
2019-07-01 13:33:13 +00:00
Nirbheek Chauhan bafa7a5ca7 leakstracer: Improve documentation for the element
Also print a useful g_warning() message when leaks are detected.
2019-07-01 13:33:13 +00:00
Nirbheek Chauhan 145f8546c4 gstinfo: Add an explicit enum for GST_STACK_TRACE_SHOW_NONE
The code implicitly uses this value when the stack trace is not FULL.
Mostly useful for documenting the behaviour when each flag is passed
and for translating to/from strings.
2019-07-01 10:36:09 +00:00
Thibault Saunier 27fbaf9d44 multiqueue: Hold weak references to pads/multiqueue in SingleQueue
Without holding a ref we have no guarantees that the SingleQueue
doesn't have dangling pointers on those objects during its destruction.
2019-06-28 15:30:54 -04:00
Thibault Saunier 6a20fcc97a multiqueue: Stop using the gst_pad_element_private API
There was a race where we could still get the pad event function
called when its private member were already unset, leading to
a segfault in the event handler:

```
0  gst_multi_queue_src_event (pad=<optimized out>, parent=<optimized out>, event=0x7f3ff0007600) at ../subprojects/gstreamer/plugins/elements/gstmultiqueue.c:2534
2534          ret = gst_pad_push_event (sq->sinkpad, event);
[Current thread is 1 (Thread 0x7f406c0258c0 (LWP 21925))]
(gdb) bt
0  0x00007f4062ec1399 in gst_multi_queue_src_event (pad=<optimized out>, parent=<optimized out>, event=0x7f3ff0007600 [GstEvent]) at ../subprojects/gstreamer/plugins/elements/gstmultiqueue.c:2534
1  0x00007f406b40f46d in gst_validate_pad_monitor_src_event_check (handler=0x7f4062ec1360 <gst_multi_queue_src_event>, event=0x7f3ff0007600 [GstEvent], parent=0x7f3fcc01f090 [GstMultiQueue|multiqueue167], pad_monitor=0x7f3fe809e7c0 [GstValidatePadMonitor|validatepadmonitor2213]) at ../subprojects/gst-devtools/validate/gst/validate/gst-validate-pad-monitor.c:2101
2  0x00007f406b40f46d in gst_validate_pad_monitor_src_event_func (pad=<optimized out>, parent=0x7f3fcc01f090 [GstMultiQueue|multiqueue167], event=0x7f3ff0007600 [GstEvent]) at ../subprojects/gst-devtools/validate/gst/validate/gst-validate-pad-monitor.c:2374
3  0x00007f406b904387 in gst_pad_send_event_unchecked (pad=pad@entry=0x7f3fdc027650 [GstPad|src_0], event=event@entry=0x7f3ff0007600 [GstEvent], type=<optimized out>, type@entry=GST_PAD_PROBE_TYPE_EVENT_UPSTREAM) at ../subprojects/gstreamer/gst/gstpad.c:5772
4  0x00007f406b90481b in gst_pad_push_event_unchecked (pad=pad@entry=0x7f4058182fc0 [GstPad|sink], event=event@entry=0x7f3ff0007600 [GstEvent], type=type@entry=GST_PAD_PROBE_TYPE_EVENT_UPSTREAM) at ../subprojects/gstreamer/gst/gstpad.c:5417
5  0x00007f406b90f016 in gst_pad_push_event (pad=0x7f4058182fc0 [GstPad|sink], event=event@entry=0x7f3ff0007600 [GstEvent]) at ../subprojects/gstreamer/gst/gstpad.c:5554
6  0x00007f406a1c99ba in gst_video_decoder_src_event_default (decoder=0x7f3fe81c6060 [GstTheoraDec|theoradec46], event=<optimized out>) at ../subprojects/gst-plugins-base/gst-libs/gst/video/gstvideodecoder.c:1532
7  0x00007f406b40f46d in gst_validate_pad_monitor_src_event_check (handler=0x7f406a1ca270 <gst_video_decoder_src_event>, event=0x7f3ff0007600 [GstEvent], parent=0x7f3fe81c6060 [GstTheoraDec|theoradec46], pad_monitor=0x7f4028163aa0 [GstValidatePadMonitor|validatepadmonitor2216]) at ../subprojects/gst-devtools/validate/gst/validate/gst-validate-pad-monitor.c:2101
8  0x00007f406b40f46d in gst_validate_pad_monitor_src_event_func (pad=<optimized out>, parent=0x7f3fe81c6060 [GstTheoraDec|theoradec46], event=0x7f3ff0007600 [GstEvent]) at ../subprojects/gst-devtools/validate/gst/validate/gst-validate-pad-monitor.c:2374
```

This make the GstSingleQueue a MiniObject, mainly so it is properly
refcounted.

This also make use of the GstMultiQueuePad class for srcpads which
is totally valid as srcpads and sinkpads share the same SingleQueue
object.
2019-06-25 12:53:05 -04:00