platform/upstream/gstreamer.git
5 years agoharness: Add gst_harness_pull_until_eos()
Xavier Claessens [Tue, 24 Sep 2019 14:06:51 +0000 (10:06 -0400)]
harness: Add gst_harness_pull_until_eos()

5 years agodocumentation: fix a number of typos
Aaron Boxer [Sun, 6 Oct 2019 15:12:11 +0000 (11:12 -0400)]
documentation: fix a number of typos

5 years agogstdirectcontrolbinding: Fix integer comparison
Jordan Petridis [Fri, 4 Oct 2019 17:01:46 +0000 (20:01 +0300)]
gstdirectcontrolbinding: Fix integer comparison

i is declared as gint but then compared against `n_values` guint
in the for loop below.

5 years agogst: Don't pass miniobjects to GST_DEBUG_OBJECT() and similar macros
Sebastian Dröge [Mon, 30 Sep 2019 08:49:35 +0000 (11:49 +0300)]
gst: Don't pass miniobjects to GST_DEBUG_OBJECT() and similar macros

The argument must be at least a GObject according to the GstLogFunction
definition, and while the default C log function handles miniobjects
just fine this is crashing bindings and user-supplied log functions that
(rightfully) don't expect anything but GObjects.

5 years agogstvalue: use value_nick for serialization
Mathieu Duponchelle [Sat, 7 Sep 2019 02:36:18 +0000 (04:36 +0200)]
gstvalue: use value_nick for serialization

not value_name . This was causing incorrect launch lines to be
displayed by gst-device-monitor, and the deserialization code
below works with nicks.

5 years agodeviceprovider: set the bus to non-flushing before calling klass->start
Mathieu Duponchelle [Mon, 9 Sep 2019 22:28:45 +0000 (00:28 +0200)]
deviceprovider: set the bus to non-flushing before calling klass->start

Not posting DEVICE_ADDED messages while a device provider is being
started makes things awkward for applications, as they have to call
get_devices() after starting the monitor.

This requires redundant code on the application side, and as far as
I understand also could cause race conditions, when a device gets
added between the calls to gst_device_monitor_start() and
gst_device_monitor_get_devices(), causing the application to "see"
the same device twice.

5 years agoelement: Enforce that elements created by gst_element_factory_create/make() are floating
Sebastian Dröge [Thu, 12 Sep 2019 07:09:18 +0000 (10:09 +0300)]
element: Enforce that elements created by gst_element_factory_create/make() are floating

Bindings might have a hard time making sure that the reference is indeed
still floating after returning here.

See https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/444

5 years agodevice: Enforce that elements created by gst_device_create_element() are floating
Sebastian Dröge [Thu, 12 Sep 2019 07:08:39 +0000 (10:08 +0300)]
device: Enforce that elements created by gst_device_create_element() are floating

Bindings might have a hard time making sure that the reference is indeed
still floating after returning here.

See https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/444

5 years agodevice: gst_device_create_element() is `transfer floating`, not `transfer full`
Sebastian Dröge [Thu, 12 Sep 2019 07:03:08 +0000 (10:03 +0300)]
device: gst_device_create_element() is `transfer floating`, not `transfer full`

Fixing the annotation fixes leaking of the created element in all
bindings using GObject-Introspection.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/444

5 years agobase: GstBaseSrc/GstBaseSink::get_caps: add (nullable) to `filter`
Sebastiano Barrera [Tue, 10 Sep 2019 10:31:40 +0000 (12:31 +0200)]
base: GstBaseSrc/GstBaseSink::get_caps: add (nullable) to `filter`

The virtual method named `get_caps` in both `GstBaseSrc` and
`GstBaseSink` has a `filter` parameter which can be `NULL` (the
default implementation in GstBaseSrc already considers the case).
Before this commit, there was no gtk-doc annotation representing this
fact, which caused the corresponding entry in the GIR file to also
miss this fact.

This caused bugs in other places, such inducing the Vala compiler to
introduce a wrongly assert on `(filter != NULL)` in every
implementation of the `get_caps` method implemented in Vala.

5 years agoDon't pass default GLib marshallers for signals
Niels De Graef [Mon, 26 Aug 2019 05:34:30 +0000 (07:34 +0200)]
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.

5 years agoconsolidated IOV_MAX/UIO_MAXIOV handling per GLib + legacy behaviour for osx/ios
Jim Mason [Sat, 7 Sep 2019 11:32:40 +0000 (12:32 +0100)]
consolidated IOV_MAX/UIO_MAXIOV handling per GLib + legacy behaviour for osx/ios

