[MPlayer-cygwin] pthreads support for mingw32

Gianluigi Tiesi mplayer at netfarm.it
Sun Jun 5 03:28:58 CEST 2005


On Fri, Jun 03, 2005 at 09:23:52AM +0200, Gianluigi Tiesi wrote:
> My usual builds are ok, only mencoder gets pthreads dep, anyway it would
> be usefull a disable-pthreads configure option
> Bye
> -- 
This patches adds the support to configure to disable pthreads using
--disable-pthreads, this because I've hacked a bit x264 to use
native threads on win32, I'll forward the patch to x264 developers
but I'm attaching also the x264 patch if someone want to make
some tests with it.

Bye

-- 
Gianluigi Tiesi <sherpya at netfarm.it>
EDP Project Leader
Netfarm S.r.l. - http://www.netfarm.it/
Free Software: http://oss.netfarm.it/
-------------- next part --------------
diff -NubBr -xCVS -xhelp_mp.h -x'*.a' -x'*.exe' -x'*.o' -xconfigure.log -xconfig.mak -x.cvsignore -xconfig.h -xcodecs.conf.h -xversion.h -x.depend main/configure sherpya/configure
--- main/configure	2005-06-05 02:50:25.647393600 +0200
+++ sherpya/configure	2005-06-05 03:23:33.515808000 +0200
@@ -195,6 +195,7 @@
                             library [autodetect]
   --disable-ftp          Disable ftp support [enabled]
   --disable-vstream      Disable tivo vstream client support [autodetect]
+  --disable-pthreads     Disable Posix threads support [autodetect]
 
 Codecs:
   --enable-gif		 enable gif support [autodetect]
@@ -1472,6 +1473,7 @@
 _gethostbyname2=auto
 _ftp=yes
 _vstream=auto
+_pthreads=yes
 for ac_option do
   case "$ac_option" in
   # Skip 1st pass
@@ -1724,6 +1726,8 @@
   --disable-ftp)        _ftp=no         ;;
   --enable-vstream)     _vstream=yes    ;;
   --disable-vstream)    _vstream=no     ;;
+  --enable-pthreads)    _pthreads=yes   ;;
+  --disable-pthreads)   _pthreads=no    ;;
 
   --enable-fribidi)     _fribidi=yes    ;;
   --disable-fribidi)    _fribidi=no     ;;
@@ -2788,6 +2792,8 @@
 _def_threads='#undef HAVE_THREADS'
 
 echocheck "pthread"
+_ld_pthread=''
+if test "$_pthreads" != no ; then
 cat > $TMPC << EOF
 #include <pthread.h>
 void* func(void *arg) { return arg; }
@@ -2819,6 +2825,7 @@
     _ld_pthread='' ; _nas=no ; _tv_v4l=no ; _macosx=no ; _win32=no
   fi
 fi
+fi
 if test "$_ld_pthread" != '' ; then
   echores "yes (using $_ld_pthread)"
   _pthreads='yes'
-------------- next part --------------
Index: encoder/encoder.c
===================================================================
--- encoder/encoder.c	(revision 248)
+++ encoder/encoder.c	(working copy)
@@ -36,6 +36,10 @@
 #include <pthread.h>
 #endif
 #endif
+
+#ifdef __WIN32__
+#include <windows.h>
+#endif
 
 #include "common/common.h"
 #include "common/cpu.h"
@@ -368,7 +372,7 @@
 
     h->param.i_threads = x264_clip3( h->param.i_threads, 1, X264_SLICE_MAX );
     h->param.i_threads = X264_MIN( h->param.i_threads, h->param.i_height / 16 );
-#if !(HAVE_PTHREAD)
+#if !(__WIN32__) && !(HAVE_PTHREAD)
     if( h->param.i_threads > 1 )
     {
         x264_log( h, X264_LOG_WARNING, "not compiled with pthread support!\n");
@@ -1055,6 +1059,18 @@
             for( i = 0; i < h->param.i_threads; i++ )
                 pthread_join( handles[i], &status );
         }
+#elif defined(__WIN32__)
+        {
+            HANDLE handles[X264_SLICE_MAX];
+            DWORD tid;
+            for( i = 0; i < h->param.i_threads; i++ )
+                handles[i] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) x264_slice_write, (LPVOID) h->thread[i], 0, &tid);
+            for( i = 0; i < h->param.i_threads; i++ )
+            {
+                WaitForSingleObject(handles[i], INFINITE);
+                CloseHandle(handles[i]);
+            }
+        }
 #else
         for( i = 0; i < h->param.i_threads; i++ )
             x264_slice_write( h->thread[i] );


More information about the MPlayer-cygwin mailing list