Commit graph

8673 commits

Author SHA1 Message Date
Edward Hervey
79374b8d94 value: Fix comparison of int/int64 ranges
ranges are only equal if:
* Their bounds are equal
* And their step value are equal *IF* they contain more than one value

https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/253
2020-05-25 08:29:21 +02:00
Edward Hervey
7f068512ec gstbin: Remove mentions of duration caching
This was effectively disabled in 1.0 with the intent of maybe re-enabling it.

The problem is that caching duration at a bin level doesn't make much sense
since there might be queueing/buffering taking place internally and therefore
the duration reported might have no correlation to what is actually being
outputted.

Remove commented code and fixmes, and update documentation

Fixes #4

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/489>
2020-05-18 15:37:20 +02:00
Edward Hervey
3c7db917dd gstvalue: Minor list intersection optimization
When matching against the 2nd list, increment the starting position of the inner
list iteration.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/484>
2020-05-14 12:19:58 +02:00
Xu Guangxin
003b25f39d bufferpool: unblock acquire thread when we discard buffer
else the acquire thread will wait infinitely.
The deadlock showed in prevous unit test commit. This will fix it

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/470>
2020-05-14 07:04:02 +00:00
Edward Hervey
2536cf7c57 gstvalue: Fix segment (de)serialization
By using the proper quarks (stored in the indirection table) and not the *enums*
of those entry in the quark table.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/473>
2020-05-08 17:21:20 +02:00
Matej Knopp
cab5b22f21 taglist: Fix crash when comparing two lists of the same length but with different items
Fixes #549

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/469>
2020-05-08 11:04:14 +03:00
Edward Hervey
81752169a4 taglist: Make equality check more uniform
Previously this was iterating over taglists with ... string names.

Instead use the same technique as `gst_structure_is_equal()` with the additional
double check.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/466>
2020-05-06 12:00:46 +02:00
Sebastian Dröge
a3c7e1c9b9 registrybinary: Also call fclose() if fflush()/fsync() failed
Otherwise we would be leaking the file in error cases.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/465>
2020-05-06 07:33:42 +00:00
Sebastian Dröge
0d1fe824e2 registrybinary: Don't call fclose() more than once
We must not retry fclose() on EINTR as POSIX states:

  After the call to fclose(), any use of stream results in undefined
  behavior.

We ensure above with fflush() and fsync() that everything is written out
so chances of running into EINTR are very low. Nonetheless assume that
the file can't be safely renamed, we'll just try again on the next
opportunity.

CID #1462697

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/465>
2020-05-06 07:33:42 +00:00
Thibault Saunier
c740c10404 segment: Enhance the GstSegment structure documentation
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/435>
2020-05-05 20:52:11 +00:00
Richard Kreckel
96ebee1dc8 registrybinary: Use a FILE* in BinaryRegistryCache...
...instead of a file descriptor so buffered I/O is used when writing
the binary cache. This boosts performance at startup, particularly on
network filesystems where writes may be quite slow.

Fixes gstreamer#545.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/458>
2020-05-05 12:27:46 +00:00
Edward Hervey
ca2994700e gstvalue: Use quark-based structure usage for segment (de)serialization
Instead of string-based one. Smaller and faster code

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/453>
2020-05-05 10:17:49 +00:00
Edward Hervey
d539d619e4 value: Handle runtime checks as such
The various `g_strdup_printf()` returns values are runtime checks
which could be disabled if one wants and therefore should be
handled as such with g_return_val_if_fail()

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/453>
2020-05-05 10:17:49 +00:00
Edward Hervey
be76ba1312 gstvalue: Remove useless checks
The calling function already checks that the values exists and it's
a valid list

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/453>
2020-05-05 10:17:49 +00:00
Edward Hervey
761bdc9e5c gstvalue: Use previous assumption
The types were already checked for equality just before, not need to
check for that again

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/453>
2020-05-05 10:17:49 +00:00
Edward Hervey
9af9113c4a gstvalue: Use comparision functions directly
We know the types of values, just use the comparision function directly

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/453>
2020-05-05 10:17:49 +00:00
Edward Hervey
f800559789 gstvalue: Minor optimization for checks
For value types that aren't subclassable, just check the type directly.
For flags, compare against the fundamental type directly instead of going through
the more expensive recursive check of `G_TYPE_CHECK_VALUE_TYPE()`

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/453>
2020-05-05 10:17:49 +00:00
Edward Hervey
dc7efe296d gstvalue: Optimize list subset some more
Avoid going through the double subtract function when comparing
anything to a list.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/453>
2020-05-05 10:17:49 +00:00
Edward Hervey
46449cbb76 gstvalue: Optimize gst_value_compare_list
The compare function only needs to be retrieved once and used
directly

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/453>
2020-05-05 10:17:49 +00:00
Edward Hervey
ee4d2f9178 gstvalue: Avoid temporary allocation
The problem is that:
* g_value_init will end up allocating an internal list/array
* g_value_copy *clears* the existing value by calling the free func
  and then the copy function (creating it again)