5 years agogst_writev: respect IOV_MAX for the writev iovec array #439
Jim Mason [Fri, 6 Sep 2019 18:23:01 +0000 (19:23 +0100)]
gst_writev: respect IOV_MAX for the writev iovec array #439

5 years agopad: Added gst_pad_get_single_internal_link
Vivia Nikolaidou [Wed, 4 Sep 2019 13:59:58 +0000 (16:59 +0300)]
pad: Added gst_pad_get_single_internal_link

gst_pad_iterate_internal_links is usually used to find a single internal
link that a pad has, e.g. to find the corresponding pad of a multiqueue.
Added a helper function that will return either a single internal link,
if there's no other, or NULL.

5 years agominiobject: free qdata array when the last qdata is removed
David Svensson Fors [Tue, 3 Sep 2019 08:38:13 +0000 (10:38 +0200)]
miniobject: free qdata array when the last qdata is removed

In cases with many long-lived buffers that have qdata only very
briefly, the memory overhead of keeping an array of 16 GstQData
structs for each buffer can be significant. We free the array when
the last qdata is removed, like it was done in 1.14.

Fixes #436

5 years agobin: Fix minor race when adding to a bin
Nicolas Dufresne [Tue, 3 Sep 2019 17:44:24 +0000 (13:44 -0400)]
bin: Fix minor race when adding to a bin

This patch simply add a null check around a case where a child may have
been unparented concurrently to the deep_add_remove operation. This was
found by accident in the form of an "IS_GST_OBJECT" assertion, but had
no other known side effect in that test.

5 years agolibcheck: fix macos werror build
Matthew Waters [Fri, 30 Aug 2019 02:04:40 +0000 (12:04 +1000)]
libcheck: fix macos werror build

../libs/gst/check/libcheck/check.c:617:15: error: result of comparison of constant 4294967295 with expression of type 'clockid_t' is always false [-Werror,-Wtautological-constant-out-of-range-compare]
  if (clockid == -1) {
      ~~~~~~~ ^  ~~

5 years agofile/fdsrc: use struct stat64 on android to match stat64()
Matthew Waters [Wed, 28 Aug 2019 05:19:54 +0000 (15:19 +1000)]
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);
                                     ^

5 years agocheck: fix werror build with clang
Matthew Waters [Mon, 26 Aug 2019 12:36:25 +0000 (22:36 +1000)]
check: fix werror build with clang

Silence -Wformat-nonliteral warnings from the internal copy of libcheck

../subprojects/gstreamer/libs/gst/check/libcheck/check.c:379:29: warning: format string is not a string literal [-Wformat-nonliteral]
    vsnprintf (buf, BUFSIZ, msg, ap);
                            ^~~
../subprojects/gstreamer/libs/gst/check/libcheck/check_error.c:48:21: warning: format string is not a string literal [-Wformat-nonliteral]
  vfprintf (stderr, fmt, args);
                    ^~~
../subprojects/gstreamer/libs/gst/check/libcheck/check_str.c:92:29: warning: format string is not a string literal [-Wformat-nonliteral]
    n = vsnprintf (p, size, fmt, ap);
                            ^~~

5 years agoobject: Use g_object_notify_by_pspec()
Niels De Graef [Sun, 25 Aug 2019 17:37:30 +0000 (19:37 +0200)]
object: 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.

5 years agogst-launch: Use gst_print* instead of g_print* to fix broken stdout on Windows
Seungha Yang [Mon, 19 Aug 2019 16:02:48 +0000 (01:02 +0900)]
gst-launch: Use gst_print* instead of g_print* to fix broken stdout on Windows

Concurrent Windows' colored debug message and g_print will print
string hard to read. Instead, use gst_print* which serialize
debug output and the APIs call.

5 years agoinfo: Take lock around all prinf on Windows
Seungha Yang [Mon, 19 Aug 2019 15:59:15 +0000 (00:59 +0900)]
info: Take lock around all prinf on Windows

On Windows, concurrent colored gstreamr debug output and usual
stdout/stderr string will cause broken output on terminal.
Since it's OS specific behavior, that's hard to completely avoid it
but we can protect it at least among our printing interfaces side.

5 years agodocstrings: port ulinks to markdown links
Mathieu Duponchelle [Fri, 23 Aug 2019 16:17:41 +0000 (18:17 +0200)]
docstrings: port ulinks to markdown links

5 years agoutils: Avoid memory merge in gst_util_dump_buffer()
Johan Sternerup [Tue, 20 Aug 2019 15:18:31 +0000 (17:18 +0200)]
utils: Avoid memory merge in gst_util_dump_buffer()

For buffers with multiple memory chunks, gst_buffer_map() has the side
effect of merging the memory chunks into one contiguous
chunk. Since gst_util_dump_mem() used gst_buffer_map() the internals
of the buffer could actually change as a result of printing it.

