[vlc-devel] Running interface on the main thread
brezhoneg1 at yahoo.fr
Thu Jun 17 14:13:02 CEST 2010
Le 17/06/2010 09:25, Juho Vähä-Herttua a écrit :
> I want to experiment a bit with running the Qt4 interface on Mac. Originally I had Qt4 binaries compiled with Carbon (old 32-bit MacOS based GUI framework) and it worked somewhat, but crashed from time to time and there was no video. With Laurent's help I fixed the vout module to work with Qt4 but that required the latest Qt4 binaries compiled with Cocoa (the NeXTStep based GUI framework, default now). I ran into a major issue with it though:
> The Cocoa framework main loop wants to be run on the main thread. VLC right now spawns a new thread for interface and calls QCoreApplication::exec there, which seems to break. Is there any possibility to move the interface code into the main thread? Right now the main() is in sigwait() state. Even Qt4 documentation seems to always refer QCoreApplication::exec running in the main() function, I think there's a possibility that this might cause problems on other systems as well.
Running a GUI interface on the main thread is possible (a flag is
available, see src/interface/interface.c:112)
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).
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 ....
More information about the vlc-devel