[vlc-devel] Running interface on the main thread

Juho Vähä-Herttua juhovh at iki.fi
Thu Jun 17 16:06:04 CEST 2010

17.6.2010 15:13, brezhoneg1 kirjoitti:
>   Running a GUI interface on the main thread is possible (a flag is 
> available, see src/interface/interface.c:112)

Thanks for the tip, looks like this is what I need. Needs some 
modifications since the main thread calls pf_run, which should again 
call the Qt4 main thread in this case. Actually the Qt4 interface 
doesn't clean up so nicely either, since it does the cleanup after the 
app.exec() and not in aboutToQuit() signal as it should. Moving the 
cleanup to a signal should make things a bit more simple...

>   Skins2 on Win32 used to work that way prior to vlc1.1. But, there 
> were a few side effects, especially at vlc termination, that could not 
> be worked out easily.
>   It turned out that the problems with skins2(Win32) were the following :
>         - Window management MUST NEVER be done in the Open/Close 
> functions of the interface module (this is the main thread)
>         - It HAS TO be done at the beginning/end of the spawned thread.
>   This was because Win32 demands that most things pertaining to 
> windows (from creation to management to destruction) be executed in 
> one _single_ thread. (not necessarily the main thread).

It's quite common that all GUI code should be done in a single thread, 
on Mac there's the method "performSelectorOnMainThread" that can be 
called anywhere and will always execute the method on main thread 
regardless of where it's called. Other Mac modules should be using this 
when required, and this is part of the reason why the main loop has to 
be on the main thread and running.

>   A common error is to create/destroy windows in the Open/Close 
> functions of a module (therefore executed by the main thread), then 
> expects the spawned thread to manage the life of these windows (eg the 
> event loop). This simply doesn't work on Win32.
>   Though I'm not familiar with MacOS, I would guess things may not be 
> that different ....

I'll see when I get it working first, this at least gives me something 
to work on, since I was stuck for a while. Now that you mentioned I 
noticed that the old macosx interface also used the flag to get main 
thread. Thanks you for the help.


More information about the vlc-devel mailing list