To avoid that alloc/free/alloc cycle, directly call the appropriate
function

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/453>
2020-05-05 10:17:49 +00:00
Edward Hervey
62f553873b gstcaps: Move assignment outside loop
s1 and f1 stay the same within the inner loop

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/453>
2020-05-05 10:17:49 +00:00
Edward Hervey
7e1a0ed604 gststructure: inline gst_structure_is_subset()
Having direct access to the iteration allows tighter code and
also being able to stop earlier.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/453>
2020-05-05 10:17:49 +00:00
Edward Hervey
586454bf10 gststructure: Inline gst_structure_intersect()
Having direct access to the iteration allows tighter code and
also being able to stop earlier.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/453>
2020-05-05 10:17:49 +00:00
Edward Hervey
973986f40b gstregistry: Directly get list of plugin features
Previously this was:
* iterating and referencing all plugin features in a GList
* *then* filtering out the ones we want
* Was doing that filtering by name (i.e. `strcmp`) instead of direct pointer
comparision

Instead, just create a private direct function to get the list of plugin
features

Uses 4 times less instructions ...

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/462>
2020-05-05 10:50:05 +02:00
Rubén Gonzalez
32600b48a2 plugin: Fix typo with GStremaer version:
```
has incompatible version (plugin: 1.15, gst: 1,12)
```

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/460>
2020-05-04 20:20:17 +00:00
Edward Hervey
841fa7062e gstvalue: No longer store same-type intersection functions in table
The intersection function table is a legacy of 2005, when one could
register random intersection functions. This is no longer the case.

The only place where that table was used was:

* `gst_value_can_intersect()`, where it was already only used for identical
GType
* `gst_value_intersect()`, where the table iteration was insanely expensive

Instead this patch:
* Only stored intersection functions for *different* types (of which there are
only 4)
* Make gst_value_intersect directly call the same-type intersection functions
and only use the table if ever it doesn't match.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/454>
2020-05-04 14:41:01 +00:00
Edward Hervey
5e553b8cce gstpad: Simplify task name creation
This was going through a few locks and doing temporarily allocations for every
single task creation.. just to get a name.

We don't need to take locks since:
* The parent exists (we have a reference to it)
* The pad exists (the task belongs to it)
* Changing names of pad/elements when activating is a big no-no

Instead use the existing direct GST_DEBUG_PAD_NAME macro

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/455>
2020-05-04 12:26:10 +00:00
Edward Hervey
7a207da733 gstevent: Add function for checking event name by GQuark
Avoids doing string<=>quark conversions in the sticky event handling path.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/455>
2020-05-04 12:26:10 +00:00
Edward Hervey
1d0bda8005 caps: Unify common checks for intersections
Regardless of the intersect method chosen, migrate the same checks
up into the calling function. Same result, just less code.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/455>
2020-05-04 12:26:10 +00:00
Edward Hervey
a307c0623c gstregistry: Remove unneeded call
_priv_gst_preload_plugins is only filled if option parsing is active.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/455>
2020-05-04 12:26:10 +00:00
Sebastian Dröge
333b77bc9f Add missing colons to Since markers in the docs
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/452>
2020-05-01 10:07:09 +03:00
Juan Navarro
358d4e991a gstcaps: fix out of bounds checks
These two checks could end up allowing out of bounds array access, when
the index equals the array size.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/445>
2020-04-22 17:27:31 +00:00
Matthew Waters
166c0fbc47 Revert "gstvalue: Avoid expensive fallback on intersection"
This reverts commit cd751c2de3.
Reverts https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/406

