After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 794956 - gst_initialized is not reset in gst_deinit()
gst_initialized is not reset in gst_deinit()
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
unspecified
Other All
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
: 794960 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2018-04-03 21:44 UTC by hermann.fuerntratt
Modified: 2018-11-03 12:45 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description hermann.fuerntratt 2018-04-03 21:44:01 UTC
gst.c uses 2 static gboolean flags for initialization:
gst_initialized and gst_deinitialized.

gst_deinit() checks, whether or not gst_initialized is set and sets gst_deinitialized to TRUE at the end. Consequently, gst_initialized should be reset to FALSE at the same location.
Comment 1 Sebastian Dröge (slomo) 2018-04-04 06:58:35 UTC
After gst_deinit() was called, it's not allowed to call gst_init() again and you won't be able to use GStreamer anymore. gst_deinit() exists only for debugging/memory leak detection reasons.

As such it probably does not make much of a difference if this is reset or not, or does it cause problems in a specific situation for you? If so, please also provide a patch for that change, thanks!
Comment 2 Sebastian Dröge (slomo) 2018-04-04 07:00:04 UTC
*** Bug 794960 has been marked as a duplicate of this bug. ***
Comment 3 hermann.fuerntratt 2018-04-04 07:16:13 UTC
Currently I try to keep things simple and put gst related code in a separate C++ thread. At the very end, I would like to recreate the trhead with a different pipeline. That would require gst_init_check() to be called only once outside the thread, which means to rip the gst related code appart into one part (calling gst_init_check()) and the rest of it (with additional argc argv handling of the new pipeline arguments) inside the thread, which is not good, especially if the following patch could fix the problem.


gst/gst.c
@@ -1228,6 +1228,7 @@ gst_deinit (void)
   g_type_class_unref (g_type_class_peek (gst_promise_result_get_type ()));
 
   gst_deinitialized = TRUE;
+  gst_initialized = FALSE;
   GST_INFO ("deinitialized GStreamer");
 }
Comment 4 Sebastian Dröge (slomo) 2018-04-04 07:35:45 UTC
(In reply to hermann.fuerntratt from comment #3)
> Currently I try to keep things simple and put gst related code in a separate
> C++ thread. At the very end, I would like to recreate the trhead with a
> different pipeline. That would require gst_init_check() to be called only
> once outside the thread, which means to rip the gst related code appart into
> one part (calling gst_init_check()) and the rest of it (with additional argc
> argv handling of the new pipeline arguments) inside the thread, which is not
> good, especially if the following patch could fix the problem.

I'm not sure I understand. You can't call any GStreamer function after gst_deinit(), including gst_init() or gst_init_check().

But to split things into separate threads that's also not required. You can call gst_init() as many times as you want (it would do nothing for anything but the first call). So each of your threads could call that in the very beginning unless you want to simply place it at the top of your main().

Your problem is that gst_is_initialized() still returns TRUE after gst_deinit(), but what exactly are you doing based on that?


For the patch, please provide it as a 'git format-patch' formatted patch (with a commit message and correct author information), see https://gstreamer.freedesktop.org/documentation/contribute/index.html#how-to-submit-patches
Comment 5 hermann.fuerntratt 2018-04-04 09:39:13 UTC
Actually, all I want to do is to call 2 different pipelines in parallel. 
So I thought, gst_init() and gst_deinit() would work together. 
Now I don't call gst_deinit() anymore, and start the first pipeline in a thread with argv 
filesrc location=d:/testvideo1.mp4 ! decodebin ! videoconvert ! autovideosink name=video-sink1

using
g_option_context_parse(ctx, &argc, &argv, &err)

but the next call of 
g_option_context_parse(ctx, &argc, &argv, &err)
in the other thread with the other pipeline

filesrc location=d:/testvideo2.mp4 ! decodebin ! videoconvert ! autovideosink name=video-sink2

fails with 
ERROR: pipeline could not be constructed: no element "filesrc"

So, what am I missing?
Comment 6 Sebastian Dröge (slomo) 2018-04-04 10:48:25 UTC
Do you pass actual arguments to gst_init() via argv that are somehow relevant to GStreamer?

As long as you don't call gst_deinit(), the second pipeline should work just as the first. However calling g_option_context_parse() multiple times in the same application is generally not a good idea. Why would you want to parse commandline arguments multiple times?
Comment 7 hermann.fuerntratt 2018-04-04 13:30:14 UTC
For conveniance the pipelines are stored as space separated comandline strings which can be tested with gst_launch(), but also selected depending on the protocol type (file:// http://..). 

Using g_option_context_parse() allows to define our own options, which are not considered if gst_init() is used..

That's why we thought that this would be a rather straightforward way to deal with a large variety of sources..

May I gently ask, why you think that calling g_option_context_parse() multiple times is a bad idea?
Comment 8 Sebastian Dröge (slomo) 2018-04-04 13:50:19 UTC
Maybe you can provide a standalone testcase for reproducing the problem you're seeing?

Parsing the commandline multiple times seems rather hackish to me (parsing once into some local data structures that makes sense to your application and then working from those seems nicer), but it should also be unrelated as long as none of the other init functions (like gst_init()) allow being called multiple times. I don't know if GOptionContext explicitly supports this though.
Comment 9 GStreamer system administrator 2018-11-03 12:45:38 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/284.