Commit graph

687 commits

Author SHA1 Message Date
François Laignel 1a8dfdfc54 Introduce gst_element_request_pad_simple
The name `gst_element_get_request_pad()` is confusing to people
learning GStreamer. `gst_element_request_pad_simple()` aims at
providing the exact same functionality, while making it more
explicit it is a simplified `gst_element_request_pad()`.

`gst_element_request_pad_simple()` is consistent with other
functions such as `gst_element_seek_simple`.

This commit deprecates `gst_element_get_request_pad()` so that a
compilation warning is emitted when used and incite developers
to use the more explicit `gst_element_request_pad_simple()`.

See also https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/743#note_886586

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/802>
2021-05-04 15:49:32 +02:00
Chris White a38d06cb1c gst: Add missing G_GNUC_NULL_TERMINATED markers
Functions that require NULL as their last vararg are marked so the
compiler can warn on missing NULL.

Also, document the NULL terminator for gst_make_element_message_details()
and gst_tracer_record_new().

https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/669

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/774>
2021-04-01 20:53:26 -04:00
Matthew Waters 3d887c7f07 gst: don't use volatile to mean atomic
volatile is not sufficient to provide atomic guarantees and real atomics
should be used instead.  GCC 11 has started warning about using volatile
with atomic operations.

https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719

Discovered in https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/issues/868

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/775>
2021-03-19 04:15:19 +00:00
Sebastian Dröge 20f6a2ece4 Add some missing nullable annotations
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/678>
2020-11-05 14:22:24 +02:00
Sebastian Dröge d22813ef97 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/553>
2020-07-03 06:55:37 +00:00
Sebastian Dröge f88b59f49a Fix up and add various "Since" markers and other related docs fixes
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/536>
2020-06-19 13:10:53 +01:00
Edward Hervey 31e6d766ff 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/531>
2020-06-16 08:23:21 +02: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
Jan Alexander Steffens (heftig) 1d5a1e8235 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.
2019-08-12 12:59:27 +03:00
Thibault Saunier a0c65067e0 Port to hotdoc 2019-05-13 16:34:09 -04:00
Thibault Saunier 5b2da0835e doc: Fix and add some missing docstrings 2019-05-13 11:33:49 -04:00
Stephane Cerveau a01c4965de gst_element_get_factory: update documentation
Inform about a potential NULL result.
2019-03-14 13:12:52 +01:00
Sebastian Dröge cacc834d8f element: Add note about racyness to gst_element_set_locked_state()
This is racy if the state lock of the parent bin is not taken. The
parent bin might've just checked the flag in another thread and as the
next step proceed to change the child element's state.
2019-01-09 16:12:26 +02:00
Mathieu Duponchelle 2fee579747 element: remove inactive pad g_warning in add_pad
The documentation incorrectly used to state that the pads were
not automatically activated when added, whereas we actually do
that when appropriate.

Callers of gst_element_add_pad must not hold the object lock,
which implies that they cannot perform the same checks as
add_pad in a non-racy manner.

This updates the documentation, and removes the g_warning
that was output before performing automatic activation.

https://bugzilla.gnome.org/show_bug.cgi?id=797181
2018-09-27 12:46:50 +02:00
luz.paz 98200ddd8d Source code typo fixes
https://bugzilla.gnome.org/show_bug.cgi?id=795610
2018-05-01 11:25:21 +01: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
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
Sebastian Dröge 1a5a5709ad element: Annotate set_clock() clock parameter with allow-none 2017-12-20 18:11:48 +02:00
Sebastian Dröge e16e55ed04 element: Annotate set_bus() bus parameter as allow-none
It's possible to replace the bus with NULL/None
2017-12-20 18:09:28 +02:00
Sebastian Dröge 16de48ae03 gst: gst_element_remove_pad() is transfer none for the pad
While the refcount of the pad is decreased, it's the refcount that is
owned by the parent (i.e. the element) and not the one passed in by the
caller.

Fixes a memory leak in bindings.
2017-12-04 18:10:23 +02:00
Mathieu Duponchelle c01949a99e pad templates: Allow specifying GType
See https://bugzilla.gnome.org/show_bug.cgi?id=731301

