Commit graph

576 commits

Author SHA1 Message Date
Jan Schmidt
2a9267f2d4 bin: When removing a sink, check if the EOS status changed.
Removing a sink that hasn't posted EOS might change the bin itself
to EOS if it's the last remaining non-EOSed sink.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/683>
2020-10-30 03:56:02 +11: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
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
Sebastian Dröge
47765e164b bin: Don't consider having a group-id or being STREAM_START if we have not a single STREAM_START message
This would cause us to set GST_GROUP_ID_INVALID as group-id in the
aggregated STREAM_START message if there are no sinks at all or none of
them have a STREAM_START message, which is simply wrong.

If we have not a single STREAM_START message then the bin should not be
considered STREAM_START.
2020-01-25 00:02:20 +02:00
Jan Alexander Steffens (heftig)
f018b4eddc
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:08:38 +01:00
Niels De Graef
0cb3940c94 bin: Add method to find elements by factory name
A common use case of a dynamically built pipeline is that you want to
(conditionally) find a certain element, e.g. the `rtpbin`s in a
`uridecodebin`. If that element has a fixed name inside its parent bin
(and only has a single instance) this can be easily done by
`gst_bin_get_by_name()`.

If there are multiple instances of the element however, you can only use
`gst_bin_iterate_all_by_interface()`, but this doesn't work if you don't
have the specific `GType` (which is often the case, due to plugins being
dynamically loaded). As such, another fallback could be to use the
well-known name of the element's factory (in case of our example, this
is of course `"rtpbin"`).
2019-12-20 14:29:19 +01:00
Sebastian Dröge
487a3f9a30 bin: Drop need-context messages without source instead of crashing 2019-10-22 09:46:19 +03: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
Nicolas Dufresne
80a76a4b4d 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 15:42:17 -04:00
Sebastian Dröge
37edc474e3 Revert "bin: Hold the state lock while removing elements from a bin"
This reverts commit 7f70d7a945
2019-01-10 12:05:34 +00:00
Sebastian Dröge
7f70d7a945 bin: Hold the state lock while removing elements from a bin
We need to take the state lock here to ensure that we're
not currently just before setting the state of this child
element. Otherwise it can happen that we removed the element
here and e.g. set it to NULL state, and shortly afterwards
have another thread set it to a higher state again as part of
a state change for the whole bin.

When adding an element to the bin this is not needed as we
require callers to always ensure after adding to the bin that
the new element is set to the correct state.
2019-01-07 14:08:00 +02:00
Philippe Normand
616d588b52 bin: Fix use-after-free issue in gst_bin_add()
gst_element_post_message() takes ownership of the message so we need to increase
its refcount until we no longer require access to its data (context_type).

https://bugzilla.gnome.org/show_bug.cgi?id=797099
2018-09-08 19:15:41 +01:00
Tim-Philipp Müller
2db8e3705f Update for g_type_class_add_private() deprecation in recent GLib
https://gitlab.gnome.org/GNOME/glib/merge_requests/7
2018-06-24 12:49:14 +02:00
Edward Hervey
5b0fe8d174 bin: Make sure we don't use invalid seqnums on messages
There is a possibility that the accumlation functions don't set
a seqnum. Make sure we only set/override the seqnum of the new
messages if we *have* a valid upstream seqnum to use
2018-06-05 16:58:21 +02:00
luz.paz
4a402c1c7d Fix typos in comments and docs
Found via `codespell`

https://bugzilla.gnome.org/show_bug.cgi?id=795610
2018-05-01 11:18:03 +01:00
Matthew Waters
f5f1fb5780 bin: fix deep-element-added signal debug log message
Adding the bin to the child element doesn't really make sense.
2018-03-29 12:36:11 +11:00
Arun Raghavan
b5028383ab gst: Fix up a bunch of GIR annotations
This is mostly on nullable return values, and some other minor ones that
I ran across.

https://bugzilla.gnome.org/show_bug.cgi?id=789319
2018-01-27 10:41:24 +00:00
Edward Hervey
ebad8c0094 bin: iterate_sorted: Ensure sources are always returned last
For linked elements, the resulting gst_bin_iterate_sorted() will
properly return elements from sink to sources.

If we have some elements that are not linked, we *still* want to
ensure that we return:
* In priority any sinks
* Last of all any sources
* And in between any element which is neither source nor sink

For this to work, when looking for the next candidate element,
not only check the degree order, but if there are two candidates
with the same degree order, prefer the non-source one.

Amongst other things, this fixes the case where we activating a
bin containing unlinked sources and other elements. Without this
we could end up activating sources (which might start adding pads
to be linked) before other (to which those new source element pads
might be linked) are not activated

https://bugzilla.gnome.org/show_bug.cgi?id=788434
2017-10-03 07:56:39 +02:00
Sebastian Dröge
5f5caffa70 bin: Put correct annotations on gst_bin_add() too 2017-05-31 20:40:00 +03:00
Christoph Reiter
9bf46a1065 gst: ref_sink() some more floating references returned by g_object_new()
https://bugzilla.gnome.org/show_bug.cgi?id=743062
2017-05-17 15:36:12 +03:00
Sebastian Dröge
2e4c82d850 gst: Handle floating references consistently
If a function takes a floating reference parameter, it should also be
sinked in error cases. Otherwise the function behaves differently
between error and normal cases, which is impossible for bindings to
handle.

