Commit graph

8553 commits

Author SHA1 Message Date
Matthew Waters 0cc42f9dc6 element: NULL the lists of contexts in dispose()
If dispose() is called more than once, we may double unref the list of
GstContext's.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/877>
2021-08-27 14:08:08 +01:00
Mathieu Duponchelle e846ef2221 gstvalue: don't write to const char *
Our various deserializing functions require NULL terminators
to not over consume substrings (eg fields of an array). Instead
of writing a NULL terminator to the passed-in string, which may
result in segfaults, make a copy of the substring we're interested
in.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/446

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/674>
2020-10-14 00:59:03 +01:00
Roman Shpuntov cc13705855 systemclock: Fix clock time conversion on Windows/xbox
The returned ratio can be bigger than GST_SECOND, in which case we would
forever return 0 for the system clock time. Even in other cases if it's
close to GST_SECOND it would result in accuracy loss.

Instead of doing the division by GST_CLOCK_TIME_NONE during
initialization once, do it every time the clock time is requested.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/575

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/635>
2020-09-25 01:35:16 +00:00
Mathieu Duponchelle 1baa2ba9f0 gstmeta: intern registered impl string
Subsequent lookups in the hashtable are probably better done
on memory we're confident is allocated to us :)

It was easy to trigger invalid reads by calling gst_meta_register
with dynamically allocated memory, freeing that memory, then
calling gst_meta_get_info()

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/647>
2020-09-24 19:13:13 +00:00
Tim-Philipp Müller e9e2069de5 buffer: improve seqnum fallback warning message
Print target CPU we're building for.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/645>
2020-09-24 17:50:01 +00:00
Tim-Philipp Müller 0a6f93df2d buffer: fix meta sequence number fallback on rpi
The global seqnum variable wasn't actually increased in
the fallback code path, leading to all buffers getting
a seqnum of 0. Which also made the unit test fail.

This affects platforms/toolchains that don't have
64-bit atomic ops such as when compiling for armv7 rpi.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/645>
2020-09-24 17:50:01 +00:00
Christoph Reiter bc566d2859 gstelementfactory: Fix missing features in case a feature moves to another filename
In case a plugin filename was renamed with the plugin being in the registry cache
the features were not loaded after the rename:

1) Cache of old/gone filename was loaded, features added
2) New filename was loaded, features where not added because
   they were already found in the registry.
3) In the end stale cache entries for files which are no longer there
   are removed, including the wanted features.
4) The cache gets updated without the features.

Fix this by also checking at (2) that the found feature is from the loaded plugin
and not from some stale cache entry.

This affected directsoundsink where libgstdirectsoundsink.dll was renamed
to libgstdirectsound.dll, losing the directsoundsink element in the process.

Fixes #290

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/643>
2020-09-24 16:28:54 +00:00
Sebastian Dröge d0eb870c14 element: When removing a ghost pad also unset its target
Otherwise the proxy pad of the ghost pad still stays linked to some
element inside the bin, which is not allowed anymore according to the
topology.

In 2.0 this should be fixed more generically from inside GstGhostPad but
currently there is no way to get notified that the ghost pad is
unparented.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/642>
2020-09-24 16:40:53 +01:00
Edward Hervey c33f859aa0 gst: Delay creation of threadpools
Since glib 2.64, gthreadpool will start waiting on a GCond immediately upon
creation. This can cause issues if we fork *before* actually using the
threadpool since we will then be signalling that GCond ... from another process
and that will never work.

Instead, delay creationg of thread pools until the very first time we need
them. This introduces a minor (un-noticeable) delay when needing a new thread
but fixes the issues for all users of GSTreamer that will call gst_init, then
fork and actually start pipelines.

See https://gitlab.gnome.org/GNOME/glib/-/issues/2131 for more context.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/634>
2020-09-21 15:46:39 +00:00
Nirbheek Chauhan 80c753c4a9 registry: Print the pointer when printing features
This is what we do everywhere else too, useful for debugging.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/636>
2020-09-21 10:18:59 +00:00
Nirbheek Chauhan f83bf11d75 registry: Use a toolchain-specific registry file on Windows
If we load a plugin registry for MinGW plugins when running with MSVC,
we will have to write out the whole cache again, and vice-versa. Just
use separate cache files so that the cache is actually useful.