https://bugzilla.gnome.org/show_bug.cgi?id=789986
2017-11-22 16:44:08 +01:00
Tim-Philipp Müller d106390adc element: add gst_element_foreach_*pad()
Add convenience API that iterates over all pads, sink pads or
source pads and makes sure that the foreach function is called
exactly once for each pad.

This is a KISS implementation. It doesn't use GstIterator and
doesn't try to do clever things like resync if pads are added
or removed while the function is executing. We can still do that
in future if we think it's needed, but in practice it will
likely make absolutely no difference whatsoever, since these
things will have to be handled properly elsewhere by the element
anyway if they're important.

After all, it's always possible that a pad is added or removed
just after the iterator finishes iterating, but before the
function returns.

This is also a replacement for gst_aggregator_iterate_sink_pads().

https://bugzilla.gnome.org/show_bug.cgi?id=785679
2017-11-02 15:59:22 +00:00
Sebastian Dröge 0459b2db84 element/deviceprovider: Add instance getter functions for class properties
That is, the metadata and pad templates. Using instance getters is
easier to deal with for bindings, especially autogenerated ones.
2017-08-17 14:13:39 +03:00
George Kiagiadakis 4c3092e07a element: document that gst_element_continue_state needs to be called with the STATE_LOCK
It internally calls gst_element_change_state(), which requires the STATE_LOCK

https://bugzilla.gnome.org/show_bug.cgi?id=785431
2017-07-26 12:36:20 +03:00
Sebastian Dröge 30f871d274 gst: Correctly annotate functions taking floating reference parameters and returning floating references
https://bugzilla.gnome.org/show_bug.cgi?id=702960
2017-05-17 10:40:37 +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
Sebastian Dröge 597e43cffc element: Add guard to gst_element_release_pad() to ensure the pad belongs to this element
It's a programming error to pass other pads here, and it easily causes
crashes or other problematic behaviour down the road as subclasses
usually assume to only get their pads.
2016-12-22 12:08:14 +02:00
Sebastian Dröge 2872ae21c3 element: Don't increment NULL pointers
Trivial workaround for coverity false warning.

CID 1394488, 1394487.
2016-11-23 18:57:17 +02:00
Wonchul Lee f80dfc9b06 element: Allow multiple conversion specifiers for request pads
This allows pad template names like "src_%u_%u", but it does not allow
multiple specifiers of string type %s as that would lead to ambiguities.

https://bugzilla.gnome.org/show_bug.cgi?id=761225
2016-11-01 20:29:03 +02:00
Matthew Waters 556c540ecd element: use g_strcmp0 in set_context
It's NULL-safe while the libc implementation may not be.

https://bugzilla.gnome.org/show_bug.cgi?id=771773
2016-10-19 22:24:27 +11:00
Matthew Waters 3654d844c1 element: check for invalid gstcontext's being provided to set_context
https://bugzilla.gnome.org/show_bug.cgi?id=771773
2016-10-19 22:24:27 +11:00
Tim-Philipp Müller 3cba95ca2a element: rename gst_element_message_new_details() to gst_make_element_message_details()
Fixes g-i warning "Gst: Constructor return type mismatch
symbol='gst_element_message_new_details' constructed='Gst.Element'
return='Gst.Structure'".

This is a newly-added function in git that has not been in a stable
release yet, so it's fine to rename it. It's also only used indirectly
via macros.
2016-08-26 12:56:40 +01:00
Tim-Philipp Müller 26797d0714 docs: fix various gtk-doc warnings
e.g. "warning: multi-line since docs found"
2016-08-26 12:35:23 +01:00
Vincent Penquerc'h 1105caa805 message: new API for additional custom data to error messages
https://bugzilla.gnome.org/show_bug.cgi?id=756806
2016-07-22 14:16:34 +01:00
Tim-Philipp Müller 7a0f4422fa element: re-create threadpool after cleaning up tasks
We don't free this from gst_deinit() but from gst_task_cleanup_all(),
so more GStreamer API may be called. In particular makes unit tests
work again with CK_FORK=no.