For the case of a buffer containing several memory chunks,
gst_memory_map() is now used to obtain the memory address and each
memory chunk is dumped separately preceded by a header line. The
behaviour for a buffer containing a single memory chunk is left unchanged.

5 years agoaggregator: Always handle serialized events/queries directly before waiting
Sebastian Dröge [Mon, 19 Aug 2019 15:19:50 +0000 (18:19 +0300)]
aggregator: Always handle serialized events/queries directly before waiting

Otherwise it can happen that we start waiting for another pad, while one
pad already has events that can be handled and potentially also a buffer
that can be handled. That buffer would then however not be accessible by
the subclass from GstAggregator::get_next_time() as there would be the
events in front of it, which doesn't allow the subclass then to
calculate the next time based on already available buffers.

As a side-effect this also allows removing the duplicated event handling
code in the aggregate function as we'll always report pads as not ready
when there is a serialized event or query at the top of at least one
pad's queue.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/428

5 years agomeson: fix warning about configure_file() install kwarg
Tim-Philipp Müller [Thu, 15 Aug 2019 11:56:06 +0000 (12:56 +0100)]
meson: fix warning about configure_file() install kwarg

The install kwarg on configure_file() was only added in
Meson 0.50 but we're targetting older versions as well,
which caused a warning. The install kwarg is not needed
here as we specify install_dir, so we can just drop it.

Fixes #379

5 years agoaggregator: Add sink_event_pre_queue() and sink_query_pre_queue() vfuncs
Sebastian Dröge [Wed, 14 Aug 2019 11:25:48 +0000 (14:25 +0300)]
aggregator: Add sink_event_pre_queue() and sink_query_pre_queue() vfuncs

These allow subclasses catching serialized events/queries before they're
queued up.

5 years agoaggregator: Add GstAggregator::negotiate()
Sebastian Dröge [Wed, 14 Aug 2019 07:05:53 +0000 (10:05 +0300)]
aggregator: Add GstAggregator::negotiate()

For consistency with other base classes and for allowing to completely
override the negotiation behaviour.

5 years agoaggregator: Actually handle NEED_DATA return from update_src_caps()
Sebastian Dröge [Wed, 14 Aug 2019 06:51:55 +0000 (09:51 +0300)]
aggregator: Actually handle NEED_DATA return from update_src_caps()

The documentation says that this allows the subclass to signal that it
needs more data before it can decide on caps, so let's actually
implement it that way.

5 years agoaggregator: Assert if the sink/src pad type that is to be used is not a GstAggregator...
Sebastian Dröge [Tue, 13 Aug 2019 16:57:08 +0000 (19:57 +0300)]
aggregator: Assert if the sink/src pad type that is to be used is not a GstAggregatorPad or subclass thereof

5 years agoaggregator: Ensure that the source pad is created as a GstAggregatorPad if no type...
Sebastian Dröge [Tue, 13 Aug 2019 16:55:59 +0000 (19:55 +0300)]
aggregator: Ensure that the source pad is created as a GstAggregatorPad if no type is given in the pad template

Otherwise we would create a GstPad and that causes invalid memory
accesses later.

5 years agolatency: fix custom event leaks
Guillaume Desmottes [Tue, 6 Aug 2019 04:39:22 +0000 (10:09 +0530)]
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.

5 years agoelement: Added gst_element_get_current_clock_time and gst_element_get_current_running...
Jan Alexander Steffens (heftig) [Mon, 12 Aug 2019 08:53:33 +0000 (11:53 +0300)]
element: Added gst_element_get_current_clock_time and gst_element_get_current_running_time

Helper functions for getting the element clock's time, and the clock
time minus base time, respectively.

5 years agoregistry: Use plugin directory from the build system for relocateable Windows builds
Sebastian Dröge [Thu, 8 Aug 2019 10:49:07 +0000 (13:49 +0300)]
registry: Use plugin directory from the build system for relocateable Windows builds

Instead of guessing something based on preprocessor defines and magic.

5 years agodevice-monitor: list hidden providers before listing devices
Thibault Saunier [Tue, 30 Apr 2019 21:24:50 +0000 (17:24 -0400)]
device-monitor: list hidden providers before listing devices

The way it was implemented could make the list updated after the
list of device was filled with supposdely hidden devices

5 years agofunnel: fix documentation
Mathieu Duponchelle [Tue, 6 Aug 2019 13:28:58 +0000 (15:28 +0200)]
funnel: fix documentation

funnel no longer sends its own segment since:

bbb26f875692a6cd84050c545ba85a7d2129cf5d

Update the documentation to reflect that

