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
This commit is contained in:
Paul Davis 2011-02-09 02:41:01 +00:00
parent 418e7ec229
commit e61b5e23c4
5 changed files with 53 additions and 31 deletions

View file

@ -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); }
}