diff options
author | wm4 <wm4@nowhere> | 2015-01-05 12:34:34 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-01-05 12:34:34 +0100 |
commit | d7dfbc86105ae2ad04a547042140cd12353e65e5 (patch) | |
tree | 728c678e61395e45cbaf2a7def317840e8126d7f | |
parent | 0f4bf347c52543057404e5c36f504ab18b901dba (diff) |
player: use libavutil API to get number of CPUs
Our own code was introduced when FFmpeg didn't provide this API (or
maybe didn't even have a way to determine the CPU count). But now,
av_cpu_count() is available for all FFmpeg/Libav versions we support,
and there's no reason to have our own code.
libavutil's code seems to be slightly more sophisticated than our's, and
it's possible that the detected CPU count is different on some platforms
after this change.
-rw-r--r-- | common/av_common.c | 5 | ||||
-rw-r--r-- | old-makefile | 1 | ||||
-rw-r--r-- | osdep/numcores.c | 66 | ||||
-rw-r--r-- | osdep/numcores.h | 1 | ||||
-rw-r--r-- | wscript_build.py | 1 |
5 files changed, 2 insertions, 72 deletions
diff --git a/common/av_common.c b/common/av_common.c index eb357d9f05..2d976bbc8d 100644 --- a/common/av_common.c +++ b/common/av_common.c @@ -22,6 +22,7 @@ #include <libavutil/dict.h> #include <libavutil/opt.h> #include <libavutil/error.h> +#include <libavutil/cpu.h> #include <libavcodec/avcodec.h> #include "common/common.h" @@ -30,8 +31,6 @@ #include "av_common.h" #include "codecs.h" -#include "osdep/numcores.h" - int mp_lavc_set_extradata(AVCodecContext *avctx, void *ptr, int size) { if (size) { @@ -129,7 +128,7 @@ void mp_set_av_packet(AVPacket *dst, struct demux_packet *mpkt, AVRational *tb) void mp_set_avcodec_threads(struct mp_log *l, AVCodecContext *avctx, int threads) { if (threads == 0) { - threads = default_thread_count(); + threads = av_cpu_count(); if (threads < 1) { mp_warn(l, "Could not determine thread count to use, defaulting to 1.\n"); threads = 1; diff --git a/old-makefile b/old-makefile index d0d7ebb476..b3c97babe3 100644 --- a/old-makefile +++ b/old-makefile @@ -190,7 +190,6 @@ SOURCES = audio/audio.c \ options/parse_configfile.c \ options/path.c \ osdep/io.c \ - osdep/numcores.c \ osdep/semaphore_osx.c \ osdep/subprocess-posix.c \ osdep/terminal-unix.c \ diff --git a/osdep/numcores.c b/osdep/numcores.c deleted file mode 100644 index 86a327e041..0000000000 --- a/osdep/numcores.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <errno.h> -#include <unistd.h> - -#include "numcores.h" - -#ifdef _SC_NPROCESSORS_ONLN -#define SCNAME _SC_NPROCESSORS_ONLN -#elif defined _SC_NPROC_ONLN -#define SCNAME _SC_NPROC_ONLN -#elif defined _SC_CRAY_NCPU -#define SCNAME _SC_CRAY_NCPU -#endif - -#ifdef _WIN32 - -#define WIN32_LEAN_AND_MEAN -#include <windows.h> -int default_thread_count(void) -{ - SYSTEM_INFO info; - GetSystemInfo(&info); - int count = info.dwNumberOfProcessors; - if (count > 0) - return count; - return -1; -} - -#elif defined SCNAME - -int default_thread_count(void) -{ - long nprocs = sysconf(SCNAME); - if (nprocs < 1) - return -1; - return nprocs; -} - -#else - -int default_thread_count(void) -{ - return -2; -} - -#endif diff --git a/osdep/numcores.h b/osdep/numcores.h deleted file mode 100644 index b999d9e275..0000000000 --- a/osdep/numcores.h +++ /dev/null @@ -1 +0,0 @@ -int default_thread_count(void); diff --git a/wscript_build.py b/wscript_build.py index 2771bbbbec..c91f5de4c7 100644 --- a/wscript_build.py +++ b/wscript_build.py @@ -374,7 +374,6 @@ def build(ctx): ## osdep ( getch2_c ), ( "osdep/io.c" ), - ( "osdep/numcores.c"), ( "osdep/timer.c" ), ( timer_c ), ( "osdep/threads.c" ), |