https://bugzilla.gnome.org/show_bug.cgi?id=747990
2017-05-17 10:40:37 +03:00
Vineeth TM
7c4d3a6c52 gst: Fix floating reference inconsistencies in error cases
If a function takes a floating reference and sinks it, it should also do
that in error cases. I.e. call ref_sink() followed by unref().

Otherwise the reference counting behaviour of the function will be
different between the good and the error case, and simply inconsistent.

https://bugzilla.gnome.org/show_bug.cgi?id=747990
2017-05-17 10:40:37 +03:00
Thibault Saunier
a87b4551a6 Port gtk-doc comments to their equivalent markdown syntax
Modernizing our documentation and preparing a possible move to hotdoc.
This commits also adds missing @title metadatas to all SECTIONs
2017-01-27 16:36:38 -03:00
Stefan Sauer
a533b6c2f9 bin: update the docs for the event forwarding
First this sends the events not only to the sources and 2nd this is not only
for seek events.
2017-01-18 22:39:33 +01:00
Jan Schmidt
b3296183fc gstbin: Quieten a noisy FIXME about duration caching
Only print this FIXME once per run, at it's pretty annoying in
lots of logs otherwise.
2017-01-16 09:44:15 +11:00
Sebastian Dröge
78e485b314 bin: Make sure to resync iterators and handle RESYNC at all in gst_iterator_foreach() calls 2016-12-01 18:20:11 +02:00
Edward Hervey
d02e1d7f7d bin: Fix iterator resync'ing
When we get GST_ITERATOR_RESYNC, we need to call gst_iterator_resync()
otherwise we will always get GST_ITERATOR_RESYNC (and that loop would
run forever).
2016-10-08 17:23:08 +02:00
Sebastian Dröge
bf1c12342a bin: Add forgotten "git commit --amend" for last commit
Need to cast away the const as g_queue_foreach() takes a non-const GQueue*
2016-09-19 10:07:51 -04:00
Kouhei Sutou
a43de49d52 bin: When copying the sort iterator, also copy its internal queue
Otherwise both iterators share the same references, the second one
usually resulting in a crash when being freed.

https://bugzilla.gnome.org/show_bug.cgi?id=771649
2016-09-19 10:04:55 -04:00
Sebastian Dröge
c7e0299d24 bin: Also don't *unset* element flags if they're in the suppressed flags
Otherwise our bin might lose various flags that were explicitly set on
it at arbitrary times.
2016-09-12 17:07:09 +02:00
Wonchul Lee
978b7ace52 bin: Add setter and getter to suppress element flags
Suppress-flags is for preventing propagation of child element's specific
flag when it is added to the bin.

https://bugzilla.gnome.org/show_bug.cgi?id=770627
2016-09-10 13:28:21 -03:00
Guillaume Desmottes
757a8b04c0 bin: properly display the type of the removed message
Makes debugging easier.

https://bugzilla.gnome.org/show_bug.cgi?id=768579
2016-07-08 17:52:40 +01:00
Tim-Philipp Müller
ef1444cfe4 bin: emit deep-element-{added,removed} for children of newly-added/removed bin
https://bugzilla.gnome.org/show_bug.cgi?id=578933
2016-05-16 09:10:09 +01:00
Tim-Philipp Müller
81dec8cc4d bin: add "deep-element-added" and "deep-element-removed" signals
This means applications and bin sub-classes can easily track when
a new child element is added to the pipeline sub-hierarchy or
removed.

Currently doesn't signal deep added/removed for elements inside
a bin if a bin is added/removed.

https://bugzilla.gnome.org/show_bug.cgi?id=578933
2016-05-16 09:10:09 +01:00
Jan Schmidt
174a5e93e2 bin: Fix EOS forwarding on PLAYING->PLAYING
When doing a transition from PLAYING to PLAYING, we will fail
to forward an EOS message on the bus, and noone else will ever
send it because there'll be no actual state changed message.

Allow EOS through directly in that case.
2016-05-14 23:46:47 +10:00
Sebastian Dröge
8177173db0 element: Add gst_element_call_async()
This calls a function from another thread, asynchronously. This is to be
used for cases when a state change has to be performed from a streaming
thread, directly via gst_element_set_state() or indirectly e.g. via SEEK
events.

Calling those functions directly from the streaming thread will cause
deadlocks in many situations, as they might involve waiting for the
streaming thread to shut down from this very streaming thread.

This is mostly a convenience function around a GThreadPool and is for example
used by GstBin to continue asynchronous state changes.

https://bugzilla.gnome.org/show_bug.cgi?id=760532
2016-04-27 18:51:33 +03:00
Mark Combellack
b8f2929dac GST_REFCOUNTING: Add logging of pointer address for dispose, finalize, etc messages
Updated the GST_REFCOUNTING logging so that it includes the pointer
address of the object that is being disposed or finalized.

