summaryrefslogtreecommitdiff
path: root/libs/ardour/graph.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2011-02-09 00:01:56 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2011-02-09 00:01:56 +0000
commit5376bc757f913764e61ac17a8efc05dbc7bb93d7 (patch)
tree4ad9381c02915ea55c405ffb57019fcc029a81d7 /libs/ardour/graph.cc
parentf0052b463dc757223fa8dee3c2cd41b6a4ea6f41 (diff)
fix num DSP threads computation (TODO: move into a utility function for Sakari's graph too)
git-svn-id: svn://localhost/ardour2/branches/3.0@8791 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/graph.cc')
-rw-r--r--libs/ardour/graph.cc37
1 files changed, 21 insertions, 16 deletions
diff --git a/libs/ardour/graph.cc b/libs/ardour/graph.cc
index 29e95b67fd..6fb9305d20 100644
--- a/libs/ardour/graph.cc
+++ b/libs/ardour/graph.cc
@@ -97,32 +97,37 @@ void
Graph::reset_thread_list ()
{
int num_cpu = hardware_concurrency();
- uint32_t num_threads = num_cpu;
int pu = Config->get_processor_usage ();
pthread_t a_thread;
-
- Glib::Mutex::Lock lm (_session.engine().process_lock());
-
- if (!_thread_list.empty()) {
- drop_threads ();
- }
+ 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 ((uint32_t) -pu < num_threads) {
- num_threads += pu;
- } else {
- num_threads = 1;
+ if (-pu < num_cpu) {
+ num_threads = num_cpu + pu;
}
+
+ } else if (pu == 0) {
+
+ num_threads = num_cpu;
+
} else {
/* use "pu" cores, if available
*/
- if ((uint32_t) pu <= num_threads) {
- num_threads = pu;
- }
+ num_threads = min (num_cpu, pu);
+ }
+
+ if (_thread_list.size() == num_threads) {
+ return;
+ }
+
+ Glib::Mutex::Lock lm (_session.engine().process_lock());
+
+ if (!_thread_list.empty()) {
+ drop_threads ();
}
if (AudioEngine::instance()->create_process_thread (boost::bind (&Graph::main_thread, this), &a_thread, 100000) == 0) {
@@ -135,8 +140,8 @@ Graph::reset_thread_list ()
}
}
- info << string_compose (_("Using %2 threads on %1 CPUs"), _thread_list.size(), num_threads) << endmsg;
- cerr << string_compose (_("Using %2 threads on %1 CPUs"), _thread_list.size(), num_threads) << endl;
+ info << string_compose (_("Using %1 threads for DSP on %2 CPUs"), _thread_list.size(), num_cpu) << endmsg;
+ cerr << string_compose (_("Using %1 threads for DSP on %2 CPUs"), _thread_list.size(), num_cpu) << endl;
}
void