Fixes glviewconvert negotiation in e.g.:

gltestsrc ! glviewconvert output-mode-override=side-by-side ! glstereosplit name=s s.left ! queue ! fakesink s.right ! queue ! glimagesink

Problem here is that intersecting flagsets in gst_value_intersect will
always find a value comparison function but may fail a direct type
comparison due to flagsets supporting derived types.  When flagset
derived types are intersected, an intersection will therefore always
fail.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/441>
2020-04-22 15:18:50 +00:00
Seungha Yang
684723d07c systemclock: Fix clock waiting on Windows
Add missing parentheses in macro for the divide operation

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/444>
2020-04-22 20:59:02 +09:00
Charlie Turner
e310a738f6 debugutils: Skip multiqueue stats in dot dump
If this is not done, tools like xdot fail with "unexpected char
b'\\'". This is a regression caused by commit
74938f07c2 (multiqueue: Add stats
property).

The deserialized value coming out of g_object_get_property looks like
this,

$24 = (gchar *) 0x7f560c0046a0 "application/x-gst-multi-queue-stats, queues=(structure)< \\\"queue_0\\\\,\\\\ buffers\\\\=\\\\(uint\\\\)39\\\\,\\\\ bytes\\\\=\\\\(uint\\\\)8
120251\\\\,\\\\ time\\\\=\\\\(guint64\\\\)1460000000\\\\;\\\", \\\"queue_1\\\\,\\\\ buffers\\\\=\\\\(uint\\\\)186\\\\,\\\\ bytes\\\\=\\\\(uint\\\\)838020\\\\,\\\\ time\\\\=\
\\\(guint64\\\\)1984000002\\\\;\\\" >;"

That is immediately looking wrong. I don't know enough about GNOME
serialization details to say with confidence what happened here. It
gets worse after this is sent through g_strescape and then written to
the dot file. Interestingly, dot -Tpng is fine to ignore them it
seems.

Since the stats are by definition verbose, I decided the best choice
to omit them from the dot file, since such details are not of interest
there.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/442>
2020-04-21 19:53:33 +00:00
Sebastian Dröge
ed1022fa81 Use gst_object_unref() / gst_object_clear() instead of the GObject ones
To allow the refcounting tracer to work better. In childproxy/iterator
these might be plain GObjects but gst_object_unref() also works on them.
In other places where it is never GstObject, g_object_unref() is kept.
2020-04-20 16:28:52 +00:00
Edward Hervey
ab8674d503 gstregistrychunks: Directly set name on features 2020-04-17 09:26:45 +02:00
Edward Hervey
d4f84ad4e6 gstobject: Don't double-notify when setting names
If the name is set via the gobject setters, the notificatio will
already be emitted.
2020-04-17 09:26:45 +02:00
Matthew Waters
de0ec87ba1 systemclock: introduce a minimum wait time
There is not point waiting if the time to wait is less than this
platform specific value.  The worst case here is GCond usage on windows
where the granularity is 1ms.
2020-04-16 01:26:59 +00:00
Matthew Waters
6f9a63a10d gst/systemclock: wait on each entry individually
Problem:
multiple aggregator elements (audiomixer, compositor) in a live
pipeline use a lot of CPU waiting each other up.  This is because
of the previously unused clock entry unscheduling during regular
operation.

Clock entry unscheduling has the potential to wake up every clock entry
waiting using the system clock which may be a large number.

Solution:
Implement waiting per entry and only wakeup the unscheduled entry.

While this may be possible using GCond, theoretically GCond only gives
us microsecond accuracy and uses relative waits in a number of places.
We can unfortunately do better poking at the platform specifics
ourselves by using futexes on linux and pthread on other unix.  Windows
may have a possible implementation using Waitable timers but that is
not implemented here and instead falls back to the GCond implementation.
GCond waits on Windows is still as accurate as the previous GstPoll-based
implementation.
2020-04-16 01:26:59 +00:00
Matthew Waters
546bf6ec25 systemclock: log the object name with all debug logs
Simplifies correlating logs with clock instances
2020-04-16 01:26:59 +00:00
Matthew Waters
2c8a65745c systemclock: move to GCond waiting 2020-04-16 01:26:59 +00:00
Thibault Saunier
88f0312624 value: Fix segfault comparing empty GValueArrays
Adding a test
2020-04-12 20:33:43 -04:00
Mathieu Duponchelle
0566b0528a pipeline: fix base_time selection when flush seeking live
When a live pipeline goes to PLAYING, its change_state method
is called twice for PAUSED_TO_PLAYING: the first time is
from GstElement, when NO_PREROLL is returned, the second
is from GstBin, after all async_done messages have been
collected.

