[vlc-devel] [PATCH]: fix a CoInitializeEx() issue on Windows

Rémi Denis-Courmont remi at remlab.net
Tue Jul 16 20:22:04 CEST 2019


Le perjantaina 12. heinäkuuta 2019, 15.52.45 EEST Steve Lhomme a écrit :
> On 2019-07-12 14:32, Thomas Guillem wrote:
> > Hello,
> > 
> > OK for me.
> > 
> > Steve ?
> 
> I think you meant Hugo who's the one who has been playing with that.
> 
> Anyway it seems correct. The CoInitializeEx() calls in our Qt code uses
> COINIT_APARTMENTTHREADED.

I don't think it's that simple.

If you create a COM object in the process' multi-thread apartment  (MTA), then 
you can only access[1] it from a thread that is currently bound to the MTA.

If you create a COM object in a given thread's single-thread apartment (STA) 
then you can only access[1] it from _that_ thread while it remains bound to 
its STA. That is why it is called "single thread" apartment.

So if you want to access a COM object from the Qt UI's STA-bound thread, you 
must have created it on the Qt UI's thread. As such, I don't think changing 
the vout display's threading model would fix anything; it would rather break 
even more things.

[1] invoke a function in the object's COM vtable.


Ultimately, the problem is that no conventions were defined in VLC for how to 
deal with COM, notably:

1) Can core functions and callbacks be invoked from an STA-bound thread, or 
can functions and callbacks assume that binding the MTA will succeed, or 
neither? (but not both)

2) Can core functions and callbacks be invoked from an MTA-bound thread, or 
can functions and callbacks assume that instantiating an STA will succeed, or 
neither? (but also not both)

-- 
Реми Дёни-Курмон
http://www.remlab.net/





More information about the vlc-devel mailing list