Closes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/427

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/636>
2020-09-21 10:18:59 +00:00
Thibault Saunier c666a9a7e1 value: Fix segfault comparing empty GValueArrays
Adding a test
2020-06-07 01:41:52 +01:00
Ondřej Hruška 7b0e6f3e62 gstdatetime: Add missing NULL check to gst_date_time_new_local_time
Also add a unit test for this.

Fixes #524
2020-06-04 22:59:10 +00:00
Miguel Paris 687c0f0ce7 bufferlist: foreach: always remove as parent if buffer is changed
In case the buffer is not writable, the parent (the BufferList) is not
removed before calling func. So if it is changed, the parent (the BufferList)
of the previous buffer should be removed after calling func.
2020-06-04 21:49:02 +00:00
Sebastian Dröge a1c0ca3ac0 bus: Make setting/replacing/clearing the sync handler thread-safe
Previously we would use the object lock only for storing the sync
handler and its user_data in a local variable, then unlock it and only
then call the sync handler. Between unlocking and calling the sync
handler it might be unset and the user_data be freed, causing it to be
called with a freed pointer.

To prevent this add a refcounting wrapper struct around the sync
handler, hold the object lock while retrieving it and increasing the
reference count and only actually free it once the reference count
reaches zero.

As a side-effect we can now also allow to actually replace the sync
handler. Previously it was only allowed to clear it after initially
setting it according to the docs, but the code still allowed to clear it
and then set a different one.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/506
2020-02-14 18:51:35 +00:00
Thibault Saunier cdf7d802db 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
2020-02-05 09:08:31 +00:00
Jan Alexander Steffens (heftig) 63f0b31dbf bin: Fix deep-element-removed log message
child and bin were switched.

https://gitlab.freedesktop.org/gstreamer/gstreamer/merge_requests/354
2020-01-09 20:20:47 +00:00
Mathieu Duponchelle 5c47fe6118 Revert "element: Enforce that elements created by gst_element_factory_create/make() are floating"
See https://gitlab.freedesktop.org/gstreamer/gstreamer/merge_requests/333

The reference we receive when calling g_object_new should be
floating, but we can't force it at our level.

This reverts commit ce43de8690.
2019-12-05 10:45:49 +01:00
Mathieu Duponchelle 3c21d6a29f Revert "device: Enforce that elements created by gst_device_create_element() are floating"
See https://gitlab.freedesktop.org/gstreamer/gstreamer/merge_requests/333

The reference we receive when calling g_object_new should be
floating, but we can't force it at our level.

This reverts commit cc6342d853.
2019-12-05 10:45:10 +01:00
Tim-Philipp Müller 7105428470 Revert "gst/parse: define pure-parser depending on bison version"
This reverts commit 77141834bb.

This breaks the autotools build and it seems too much effort to
fix that up just to fix a bison warning.
2019-12-03 10:40:44 +00:00
Víctor Manuel Jáquez Leal 77141834bb gst/parse: define pure-parser depending on bison version
After release bison 2.5 the declaration %pure-parser was deprecated
in favor of %define api.pure

Nonetheless, until bison 3.4, the declaration was treated as backward
compatibility, but now bison shows a warning:

  warning: deprecated directive, use ‘%define api.pure’

The patch's approach is to handle both directives according with the
used bison's version, by string replacement at source configuration
stage.
2019-11-05 15:25:23 +00:00
Sebastian Dröge e6f55805b4 bin: Drop need-context messages without source instead of crashing 2019-10-24 12:58:54 +01:00
Sebastian Dröge 0c6f5b3e4c 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.
2019-10-01 13:45:31 +00:00
Seungha Yang 32b7108d54 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.
2019-10-01 12:40:32 +01:00
Sebastian Dröge ce43de8690 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
2019-09-15 00:26:54 +01:00
Sebastian Dröge cc6342d853 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
2019-09-15 00:26:54 +01:00
Sebastian Dröge 937a6ca6d3 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
2019-09-15 00:26:54 +01:00
David Svensson Fors e6bd5b4193 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
2019-09-08 19:42:59 +00:00
Nicolas Dufresne 94ba1cea88 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.
2019-09-03 22:27:38 +01:00
Sebastian Dröge 684796f45a registry: Use plugin directory from the build system for relocateable Windows builds
Instead of guessing something based on preprocessor defines and magic.
2019-08-09 12:29:37 +01:00
Tim-Philipp Müller dc7b9cec1e 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
2019-08-09 09:10:04 +01:00
Doug Nazar 815acd88ee 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.
2019-08-09 00:27:04 +01:00
Nicolas Dufresne 53bf06c088 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
2019-08-08 18:49:40 +01:00
Edward Hervey 53e879c750 gstpad: Probes that return HANDLED can reset the data info field
Before GST_PAD_PROBE_HANDLED was introduced, we had to handle the case
where some probes would reset the probe info data field to NULL. This would
be considered an invalid use-case.