With this change is is then possible to match up GST_REFCOUNTING log messages
for object allocation/disposal/finalization. This can help with diagnosing
"memory leaks" in applications that have not correctly disposed of all the
GStreamer objects it creates.

https://bugzilla.gnome.org/show_bug.cgi?id=749427
2016-04-02 18:18:10 +01:00
Sebastian Dröge
2d427c75ae bin: Post a LATENCY message with async-handling=TRUE if the PLAYING state is reached
Otherwise each bin might have a different latency in the end, causing
synchronization problems.

The bin will still first handle latency internally as before, but gives the
overall pipeline the opportunity to update the latency of the whole pipeline
afterwards.

https://bugzilla.gnome.org/show_bug.cgi?id=759125
2015-12-09 11:13:22 +02:00
Sebastian Dröge
2955eeb0ed bin: Make sure to free all cached messages when going to NULL
An ASYNC READY->PAUSED might have failed without the bin code noticing during
the state change, in which case we will never get PAUSED->READY and would leak
messages.

https://bugzilla.gnome.org/show_bug.cgi?id=756611
2015-10-19 11:06:54 +03:00
Marcin Kolny
e8d0b019b3 tracer: add missing hooks
Add following hooks: element-new, element-add-pad, element-remove-pad,
bin-add-pre, bin-add-post, bin-remove-pre, bin-remove-post, pad-link-pre,
pad-link-post, pad-unlink-pre, pad-unlink-post.

https://bugzilla.gnome.org/show_bug.cgi?id=733187
2015-10-05 20:59:39 +02:00
Matthew Waters
d5ded15889 bin: implement context propagation when adding elements
When adding an element to a bin we need to propagate the GstContext's
to/from the element.

This moves the GstContext list from GstBin to GstElement and adds
convenience functions to get the currently set list of GstContext's.

This does not deal with the collection of GstContext's propagated
using GST_CONTEXT_QUERY.  Element subclasses are advised to call
gst_element_set_context if they need to propagate GstContext's
received from the context query.

https://bugzilla.gnome.org/show_bug.cgi?id=705579
2015-09-28 18:21:59 +10:00
Stian Selnes
0fbf1d3eb7 bin: element: Ignore activate result for removed pads on state change
This fixes a race where a state change may return failure if it has
request pads that are deactivated and removed (and thus have no
parent) at the same time as the element changes state and (de)activates
its pads.

https://bugzilla.gnome.org/show_bug.cgi?id=755342
2015-09-24 12:14:57 +02:00
Vineeth TM
09900bbfb1 bin: fix typo in log message when threadpool alloc fails
https://bugzilla.gnome.org/show_bug.cgi?id=754975
2015-09-14 16:03:51 +01:00
Vivia Nikolaidou
ee1bbe2f15 bin: Make sure we don't add/remove a bin to/from itself
Doing so would deadlock from trying to acquire the object lock twice

https://bugzilla.gnome.org/show_bug.cgi?id=754036
2015-08-25 10:19:44 +03:00
Vincent Penquerc'h
a3b42ec42a bin: undo upward state changes on children when a child fails
When a bin changes states upwards, and a child fails to change,
any child that was already switched will not be reset to its
original state, leaving its state inconsistent with the bin,
which does not change state due to the failure.

If the state change was from NULL to READY, it means that deleting
this bin will cause those children to be deleted while not in
NULL state, which is a Bad Thing. For other upward changes, it
is less of a problem, as a subsequent switch back to NULL will
cause an actual downwards change on those inconsistent elements,
albeit from the "wrong" state.

We now reset state to the original one when a child fails.

Includes unit test.

https://bugzilla.gnome.org/show_bug.cgi?id=747610
2015-04-15 16:00:21 +01:00
Sebastian Dröge
5b2c79eda7 bin: Pass structs we plan to modify around by pointer, not value
Otherwise the struct is going to be copied, which is not very efficient. And
also has the nice side effect that modifications of the struct might be
done in a copy, and we later use the original struct without the changes.

Caused LATENCY queries to always return the initialization values in one of my
tests, instead of the actual values reported by child elements.
2015-01-16 19:17:31 +01:00
Sebastian Dröge
154eefecc9 Don't compare booleans for equality to TRUE and FALSE
TRUE is 1, but every other non-zero value is also considered true. Comparing
for equality with TRUE would only consider 1 but not the others.

Also normalize booleans in a few places.
2014-12-01 09:51:37 +01:00
Sebastian Dröge
2f33fd5c19 bin: Use allow-none instead of nullable until we depend on a new enough GI version 2014-08-13 12:40:37 +03:00
Sebastian Dröge
9b96d4c7cd bin: gst_bin_new() can accept NULL as name 2014-08-13 12:39:47 +03:00
Evan Nemerson
2759882379 introspection: add missing (nullable) annotations to return values
Support for (nullable) was added to G-I at the same time as nullable
return values.  Previous versions of G-I will not mark return values as
nullable, even when an (allow-none) annotation is present, so it is
not necessary to add (allow-none) annotations for compatibility with
older versions of G-I.

https://bugzilla.gnome.org/show_bug.cgi?id=730957
2014-06-26 18:56:38 +02:00