5 years agomessage: fix up enum value for GST_MESSAGE_DEVICE_CHANGED
Tim-Philipp Müller [Mon, 5 Aug 2019 23:05:22 +0000 (00:05 +0100)]
message: fix up enum value for GST_MESSAGE_DEVICE_CHANGED

This was added in 1.16 and accidentally duplicated the value of
the existing GST_MESSAGE_REDIRECT.

As the only known user of this message is GStreamer core itself,
and it is quite an obscure message, it seems best to just fix up
the enum value even if that technically breaks API.

Fixes #418

5 years agoRemoves unnecessary "Sissy" pejorative from configure.ac warning message.
Keri Henare [Tue, 6 Aug 2019 03:16:35 +0000 (03:16 +0000)]
Removes unnecessary "Sissy" pejorative from configure.ac warning message.

5 years agoinfo: Fix deadlock in gst_ring_buffer_logger_log
Doug Nazar [Wed, 31 Jul 2019 01:40:47 +0000 (21:40 -0400)]
info: Fix deadlock in gst_ring_buffer_logger_log

gst_ring_buffer_logger_log calls several functions while formatting
the message which may in turn log a message while we already hold
the mutex. Do all formatting first before acquiring the mutex to
avoid this and reduce the time we hold the mutex.

5 years agotracers: set MAY_BE_LEAKED on tracer records
Guillaume Desmottes [Fri, 2 Aug 2019 07:37:58 +0000 (13:07 +0530)]
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.

5 years agodownloadbuffer: Check for flush after seek
Alicia Boya García [Mon, 22 Jul 2019 15:06:20 +0000 (15:06 +0000)]
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.

5 years agoidentity: Non-live upstream have no max latency
Nicolas Dufresne [Sat, 20 Jul 2019 01:57:09 +0000 (21:57 -0400)]
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).

5 years agoaggregator: drop duplicated SEEK events
Mathieu Duponchelle [Fri, 19 Jul 2019 15:28:25 +0000 (17:28 +0200)]
aggregator: drop duplicated SEEK events

This is similar to what demuxers do, and necessary when multiple
sinks get seeked downstream of the aggregator: if we forward
duplicated seeks upstream, elements such as demuxers may drop
the flushing seeks, but return TRUE, aggregator then waits forever
for the flushing events.

Fixes #276

5 years agobasesrc: fix g-i warnings
Tim-Philipp Müller [Fri, 19 Jul 2019 10:09:22 +0000 (11:09 +0100)]
basesrc: fix g-i warnings

5 years agoinfo: Free some more memory on gst_deinit()
Sebastian Dröge [Sun, 14 Jul 2019 19:41:56 +0000 (22:41 +0300)]
info: Free some more memory on gst_deinit()

5 years agoinfo: Deprecate gst_debug_category_free()
Sebastian Dröge [Sun, 14 Jul 2019 18:36:00 +0000 (21:36 +0300)]
info: Deprecate gst_debug_category_free()

And change it to do nothing at all.

As debug categories don't use reference counting and they can be
retrieved from anywhere at any time by name, it is fundamentally unsafe
to free them at any point in time except for right before the end of the
process.

No code apart from a unit test seems to be currently using the function,
so deprecate it and also change it to do nothing at all.

5 years agoidentity: Fix the ts-offset property getter
Philippe Normand [Thu, 11 Jul 2019 16:53:53 +0000 (17:53 +0100)]
identity: Fix the ts-offset property getter

Previous code was a copy/paste from the property setter function.

5 years agoaggregator: Make parsing of explicit sink pad names more robust
Sebastian Dröge [Mon, 8 Jul 2019 16:09:03 +0000 (19:09 +0300)]
aggregator: Make parsing of explicit sink pad names more robust

When passing "sink_%d" twice to aggregator before it would create two
pads called "sink_0", because it failed to parse "%d" as integer and
used 0 instead then.

Instead validate that parsing was actually successful and also don't
even try to parse if the requested pad name contains a '%'.

5 years agogst-stats: fix leaks
Guillaume Desmottes [Mon, 8 Jul 2019 11:16:08 +0000 (13:16 +0200)]
gst-stats: fix leaks

String returned from g_match_info_fetch() needs to be freed.

5 years agogst-stats: sort latency by first activity before displaying
Guillaume Desmottes [Mon, 8 Jul 2019 09:20:26 +0000 (11:20 +0200)]
gst-stats: sort latency by first activity before displaying

We use to display the latency of each element in random order which is
not very convenient when comparing latency between different runs.
Sort them by "first activity" (the first latency reported for each
element) so it's consistent betwen runs.

This is the same logic when sorting and displaying element stats.