https://bugzilla.gnome.org/show_bug.cgi?id=768577
2016-07-08 17:46:06 +01:00
Guillaume Desmottes 40727d9c83 element: clean up thread pool from gst_task_cleanup_all()
This ensures that all async operations (started from gst_element_call_async())
have been completed and so there is no extra thread running.

Fix races when checking for leaks on unit tests as some of those
operations were still running when the leaks tracer was checking for
leaked objects.

https://bugzilla.gnome.org/show_bug.cgi?id=768577
2016-07-08 17:27:32 +01:00
Tim-Philipp Müller 38c74e41c7 element: remove base_class_finalize_func which is never called
Won't be called for static types, so no point keeping it around.

https://bugzilla.gnome.org/show_bug.cgi?id=765540
2016-06-04 13:11:55 +01: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
Tim-Philipp Müller 6e3fb7af52 element: add API to get property change notifications via messages
Be notified in the application thread via bus messages about
notify::* and deep-notify::* property changes, instead of
having to deal with it in a non-application thread.

API: gst_element_add_property_notify_watch()
API: gst_element_add_property_deep_notify_watch()
API: gst_element_remove_property_notify_watch()
API: gst_message_new_property_notify()
API: gst_message_parse_property_notify()
API: GST_MESSAGE_PROPERTY_NOTIFY

https://bugzilla.gnome.org/show_bug.cgi?id=763142
2016-04-08 13:27:59 +01: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
Tim-Philipp Müller c7734d2711 element: minor docs fix
Make gtk-doc happy.
2016-03-01 19:50:26 +00:00
Tim-Philipp Müller fa12d23a17 element: add gst_element_class_add_static_pad_template()
Pretty much every single element does

  gst_element_class_add_pad_template (element_class,
      gst_static_pad_template_get (&some_templ));

which is both confusing and unnecessary. We might just
as well add a function to do that in one step.

https://bugzilla.gnome.org/show_bug.cgi?id=762778
2016-02-28 13:10:03 +00:00
Sebastian Dröge a0b3a7f658 Revert "element: Don't hold state lock all the time while sending an event"
This reverts commit b427997119.

It breaks things that used to work before, even if the change by itself is
correct and the previous code is just working around deeper bugs in the async
state change code. Let's go back to what previously worked and then fix async
state changes in general.

https://bugzilla.gnome.org/show_bug.cgi?id=760532
2016-02-17 16:41:02 +02:00
Stefan Sauer 2f41e7bc6a tracer: harmonize the query hooks
In post hooks always pass the return value as the last param. Pass the query
also to post hooks since it is still alive.
2016-01-07 23:03:48 +01:00
Sebastian Dröge 615af0b1b0 element: Unref event if GstElement::send_event() is not implemented
Otherwise we'll take ownership of the event only if it's implemented, and
leak the event in all other situations.
2015-12-14 10:10:04 +01:00
Aurélien Zanelli 51a70dd586 element: unref message in _post_message when there is no implementation
'gst_element_post_message' takes the ownership of the message, so it
shall unref it when there is no post_message implementation. Otherwise
message is leaked.

https://bugzilla.gnome.org/show_bug.cgi?id=759300
2015-12-10 16:44:31 +02:00
Sebastian Dröge b427997119 element: Don't hold state lock all the time while sending an event
This lock seems to exist only to prevent elements from changing states while
events are being processed. However events are going to be processed
nonetheless in those elements if sent directly via pads, so protection must
already be implemented inside the elements for event handling if it is needed.

As such having the lock here is not very useful and is actually causing
various deadlocks in different situations as described in
https://bugzilla.gnome.org/show_bug.cgi?id=744040
2015-12-10 11:35:05 +02:00
Sebastian Dröge c247117990 element: Check for an activated pad before adding, not a non-flushing one
The pad could be activated but flushing because of a FLUSH_START event. That's
not what we're looking for here, we want to check for activated pads.

https://bugzilla.gnome.org/show_bug.cgi?id=758928
2015-12-07 12:59:39 +02:00