[FFmpeg-devel] [PATCH] winrt: multithreading support
wang-bin
wbsecg1 at gmail.com
Tue Sep 29 20:18:29 CEST 2015
---
compat/w32pthreads.h | 11 +++++++++++
configure | 4 ++++
libavutil/cpu.c | 11 ++++++++++-
3 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/compat/w32pthreads.h b/compat/w32pthreads.h
index 87e816f..9828e8a 100644
--- a/compat/w32pthreads.h
+++ b/compat/w32pthreads.h
@@ -37,7 +37,13 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
+#if defined(WINAPI_FAMILY) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#define TARGET_OS_WINRT
+#endif
+#ifndef TARGET_OS_WINRT
#include <process.h>
+#endif
+
#include "libavutil/attributes.h"
#include "libavutil/common.h"
@@ -82,8 +88,13 @@ static av_unused int pthread_create(pthread_t *thread, const void *unused_attr,
{
thread->func = start_routine;
thread->arg = arg;
+#ifndef TARGET_OS_WINRT
thread->handle = (void*)_beginthreadex(NULL, 0, win32thread_worker, thread,
0, NULL);
+#else
+ thread->handle = (void*)CreateThread(NULL, 0, win32thread_worker, thread,
+ 0, NULL);
+#endif
return !thread->handle;
}
diff --git a/configure b/configure
index 01f1797..4a7cdff 100755
--- a/configure
+++ b/configure
@@ -5189,6 +5189,10 @@ check_type "vdpau/vdpau.h" "VdpPictureInfoHEVC"
if ! disabled w32threads && ! enabled pthreads; then
check_func_headers "windows.h process.h" _beginthreadex &&
enable w32threads || disable w32threads
+ if ! enabled w32threads; then
+ check_func_headers "windows.h" CreateThread &&
+ enable w32threads || disable w32threads
+ fi
fi
# check for some common methods of building with pthread support
diff --git a/libavutil/cpu.c b/libavutil/cpu.c
index 780368d..5968bc5 100644
--- a/libavutil/cpu.c
+++ b/libavutil/cpu.c
@@ -30,8 +30,11 @@
#endif
#include <sched.h>
#endif
-#if HAVE_GETPROCESSAFFINITYMASK
+#if HAVE_WINDOWS_H
#include <windows.h>
+#if defined(WINAPI_FAMILY) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#define TARGET_OS_WINRT
+#endif
#endif
#if HAVE_SYSCTL
#if HAVE_SYS_PARAM_H
@@ -253,6 +256,9 @@ int av_cpu_count(void)
static volatile int printed;
int nb_cpus = 1;
+#ifdef TARGET_OS_WINRT
+ SYSTEM_INFO sysinfo;
+#endif
#if HAVE_SCHED_GETAFFINITY && defined(CPU_COUNT)
cpu_set_t cpuset;
@@ -274,6 +280,9 @@ int av_cpu_count(void)
nb_cpus = sysconf(_SC_NPROC_ONLN);
#elif HAVE_SYSCONF && defined(_SC_NPROCESSORS_ONLN)
nb_cpus = sysconf(_SC_NPROCESSORS_ONLN);
+#elif defined(TARGET_OS_WINRT)
+ GetNativeSystemInfo(&sysinfo);
+ nb_cpus = sysinfo.dwNumberOfProcessors;
#endif
if (!printed) {
--
2.1.4
More information about the ffmpeg-devel
mailing list