5 years agogsttracerutils: Fix build with disabled tracer hooks.
Jan Schmidt [Sun, 7 Jul 2019 10:42:56 +0000 (20:42 +1000)]
gsttracerutils: Fix build with disabled tracer hooks.

Add a stub gst_tracing_get_active_tracers() call when building
with tracer hooks disabled.

5 years agomultiqueue: Fix possible NULL pointer dereferencing
Thibault Saunier [Tue, 2 Jul 2019 21:14:50 +0000 (17:14 -0400)]
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

5 years agogstinfo: Fix typo in debug log message
Nirbheek Chauhan [Mon, 1 Jul 2019 18:24:19 +0000 (23:54 +0530)]
gstinfo: Fix typo in debug log message

5 years agoleakstracer: Improve notes in the the get-live-objects API docs
Tim-Philipp Müller [Mon, 1 Jul 2019 14:50:13 +0000 (20:20 +0530)]
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.

5 years agotests: Add test for new activity-tracking leaktracer API
Nirbheek Chauhan [Mon, 1 Jul 2019 09:35:58 +0000 (15:05 +0530)]
tests: Add test for new activity-tracking leaktracer API

5 years agoleakstracer: Add API for tracking and checkpointing objects
Nirbheek Chauhan [Fri, 21 Jun 2019 12:47:13 +0000 (18:17 +0530)]
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.

5 years agotests: Add test for new live-objects leaktracer API
Nirbheek Chauhan [Mon, 1 Jul 2019 09:35:08 +0000 (15:05 +0530)]
tests: Add test for new live-objects leaktracer API

Needs a valgrind suppression for:

==11119== Warning: invalid file descriptor -1 in syscall close()
==11119== Warning: invalid file descriptor -1 in syscall close()
==11119== Syscall param write(buf) points to uninitialised byte(s)
==11119==    at 0x4C4AFAD: syscall (in /usr/lib64/libc-2.29.so)
==11119==    by 0x4E70DF9: write_validate (Ginit.c:112)
==11119==    by 0x4E70DF9: UnknownInlinedFun (Ginit.c:148)
==11119==    by 0x4E70DF9: mincore_validate (Ginit.c:131)
==11119==    by 0x4E70CC3: UnknownInlinedFun (Ginit.c:208)
==11119==    by 0x4E70CC3: access_mem (Ginit.c:242)
==11119==    by 0x4E75536: UnknownInlinedFun (libunwind_i.h:168)
==11119==    by 0x4E75536: apply_reg_state (Gparser.c:863)
==11119==    by 0x4E75A71: _ULx86_64_dwarf_step (Gparser.c:952)
==11119==    by 0x4E71BD3: _ULx86_64_step (Gstep.c:71)
==11119==    by 0x48BAF47: generate_unwind_trace (gstinfo.c:2726)
==11119==    by 0x48BC92E: gst_debug_get_stack_trace (gstinfo.c:2908)
==11119==    by 0x49B2BB2: handle_object_created.part.0 (gstleaks.c:384)
==11119==    by 0x488134E: gst_object_constructed (gstobject.c:141)
==11119==    by 0x49EC61B: g_object_new_internal (gobject.c:1845)
==11119==    by 0x49EE347: g_object_new_valist (gobject.c:2128)
==11119==    by 0x49EE69C: g_object_new (gobject.c:1648)
==11119==    by 0x48CA59D: gst_pad_new_from_template (gstpad.c:867)
==11119==    by 0x68C209E: gst_base_src_init (gstbasesrc.c:454)
==11119==    by 0x4A0A0C3: g_type_create_instance (gtype.c:1858)
==11119==    by 0x49EC42C: g_object_new_internal (gobject.c:1805)
==11119==    by 0x49EDB14: g_object_new_with_properties (gobject.c:1973)
==11119==    by 0x49EE6C0: g_object_new (gobject.c:1645)
==11119==    by 0x48AF91A: gst_element_factory_create (gstelementfactory.c:372)
==11119==  Address 0x1ffeffe000 is on thread 1's stack
==11119==  in frame #6, created by generate_unwind_trace (gstinfo.c:2695)

Fixed in libunwind commit:
https://github.com/libunwind/libunwind/commit/b256722d49a63719c69c0416eba9163a4d069584

Needs a separate suppression for Debian because the callstack is
different there.

5 years agoleakstracer: Add API for logging leaks in the debug log
Nirbheek Chauhan [Fri, 28 Jun 2019 12:49:31 +0000 (18:19 +0530)]
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.

5 years agoleakstracer: Add API for fetching leaked objects
Nirbheek Chauhan [Fri, 28 Jun 2019 12:49:31 +0000 (18:19 +0530)]
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.

