[vlc-devel] [PATCH 5/6] qt4: Run mainloop on the main thread on OSX
juhovh at iki.fi
Sun Jul 25 17:47:10 CEST 2010
On 25.7.2010, at 13.20, Rémi Denis-Courmont wrote:
> Le dimanche 25 juillet 2010 12:27:01 Juho Vähä-Herttua, vous avez écrit :
>> On 25.7.2010, at 10.07, Rémi Denis-Courmont wrote:
>>> Le dimanche 25 juillet 2010 00:48:28 Juho Vähä-Herttua, vous avez écrit :
>>>>> That thread looks quite useless.
>>>> It looks quite useless, but I plan to use it to start the playlist in
>>>> the middle of those two sem_wait calls.
>>> You might as well do that after vlc_sem_post() directly. That's one line
>>> of code (plus two lines of ifdef).
>> Could you give your comments on this one? It's basically the one I sent
>> earlier, but makes sure that the semaphore is downed to zero before
>> thread_join on non-OSX as well, and it starts the playlist on OSX.
>> Actually I'm already quite happy with it, now that I can start the video
>> on Qt4 interface by just adding it on command line. It adds just 7 lines
>> of code and moves the vlc_sem_destroy to Close instead of Open.
> Looks a bit better. But would things not be an order of magnitude simpler if
> you did not use b_run_on_first_thread. Why can't you replace:
> #if !MAC
> vlc_clone(Thread, p_intf);
> and ignore pf_run as well?
I'm not sure if it is a good idea or not...
I did it like this before, but then again I would like to be able to quit gracefully when the user selects "Quit VLC" option from the menu or from the icon popup menu. The b_run_on_first_thread hack does exactly this with its MonitorLibVLCDeath thread, allowing me to execute any code after libvlc_Quit() there. Without it the player just gets stuck forever in the Qt4 main loop with no one telling it to quit.
This would be possible to patch in the Qt4 interface itself as well, if it could be made sure that the app.exec() returns when user selects quit by calling QVLCApp::triggerQuit(). What it does currently is calling DialogsProvider::quit() which in turn calls libvlc_Quit(). Simply adding QVLCApp::triggerQuit() there before libvlc_Quit() should do the job, but I should duplicate the "if( !p_sys->b_isDialogProvider )" code inside the Thread in qt4.cpp, which would make it uglier again.
All comments are welcome, since after this patch the Qt4 interface of master already plays video quite nicely on Mac. After modifying the MonitorLibVLCDeath to actually call pf_deactivate it also quits very nicely. I can do it any way you guys want me to, just tell me what's the best option. :)
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 4215 bytes
Desc: not available
More information about the vlc-devel