But with GST_PAD_PROBE_HANDLED it is totally fine to reset that, since
the probe has "handled" it.
2019-08-08 09:49:31 +01:00
Nirbheek Chauhan 3a8910f53b meson: Link to objects instea of static helper library
Otherwise the objects from that static helper library are not included
in the gstreamer-1.0 static library. This was supposed to be fixed in
Meson, but the pull request hasn't been merged yet:
https://github.com/mesonbuild/meson/pull/3939

Closes https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/398
2019-08-08 00:01:09 +01:00
Nirbheek Chauhan f5ed89dc83 meson: Pass -DGST_STATIC_COMPILATION for static builds
This is only needed on Windows when building with MSVC, but it is safe
to pass it everywhere.

Closes https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/398
2019-08-08 00:01:09 +01:00
Niels De Graef a8ec2d9910 gst: Add support for g_autoptr(GstPromise) 2019-08-07 13:53:41 +01:00
Niklas Hambüchen 8cf0df152a Make get_flex_version.py script executable
Like all other scripts in the same dir.

It has a hashbang, so it should be executable.
2019-08-07 11:10:36 +01:00
Sebastian Dröge 66ce092881 caps: Add Since: 1.16 marker to gst_caps_copy() 2019-08-06 16:00:11 +01:00
Sebastian Dröge 2fa00da84e gst: Fix various Since markers 2019-08-06 16:00:11 +01:00
Mathieu Duponchelle dc5a62f702 gstinfo: clean up function pointer names hashtable
And add strduped function pointer names to the global quark
table, so that they don't get reported as lost by valgrind.

This allows us to use GST_DEBUG when running tests under
valgrind.
2019-04-17 23:03:56 +02:00
Philipp Zabel b99bca2790 event: fix seek event creation
Creating seek events segfaults on 32-bit ARM since commit 2fa15d5371
('event: add new seek parameter, "trickmode-interval"'), which missed
casting the trickmode-interval initializer in the variable argument list
to guint64.
2019-04-12 18:30:12 +02:00
Sebastian Dröge e0c9d4f879 controlbinding: Check if the weak pointer was cleared before explicitly removing it
Otherwise we'll get an assertion if the object behind the weak pointer
was already destroyed in the meantime as we would pass NULL as first
argument to g_object_remove_weak_pointer().
2019-04-10 10:18:54 +03:00
Mathieu Duponchelle 2fa15d5371 event: add new seek parameter, "trickmode-interval"
When performing a key unit trickmode seek, it may be useful to
specify a minimum interval between the output frames, either
in very high rate cases, or as a protection against streams
that may contain an overly large amount of key frames.

One use case is ONVIF Section 6.5.3:

<https://www.onvif.org/specs/stream/ONVIF-Streaming-Spec.pdf>
2019-04-01 17:13:32 +00:00
Stephane Cerveau a01c4965de gst_element_get_factory: update documentation
Inform about a potential NULL result.
2019-03-14 13:12:52 +01:00
Stephane Cerveau b5af526c9c gst_element_factory_get_metadata: protect from null factory 2019-03-13 18:46:14 +01:00
Santiago Carot-Nemesio 706e10ad05 gsttaskpool: Do not block tasks while cleaning up the taskpool
There is a deadlock if any thread from the pool tries to push
a new task while other thread is waiting for the pool of threads
to finish. With this patch the thread will get an error when it
tries to add a new task while the taskpool is being cleaned up.
2019-03-08 17:27:30 +01:00
Marco Trevisan (Treviño) b5286f0560 gsturi: Fix annotation on get_path to return a nullable
Use proper syntax or the (nullable): part will be part of the description
2019-03-06 19:46:46 +01:00
Marco Trevisan (Treviño) 951dc50d34 gstmessage: Fix annotations on details
Details argument should be nullable, but the docstring uses a wrong syntax.
2019-03-06 19:34:12 +01:00
Mathieu Duponchelle 5dc149f4f2 gstbuffer: store meta in add order
The previous implementation of add was implemented as a prepend,
switch to append as that seems like the expected order.
2019-03-04 12:57:02 +00:00