base_time selection is done only the first time, through
comparisons with start_time.

On the other hand, when this live pipeline gets flush seeked,
even though start_time is reset by the sink upon reception
of flush_stop(reset_time=TRUE), PAUSED_TO_PLAYING only occurs
once, from GstBin, after all async_done messages have been
collected. This causes the base_time to be off by <latency>.

This commit addresses this by mimicing the behaviour of
GstElement on NO_PREROLL, and calling the change_state
method manually when the following conditions are met:

* The pipeline is live

* The target state is PLAYING
2020-04-09 15:41:36 +00:00
Sebastian Dröge
606a9acd74 pad: Add a guard against getrange functions not filling a caller-provided buffer
It's a programming error to not do so and would cause all kinds of
problems in the caller that assumed its own buffer to have been filled.
2020-04-02 13:47:37 +03:00
Nicolas Dufresne
e272ae281f task: Introduce gst_task_resume() API
This new API allow resuming a task if it was paused, while leaving it to
stopped stated if it was stopped or not started yet. This new API can be
useful for callback driver workflow, where you basically want to pause and
resume the task when buffers are notified while avoiding the race with a
gst_task_stop() coming from another thread.
2020-04-01 15:13:59 +00:00
Jan Schmidt
e98ccc7665 gstsegment: Refuse instant-rate seeks in gst_segment_do_seek()
Elements that pass a seek with INSTANT_RATE flag to
gst_segment_do_seek() haven't been updated and we should
refuse the seek.
2020-03-26 13:51:41 +00:00
Jose Antonio Santos Cadenas
dcece2a878 gstinfo: Check threshold for category from macro
This way we can avoid to process parameters if log is not going
to be printed.
2020-03-24 11:39:32 +00:00
Jan Alexander Steffens (heftig)
a20ff6aaf4 gststructure: Fix gst_structure_take ownership handling
The old code would leave a dangling pointer in oldstr_ptr if two threads
attempted to take the same structure into the same location at the same
time:

1. First "oldstr == newstr" check (before the loop) fails.
2. Compare-and-exchange fails, due to a second thread completing the
   same gst_structure_take.
3. Second "oldstr == newstr" check (in the loop) succeeds, loop breaks.
4. "oldstr" check succeeds, old structure gets freed.
5. oldstr_ptr now contains a dangling pointer.

This shouldn't happen in code that handles ownership sanely, so check
that we don't try to do this and complain loudly.

Also simplify the function by using a do-while loop, like
gst_mini_object_take.

https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/413
2020-03-23 16:48:47 +00:00
Jan Alexander Steffens (heftig)
e45f187d13
gstdeviceproviderfactory: Remove volatile from provider storage
Avoids a few compiler warnings:

../subprojects/gstreamer/gst/gstdeviceproviderfactory.c: In function ‘gst_device_provider_factory_finalize’:
../subprojects/gstreamer/gst/gstdeviceproviderfactory.c:96:12: warning: assignment discards ‘volatile’ qualifier from pointer target type [-Wdiscarded-qualifiers]
   96 |   provider = g_atomic_pointer_get (&factory->provider);
      |            ^
../subprojects/gstreamer/gst/gstdeviceproviderfactory.c: In function ‘gst_device_provider_factory_get’:
../subprojects/gstreamer/gst/gstdeviceproviderfactory.c:276:19: warning: assignment discards ‘volatile’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  276 |   device_provider = g_atomic_pointer_get (&newfactory->provider);
      |                   ^
../subprojects/gstreamer/gst/gstdeviceproviderfactory.c:309:21: warning: assignment discards ‘volatile’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  309 |     device_provider = g_atomic_pointer_get (&newfactory->provider);
      |

https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/414
2020-03-23 15:16:36 +01:00