[gst-devel] fork() and then use gstreamer functions?

Tim-Philipp Müller t.i.m at zen.co.uk
Mon Sep 14 12:06:14 CEST 2009


On Mon, 2009-09-14 at 01:59 +0200, Alejandro Forero Cuervo wrote:

> I've been working in a music player.  I figured it was time to get it
> to use gstreamer.  I'm having some issues.
>  (..)
> The problem I'm having is that when I call fork(2) and, after setting
> a pipeline, the child process calls gst_bus_poll, the child process
> seems to be trying to interact with the X server!  Y get some
> assertion failures in xlib's code.  I'm guessing gst_bus_poll just
> calls the glib primitives for the main loop, which still have the
> gtk-dependencies.
> 
> I tried closing all files in the child (except the pipe used to talk
> to the parent and the standard error) but this just results in an
> assertion failure, Fatal IO error 9 (Bad file descriptor) on X server
> :0.0.
> 
> So what's a programmer to do in order to fork a process and use
> gstreamer functions without having the child process attempt to keep
> track of all the widgets and stuff?

This sounds more like an issue with your GUI toolkit (Gtk+/Qt) than with
GStreamer per se. GStreamer doesn't force you to use the GLib main loop
- any GStreamer function that hooks into the main loop is just for
convenience.

In your case, you could use gst_bus_timed_pop_filtered() instead of
gst_bus_poll(). That would avoid iterating the main loop.

An external helper application with which you communicate via a socket
or pipe or some other form of IPC might be a solution too (and makes
debugging import issues a lot easier).

Cheers
 -Tim






More information about the gstreamer-devel mailing list