From d7dfbc86105ae2ad04a547042140cd12353e65e5 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 5 Jan 2015 12:34:34 +0100 Subject: 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. --- common/av_common.c | 5 ++--- old-makefile | 1 - osdep/numcores.c | 66 ------------------------------------------------------ osdep/numcores.h | 1 - wscript_build.py | 1 - 5 files changed, 2 insertions(+), 72 deletions(-) delete mode 100644 osdep/numcores.c delete mode 100644 osdep/numcores.h 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 #include #include +#include #include #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 -#include -#include -#include -#include - -#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 -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" ), -- cgit v1.2.3