5 years agogsttracer: Add new API to fetch the list of active tracers
Nirbheek Chauhan [Tue, 18 Jun 2019 22:52:42 +0000 (04:22 +0530)]
gsttracer: Add new API to fetch the list of active tracers

This will be useful in the next commit where we add action-signals on
the leaks tracer to get information about leaks and to manipulate
checkpoints as a replacement for the SIGUSR1 and SIGUSR2 signals for
doing the same.

5 years agotracers: Allow setting a name for all tracer objects
Nirbheek Chauhan [Tue, 18 Jun 2019 22:17:18 +0000 (03:47 +0530)]
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.

5 years agobufferpool: Fix the buffer size reset code
Nicolas Dufresne [Sat, 29 Jun 2019 13:22:05 +0000 (09:22 -0400)]
bufferpool: Fix the buffer size reset code

The offset in gst_buffer_resize() is additive. So to move back the
offset to zero, we need to pass the opposite of the current offset. This
was raised through the related unit test failingon 32bit as on 64bit
the alignment padding was enough to hide the issue. The test was
modified to also fail on 64bit. This patch will remove spurious
assertions like:

  assertion 'bufmax >= bufoffs + offset + size' failed

Fixes #316

5 years agoleakstracer: Get rid of GSlice usage
Nirbheek Chauhan [Mon, 24 Jun 2019 15:44:51 +0000 (21:14 +0530)]
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

5 years agoleakstracer: Remove unused and redundant record fields
Nirbheek Chauhan [Fri, 21 Jun 2019 05:56:38 +0000 (11:26 +0530)]
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.

5 years agotracerrecord: Be stricter while parsing record templates
Nirbheek Chauhan [Fri, 21 Jun 2019 05:13:18 +0000 (10:43 +0530)]
tracerrecord: Be stricter while parsing record templates

It's not really possible for us to recover when someone uses the
gst_tracer_record_new() API incorrectly. Also, document a piece of
somewhat-obscure code.

5 years agoleakstracer: Improve documentation for the element
Nirbheek Chauhan [Tue, 18 Jun 2019 22:12:46 +0000 (03:42 +0530)]
leakstracer: Improve documentation for the element

Also print a useful g_warning() message when leaks are detected.

5 years agogstcheck: Document strcmp used in string cmp macros
Nirbheek Chauhan [Mon, 1 Jul 2019 09:25:20 +0000 (14:55 +0530)]
gstcheck: Document strcmp used in string cmp macros

strcmp() does not allow the arguments to be NULL, but g_strcmp0()
does, so document that we use g_strcmp0() so that people don't need to
worry about that.

5 years agogstsystemclock: Mark the clock as MAY_BE_LEAKED
Nirbheek Chauhan [Fri, 21 Jun 2019 05:11:18 +0000 (10:41 +0530)]
gstsystemclock: Mark the clock as MAY_BE_LEAKED

It is freed in gst_deinit(), but otherwise it is leaked.

5 years agogstinfo: Rework stack trace detection a bit
Nirbheek Chauhan [Tue, 18 Jun 2019 22:09:59 +0000 (03:39 +0530)]
gstinfo: Rework stack trace detection a bit

Ensure that the code paths for HAVE_UNWIND and HAVE_DBGHELP are never
taken at the same time, even if the build file code changes.

Prefer DbgHelp over libunwind on Windows in case both are somehow
available because DbgHelp is only available when building with the
MSVC toolchain, and libunwind won't give us debug symbols from objects
built with the MSVC toolchain.

Also, print slightly more useful messages for the level of stack trace
support enabled, and document what each if conditional does.

5 years agogstinfo: Add an explicit enum for GST_STACK_TRACE_SHOW_NONE
Nirbheek Chauhan [Tue, 18 Jun 2019 21:49:16 +0000 (03:19 +0530)]
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.

5 years agobasesrc: Add public gst_base_src_negotiate () function
Carlos Rafael Giani [Mon, 24 Jun 2019 12:35:16 +0000 (14:35 +0200)]
basesrc: Add public gst_base_src_negotiate () function

This is useful for when format changes occur mid-stream.

5 years agomultiqueue: Hold weak references to pads/multiqueue in SingleQueue
Thibault Saunier [Thu, 27 Jun 2019 19:51:47 +0000 (15:51 -0400)]
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.

5 years agogstplugin: Don't stat plugins when building for UWP
Nirbheek Chauhan [Mon, 6 May 2019 13:49:47 +0000 (19:19 +0530)]
gstplugin: Don't stat plugins when building for UWP

When using GStreamer with Universal Windows Platform apps, dynamic
plugins can only be loaded by filename (without a path) using
gst_plugin_load_file() which will call into g_module_open().

