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 music player receives a path that it scans recursively for files. To do the scanning, it forks a child process that obtains the information about the files, one at a time, and reports the results back to the parent process over a pipe. Currently, it just uses readdir(2) and stat(2) and reports to the parent process the list of files it finds and their sizes. I've been modifying the code to hook gstreamer so that it can report metadata about the file. 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? Thanks! Alejo. http://azul.freaks-unidos.net/ ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel |
On Mon, Sep 14, 2009 at 01:59:04AM +0200, Alejandro Forero Cuervo wrote:
... > 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? You can't, at least in any useful manner. You could attempt to create a new GMainContext and main loop, and use those. That will prevent anything Gtk+ (or GStreamer) set up in the main loop of the primary process. Unfortunately, that's not the only shared resource. A reasonable scenario that cannot be worked around is that some thread in the main process holds a global lock (which are common in Glib and GStreamer) while another thread calls fork(). In the child process, this lock will never be unlocked, which can cause deadlocks. Another reasonable scenario is that the program could be running on an OS that doesn't support fork(), e.g., Windows. The fork() system call (when not immediately followed by exec()) is pretty useless in modern Unix programming. I'd recommend using a helper process, perhaps even the same executable with a --special-flag, or even just a separate thread. dave... ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel |
> > 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? > > You can't, at least in any useful manner. You could attempt to > create a new GMainContext and main loop, and use those. That > will prevent anything Gtk+ (or GStreamer) set up in the main > loop of the primary process. Unfortunately, that's not the > only shared resource. > > A reasonable scenario that cannot be worked around is that some > thread in the main process holds a global lock (which are common > in Glib and GStreamer) while another thread calls fork(). In the > child process, this lock will never be unlocked, which can cause > deadlocks. I find it sad that, from your first “reasonable scenario”, the fact that GStreamer uses threads prevents me from using fork and then the GStreamer functions. I was under the impression that I would be able to relatively ignore the heavily threaded nature of GStreamer from my application, as it's documentation has misleading statements such as “an application does not need to be thread-aware in order to use GStreamer”. If I wanted to use GStreamer in my application, I would have to make it thread-aware to the point of not using fork(2) during normal operation, which translates to forcing me to using separate threads for certain things (ie. I need to scan directories or do DNS lookups). > Another reasonable scenario is that the program could be running > on an OS that doesn't support fork(), e.g., Windows. I don't care about those OSs for my application. :-) > The fork() system call (when not immediately followed by exec()) is > pretty useless in modern Unix programming. I'd recommend using > a helper process, perhaps even the same executable with a > --special-flag, or even just a separate thread. I disagree. I find it very useful. Of course, if you've accepted to use threads, sure, you then only need fork for a handful of cases. However, some of us prefer to avoid threads in general, —and we don't mind the propagandistic application of the adjective «modern» to «Unix programming» to advocate the use of threads, we just counter it using the «propagandistic» adverb, as you just saw. :-) fork is very useful for us. But, to each his own: I don't want to start a flame war about threads vs async-IO here. I will check to see how difficult it would be to use a helper process (which itself forks the processes that do the work and which communicate with the main process over named pipes). I wish I didn't have to add all this complexity to my program just to use GStreamer. :-( In other words, I hope you can find a way to, eventually, make it possible to use GStreamer from a forked son of a process that has also used it. Thanks for your help. :-) Alejo. http://azul.freaks-unidos.net/ ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel |
In reply to this post by Alejandro Forero Cuervo-2
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 ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel |
Free forum by Nabble | Edit this page |