diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2011-02-09 02:41:01 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2011-02-09 02:41:01 +0000 |
commit | e61b5e23c436c0e54cd000c6326b70ad789f1c4a (patch) | |
tree | 1ef1edd63f9dc9b90b40c2ee0d25546f2f78ce7a /libs/ardour/utils.cc | |
parent | 418e7ec22926cf3fe25ba7eea8e6e5bcc2238fd7 (diff) |
split out ARDOUR::how_many_dsp_threads() ; fix test for whether to use use route_graph or just process routes in-thread
git-svn-id: svn://localhost/ardour2/branches/3.0@8793 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/utils.cc')
-rw-r--r-- | libs/ardour/utils.cc | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/libs/ardour/utils.cc b/libs/ardour/utils.cc index f9d16a47b4..b19aad4fa9 100644 --- a/libs/ardour/utils.cc +++ b/libs/ardour/utils.cc @@ -44,12 +44,15 @@ #include <wordexp.h> #endif +#include "pbd/cpus.h" #include "pbd/error.h" #include "pbd/stacktrace.h" #include "pbd/xml++.h" #include "pbd/basename.h" #include "pbd/strsplit.h" + #include "ardour/utils.h" +#include "ardour/rc_configuration.h" #include "i18n.h" @@ -651,6 +654,38 @@ matching_unsuffixed_filename_exists_in (const string& dir, const string& path) return ret; } +uint32_t +how_many_dsp_threads () +{ + int num_cpu = hardware_concurrency(); + int pu = Config->get_processor_usage (); + uint32_t num_threads = max (num_cpu - 1, 2); // default to number of cpus minus one, or 2, whichever is larger + + if (pu < 0) { + /* pu is negative: use "pu" less cores for DSP than appear to be available + */ + + if (-pu < num_cpu) { + num_threads = num_cpu + pu; + } + + } else if (pu == 0) { + + /* use all available CPUs + */ + + num_threads = num_cpu; + + } else { + /* use "pu" cores, if available + */ + + num_threads = min (num_cpu, pu); + } + + return num_threads; +} + extern "C" { void c_stacktrace() { stacktrace (cerr); } } |