On Windows, GModule calls LoadLibrary() on the filename, but with
UWP we need to use LoadPackagedLibrary() which is basically the same
as LoadLibrary(), except it looks only for DLLs (by name) that have
been packaged as assets with the app.

These assets are not files and cannot be accessed using normal file
APIs such as open() or stat().

The upstream glib merge request for adding LoadPackagedLibrary support
is: https://gitlab.gnome.org/GNOME/glib/merge_requests/951

NOTE: Whitespcae removal is to make gst-indent happy

5 years agogstconfig.h.in: Windows ARM64 does not allow unaligned access
Nirbheek Chauhan [Wed, 15 May 2019 23:27:16 +0000 (04:57 +0530)]
gstconfig.h.in: Windows ARM64 does not allow unaligned access

5 years agotestclock: Allow calling crank with a past entry
Nicolas Dufresne [Wed, 19 Jun 2019 21:39:58 +0000 (17:39 -0400)]
testclock: Allow calling crank with a past entry

At the moment, we can only use crank if the pending entry is in the
future. This patch leaves the clock time to the same point if the
pending entry was in the past. This still execute a single entry. This
will be needed for the jitterbuffer, since as soon as we stop waking up
the jitterbuffer when the timer is reschedule later, we may endup with
such case in the unit tests.

Related to #608

5 years agomultiqueue: Stop using the gst_pad_element_private API
Thibault Saunier [Sun, 23 Jun 2019 03:46:35 +0000 (23:46 -0400)]
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.

5 years agodevicemonitor: add debug category
Mathieu Duponchelle [Fri, 21 Jun 2019 13:38:15 +0000 (15:38 +0200)]
devicemonitor: add debug category

5 years agoFixing various typos
Michael Bunk [Thu, 20 Jun 2019 12:04:55 +0000 (14:04 +0200)]
Fixing various typos

5 years agolatency: display event pointer in logs
Guillaume Desmottes [Thu, 20 Jun 2019 11:12:01 +0000 (16:42 +0530)]
latency: display event pointer in logs

This is quite useful for debugging when tracer is reporting the wrong
latency because of an element breaking the events/buffers ordering.

5 years agogstelements_private: sync gst_buffer_get_flags_string() with new flags
Guillaume Desmottes [Thu, 20 Jun 2019 08:19:14 +0000 (13:49 +0530)]
gstelements_private: sync gst_buffer_get_flags_string() with new flags

5 years agomultiqueue: never unref queries we do not own
Thibault Saunier [Thu, 20 Jun 2019 03:29:24 +0000 (23:29 -0400)]
multiqueue: never unref queries we do not own

The `query` argument of gst_pad_query is "transfer none".

Query objects are "borrowed" by the pad query handlers and those
should never unref them.

This was leading to double freed queries in a very racy way with nested
GESTimelines.

5 years agogstmeta: Optimize get_tags() by using private quark table
Havard Graff [Mon, 17 Jun 2019 07:50:32 +0000 (09:50 +0200)]
gstmeta: Optimize get_tags() by using private quark table

5 years agopad: increase debug-level to warning for fatal outcomes
Havard Graff [Thu, 13 Jun 2019 08:32:32 +0000 (10:32 +0200)]
pad: increase debug-level to warning for fatal outcomes

5 years agoqueue: don't report 0 max-latency for leaky queue if max was already 0.
Håvard Graff [Thu, 13 Jun 2019 15:21:03 +0000 (15:21 +0000)]
queue: don't report 0 max-latency for leaky queue if max was already 0.

5 years agoharness: move creating of buffer and event queues to harness itself
Havard Graff [Wed, 22 May 2019 08:09:47 +0000 (10:09 +0200)]
harness: move creating of buffer and event queues to harness itself

By only having it on sinkpad-creation, it is racy to write a test
with a sometimes-pad (like a demuxer) that you want to pull from, having
the pull wait until the pad arrives and the buffer can be produced.

5 years agoharness: Fix race when forwarding event while tearing down harness
Stian Selnes [Wed, 3 Oct 2018 11:56:22 +0000 (13:56 +0200)]
harness: Fix race when forwarding event while tearing down harness

5 years agoharness: Make sure pad functions are not called after teardown
Stian Selnes [Mon, 28 May 2018 08:57:13 +0000 (10:57 +0200)]
harness: Make sure pad functions are not called after teardown

For the query function there's a risk that the function may be called
after the harness has been teared down. Since the function accesses a
pointer to the harness via the pad's data, the harness must protect
itself against this.

Event and chain function is also handled for constistency, although
they don't have the same problem since the gstpad.c checks whether the
pad is flushing before calling these.

