[vlc-devel] X264 and multithreading on win32

Rémi Denis-Courmont rdenis at simphalempin.com
Tue Feb 5 20:03:09 CET 2008


Le Tuesday 05 February 2008 20:47:38 Benjamin Pracht, vous avez écrit :
> When pthreads-win32 is linked statically with an application, this
> application has to call both pthread_win32_process_attach_np and
> pthread_win32_process_attach_np before doing any pthread call. This
> initializes some static data in the library (beurk).

I cannot see how pthread-win32 could possibly operate otherwise.
POSIX threads include nifty features such as statically initialized mutexes 
and condition variables, and thread-safe run-once code.

To support these on top of the Win32 API which does AFAIK NOT provide static 
mutexes creation, the only way is to have some static data inside the wrapper 
library itself.

I would assume that, when it is linked dynamically, pthread-win32 leverages 
the DLL entry points to take care of such initialization automagically. 
Obviously, this cannot work when linking statically. Of course, it could do 
some reference counting and lazy initialization, but that would not be 
thread-safe. That would not be very sane for a *threading* library.

> Does anybody have an idea of how/where to call this initialization
> functions properly?

Link dynamically, or do the reference counting inside the x264 Open and Close 
callbacks with a global LibVLC mutex, much like the gnutls plugin initializes 
gcrypt (the underlying libgcrypt, rather than the actually used libgnutls).

-- 
Rémi Denis-Courmont
http://www.remlab.net/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20080205/60985982/attachment.sig>
-------------- next part --------------
_______________________________________________
vlc-devel mailing list
To unsubscribe or modify your subscription options:
http://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list