[vlc-devel] X264 and multithreading on win32
bigben+spam at videolan.org
Tue Feb 5 19:47:38 CET 2008
I think I have a better idea of the reason why x264 crashes vlc when
compiled with pthreads-win32 on windows.
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).
pthread_win32_process_detach_np and pthread_win32_process_detach_np
should be called as well when pthreads-win32 is not used. When adding
these lines in x264.c, before x264-encoder-open, linking the module with
pthreads-win32 and adding the -DPTW32_STATIC_LIB CFLAG, I'm able to use
x264 on windows with multithreading enabled.
Now, pthreads-win32 doesn't really check if the initilization function
has already been called by the application, and doesn't keep any
refcount (rebeurk). This means that with the previous approach, if the
application uses the x264 vlc module a second time, the library is going
to be initialized a second time. Worse, if we add
pthread_win32_process_detach_np to the encoder close function, we'll end
up uninitializing the lib while it may still be in use.
Does anybody have an idea of how/where to call this initialization
vlc-devel mailing list
To unsubscribe or modify your subscription options:
More information about the vlc-devel