ximagesrc: fix compile-time warning and XInitThreads()

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5493>
This commit is contained in:
robert 2023-10-16 20:53:49 +00:00 committed by GStreamer Marge Bot
parent 3dd9411b36
commit 737c32b9b6
2 changed files with 18 additions and 4 deletions

View file

@ -28,6 +28,13 @@
* available to also capture your mouse pointer. It supports handling of * available to also capture your mouse pointer. It supports handling of
* mouse and keyboard events. By default it will fixate to 25 frames per second. * mouse and keyboard events. By default it will fixate to 25 frames per second.
* *
* Applications are expected to call `XinitThreads()` before any other threads
* are started. For use in gst-launch-1.0 or other GStreamer command line
* applications it is also possible to set the GST_XINITTHREADS=1 environment
* variable so that `XInitThreads()` gets called when the plugin is loaded. This
* may be too late in other use case scenarios though, so applications should
* not rely on that.
*
* ## Example pipelines * ## Example pipelines
* |[ * |[
* gst-launch-1.0 ximagesrc ! video/x-raw,framerate=5/1 ! videoconvert ! theoraenc ! oggmux ! filesink location=desktop.ogg * gst-launch-1.0 ximagesrc ! video/x-raw,framerate=5/1 ! videoconvert ! theoraenc ! oggmux ! filesink location=desktop.ogg
@ -1398,10 +1405,7 @@ gst_ximage_src_class_init (GstXImageSrcClass * klass)
bc->stop = gst_ximage_src_stop; bc->stop = gst_ximage_src_stop;
bc->unlock = gst_ximage_src_unlock; bc->unlock = gst_ximage_src_unlock;
push_class->create = gst_ximage_src_create; push_class->create = gst_ximage_src_create;
#ifdef HAVE_NAVIGATION
XInitThreads ();
bc->event = gst_ximage_src_event; bc->event = gst_ximage_src_event;
#endif /* HAVE_NAVIGATION */
} }
static void static void
@ -1429,6 +1433,9 @@ plugin_init (GstPlugin * plugin)
{ {
gboolean ret; gboolean ret;
if (g_getenv ("GST_XINITTHREADS"))
XInitThreads ();
GST_DEBUG_CATEGORY_INIT (gst_debug_ximage_src, "ximagesrc", 0, GST_DEBUG_CATEGORY_INIT (gst_debug_ximage_src, "ximagesrc", 0,
"ximagesrc element debug"); "ximagesrc element debug");

View file

@ -343,3 +343,10 @@ Example: `GST_PLUGIN_FEATURE_RANK=foo:PRIMARY,bar:primary,foobar:128`
As a result of the above example, As a result of the above example,
the `foo` and` bar` plugin feature rank values are `PRIMARY`(256) the `foo` and` bar` plugin feature rank values are `PRIMARY`(256)
and `SECONDARY`(128) rank value will be assigned to `foobar`. and `SECONDARY`(128) rank value will be assigned to `foobar`.
**`GST_XINITTHREADS`.**
Set this variable when using components that rely on X11, such as ximagesrc,
from gst-launch-1.0 or other command line applications. However, applications
should not depend on this variable and should make their own `XInitThreads()`
call as early as possible.