[vlc-devel] [PATCH 1/3] Qt: Run mainloop on the main thread on OSX
remi at remlab.net
Sat Jul 31 21:30:13 CEST 2010
Le samedi 31 juillet 2010 22:11:11 Juho Vähä-Herttua, vous avez écrit :
> On 31.7.2010, at 21.23, Rémi Denis-Courmont wrote:
> > Le samedi 31 juillet 2010 21:12:38 Juho Vähä-Herttua, vous avez écrit :
> >> On other platforms the semaphore is used to synchronize functions "Open"
> >> and "Thread", which run in different threads. On OSX I attempted to use
> >> the semaphore to synchronize functions "Close" and "Thread", from which
> >> I have no guarantee that they are run from the same thread.
> > You do have that guarantee. A thread cannot call module_unneed() (which
> > calls pf_deactivate = Close) before a succesful *completed* call to
> > module_need (which calls pf_activate = Open). Hence Close() cannot be
> > called before Open().
> Thank you, this conversation cleared up a lot, and I made a patch that I
> hope is something you're after. There's only two issues I can think of:
> 1) the variable creation is moved to RegisterIntf function, because it
> needs to be called from two different places, avoids code duplication 2)
> the semaphore is still created and used even on Mac OS X single thread, I
> don't think this is an issue since it's a no-op here as you said
> Everything seemed to work fine when I tested, unless libvlc_Quit is called
> during video playback as already mentioned before. That will give the good
> old main interface destroyed before vout_window_Delete called issue:
> Assertion failed: (!stable), function ~VideoWidget, file
> ../../../../modules/gui/qt4/components/interface_widgets.cpp, line 81.
In principle, pl_Deactivate() will wait for the ongoing input to finish, and
release all the input "resources" (including the video window). Only later
intf_DestroyAll() will clean up all interfaces. Laurent can correct me if I am
wrong. But I do not understand how the race can still happen. If I recall
correctly, there was some anecdotal crash report evidence that it is still
possible on Linux/Windows as well.
At least on X11, we could ignore the problem. We could let the Qt4 thread
destroy the window. We just need to change WindowControl() and WindowClose()
to fail safely if the window was already destroyed. The owner of the video
window may get some errors from the X server, but nothing fatal.
I am not sure if this can work on Windows and MacOS though.
More information about the vlc-devel