From 737c32b9b6d0ff3a9a19803022a154f1d8c7cce1 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 16 Oct 2023 20:53:49 +0000 Subject: [PATCH] ximagesrc: fix compile-time warning and XInitThreads() Part-of: --- .../gst-plugins-good/sys/ximage/gstximagesrc.c | 15 +++++++++++---- subprojects/gstreamer/docs/gst/running.md | 7 +++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/subprojects/gst-plugins-good/sys/ximage/gstximagesrc.c b/subprojects/gst-plugins-good/sys/ximage/gstximagesrc.c index 256d0eed79..895816abfe 100644 --- a/subprojects/gst-plugins-good/sys/ximage/gstximagesrc.c +++ b/subprojects/gst-plugins-good/sys/ximage/gstximagesrc.c @@ -22,11 +22,18 @@ * SECTION:element-ximagesrc * @title: ximagesrc * - * This element captures your X Display and creates raw RGB video. It uses + * This element captures your X Display and creates raw RGB video. It uses * the XDamage extension if available to only capture areas of the screen that * have changed since the last frame. It uses the XFixes extension if * 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. + * + * 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 * |[ @@ -1398,10 +1405,7 @@ gst_ximage_src_class_init (GstXImageSrcClass * klass) bc->stop = gst_ximage_src_stop; bc->unlock = gst_ximage_src_unlock; push_class->create = gst_ximage_src_create; -#ifdef HAVE_NAVIGATION - XInitThreads (); bc->event = gst_ximage_src_event; -#endif /* HAVE_NAVIGATION */ } static void @@ -1429,6 +1433,9 @@ plugin_init (GstPlugin * plugin) { gboolean ret; + if (g_getenv ("GST_XINITTHREADS")) + XInitThreads (); + GST_DEBUG_CATEGORY_INIT (gst_debug_ximage_src, "ximagesrc", 0, "ximagesrc element debug"); diff --git a/subprojects/gstreamer/docs/gst/running.md b/subprojects/gstreamer/docs/gst/running.md index 436a7900d3..8285cd2329 100644 --- a/subprojects/gstreamer/docs/gst/running.md +++ b/subprojects/gstreamer/docs/gst/running.md @@ -343,3 +343,10 @@ Example: `GST_PLUGIN_FEATURE_RANK=foo:PRIMARY,bar:primary,foobar:128` As a result of the above example, the `foo` and` bar` plugin feature rank values are `PRIMARY`(256) 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.