diff options
author | Janne Grunau <janne-libav@jannau.net> | 2011-12-22 21:10:07 +0100 |
---|---|---|
committer | Janne Grunau <janne-libav@jannau.net> | 2011-12-22 21:50:07 +0100 |
commit | b9e2226972737ab202ac1f5a6e005af80072bb39 (patch) | |
tree | 128a072463ccf929240b46f820b9d7416c5e432b /libavcodec/pthread.c | |
parent | ad29ecbff0aa41adc535c118cbd956b93dab7289 (diff) | |
download | ffmpeg-b9e2226972737ab202ac1f5a6e005af80072bb39.tar.gz |
bsd: use number of logical CPUs as automatic thread count
Diffstat (limited to 'libavcodec/pthread.c')
-rw-r--r-- | libavcodec/pthread.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c index bf6733fe7f..0b57156b99 100644 --- a/libavcodec/pthread.c +++ b/libavcodec/pthread.c @@ -36,6 +36,9 @@ #include <sched.h> #elif HAVE_GETSYSTEMINFO #include <windows.h> +#elif HAVE_SYSCTL +#include <sys/sysctl.h> +#include <sys/types.h> #endif #include "avcodec.h" @@ -162,6 +165,13 @@ static int get_logical_cpus(AVCodecContext *avctx) SYSTEM_INFO sysinfo; GetSystemInfo(&sysinfo); nb_cpus = sysinfo.dwNumberOfProcessors; +#elif HAVE_SYSCTL + int mib[2] = { CTL_HW, HW_NCPU }; + size_t len = sizeof(nb_cpus); + + ret = sysctl(mib, 2, &nb_cpus, &len, NULL, 0); + if (ret == -1) + nb_cpus = 0; #endif av_log(avctx, AV_LOG_DEBUG, "detected %d logical cores\n", nb_cpus); return FFMIN(nb_cpus, MAX_AUTO_THREADS); |