5 years agoaggregator: don't try to take STREAM_LOCK on sink pad flush
Mathieu Duponchelle [Tue, 11 Jun 2019 20:09:33 +0000 (22:09 +0200)]
aggregator: don't try to take STREAM_LOCK on sink pad flush

This was a misguided effort to try and guarantee the buffers of
the sink pads would not change during aggregate, when an upstream
branch is seeked independently, however this is simply incorrect
as downstream has not necessarily been flushed, or the aggregate
function might be waiting to receive buffers on other pads.

5 years agoaggregator: send flush_stop ourselves if needed
Mathieu Duponchelle [Tue, 11 Jun 2019 13:20:18 +0000 (15:20 +0200)]
aggregator: send flush_stop ourselves if needed

In !159 , we switched to sending flush_start ourselves from the
do_seek implementation. If no flushing seek successfully made its
way upstream, we need to send flush_stop ourselves as well.

5 years agoaggregator: don't hold stream lock when flushing
Mathieu Duponchelle [Mon, 10 Jun 2019 15:23:29 +0000 (17:23 +0200)]
aggregator: don't hold stream lock when flushing

Releasing a GRecMutex from a different thread is undefined
behaviour.

There should be no reason to hold the stream lock from the
moment aggregator receives a flush_start until it receives
the last flush_stop: the source pad task is stopped, and can
only be restarted once the last flush_stop has arrived.

I can only speculate as to the reason why this was done,
as it was that way since the original commit. My best
guess is that aggregator originally didn't marshall events
and queries to the aggregate thread, and this somehow
helped work around this.

5 years agoaggregator: refactor flushing logic
Mathieu Duponchelle [Wed, 22 May 2019 19:37:43 +0000 (21:37 +0200)]
aggregator: refactor flushing logic

Instead of tracking "pending_flush_*" on the pads and the
aggregator, we now simply track the last seqnum for flush start
and flush stop events on the pads, and use it to determine whether
we should enter or exit our flushing state.

See https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/977

5 years agovalgrind: revert generic suppression of ld-related errors
Mathieu Duponchelle [Wed, 5 Jun 2019 16:40:12 +0000 (18:40 +0200)]
valgrind: revert generic suppression of ld-related errors

the replacement suppression casts way too large a net, ignoring
all leaks in the main thread

5 years agovalgrind: ignore dlopen leaks when parsing launch lines
Mathieu Duponchelle [Wed, 5 Jun 2019 18:58:45 +0000 (20:58 +0200)]
valgrind: ignore dlopen leaks when parsing launch lines

5 years agovalgrind: suppress intentional debug list item leak
Mathieu Duponchelle [Wed, 5 Jun 2019 18:58:45 +0000 (20:58 +0200)]
valgrind: suppress intentional debug list item leak

5 years agoconcat: Improve debug output a bit
Sebastian Dröge [Tue, 4 Jun 2019 14:56:30 +0000 (17:56 +0300)]
concat: Improve debug output a bit

5 years agoconcat: Reset last_stop on FLUSH_STOP too
Sebastian Dröge [Tue, 4 Jun 2019 14:55:30 +0000 (17:55 +0300)]
concat: Reset last_stop on FLUSH_STOP too

Otherwise when seeking backwards we would keep the last_stop at the last
position we saw until playback passed the seek position again, and if
switching to the next pad happens in the meantime we would set the wrong
offset in the outgoing segment.

5 years agoUse G_DEFINE_AUTOPTR_CLEANUP_FUNC unconditionally
Niels De Graef [Tue, 4 Jun 2019 06:50:59 +0000 (08:50 +0200)]
Use G_DEFINE_AUTOPTR_CLEANUP_FUNC unconditionally

Since we started depending on GLib 2.44, we can be sure this macro is
defined (it will be a no-op on compilers that don't support it). For
plugins we should just start using `G_DECLARE_FINAL_TYPE` which means
we no longer need the macro there, but for most types in core we don't
want to break ABI, which means it's better to just keep it like it is
(and use the `#ifdef` instead).

5 years agomeson: Bump minimal GLib version to 2.44
Niels De Graef [Fri, 31 May 2019 20:56:09 +0000 (22:56 +0200)]
meson: Bump minimal GLib version to 2.44

This means we can use some newer features and get rid of some
boilerplate code using the `G_DECLARE_*` macros.

As discussed on IRC, 2.44 is old enough by now to start depending on it.

5 years agodocs: unprefix subproject paths
Mathieu Duponchelle [Sat, 1 Jun 2019 00:37:26 +0000 (02:37 +0200)]
docs: unprefix subproject paths

5 years agodocs: Add tracers support
Thibault Saunier [Fri, 31 May 2019 03:23:35 +0000 (23:23 -0400)]
docs: Add tracers support