summaryrefslogtreecommitdiff
path: root/libs/ardour
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2011-02-09 02:41:01 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2011-02-09 02:41:01 +0000
commite61b5e23c436c0e54cd000c6326b70ad789f1c4a (patch)
tree1ef1edd63f9dc9b90b40c2ee0d25546f2f78ce7a /libs/ardour
parent418e7ec22926cf3fe25ba7eea8e6e5bcc2238fd7 (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')
-rw-r--r--libs/ardour/ardour/graph.h2
-rw-r--r--libs/ardour/ardour/utils.h2
-rw-r--r--libs/ardour/graph.cc37
-rw-r--r--libs/ardour/session_process.cc8
-rw-r--r--libs/ardour/utils.cc35
5 files changed, 53 insertions, 31 deletions
diff --git a/libs/ardour/ardour/graph.h b/libs/ardour/ardour/graph.h
index 7984839431..a3f1523b15 100644
--- a/libs/ardour/ardour/graph.h
+++ b/libs/ardour/ardour/graph.h
@@ -58,6 +58,8 @@ class Graph : public SessionHandleRef
public:
Graph (Session & session);
+ uint32_t threads_in_use () const { return _thread_list.size(); }
+
void prep();
void trigger (GraphNode * n);
void rechain (boost::shared_ptr<RouteList> r);
diff --git a/libs/ardour/ardour/utils.h b/libs/ardour/ardour/utils.h
index 0b3fbc7b6c..dac4086cba 100644
--- a/libs/ardour/ardour/utils.h
+++ b/libs/ardour/ardour/utils.h
@@ -107,6 +107,8 @@ float meter_falloff_to_db_per_sec (float);
const char* native_header_format_extension (ARDOUR::HeaderFormat, const ARDOUR::DataType& type);
bool matching_unsuffixed_filename_exists_in (const std::string& dir, const std::string& name);
+uint32_t how_many_dsp_threads ();
+
#if __APPLE__
std::string CFStringRefToStdString(CFStringRef stringRef);
#endif // __APPLE__
diff --git a/libs/ardour/graph.cc b/libs/ardour/graph.cc
index 6fb9305d20..2ac465f1e9 100644
--- a/libs/ardour/graph.cc
+++ b/libs/ardour/graph.cc
@@ -21,7 +21,6 @@
#include <cmath>
#include "pbd/compose.h"
-#include "pbd/cpus.h"
#include "pbd/debug_rt_alloc.h"
#include "ardour/debug.h"
@@ -96,40 +95,29 @@ Graph::parameter_changed (std::string param)
void
Graph::reset_thread_list ()
{
- int num_cpu = hardware_concurrency();
- int pu = Config->get_processor_usage ();
- pthread_t a_thread;
- 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) {
+ uint32_t num_threads = how_many_dsp_threads ();
- num_threads = num_cpu;
-
- } else {
- /* use "pu" cores, if available
- */
-
- num_threads = min (num_cpu, pu);
- }
+ /* don't bother doing anything here if we already have the right
+ number of threads.
+ */
if (_thread_list.size() == num_threads) {
return;
}
Glib::Mutex::Lock lm (_session.engine().process_lock());
+ pthread_t a_thread;
if (!_thread_list.empty()) {
drop_threads ();
}
+ if (num_threads <= 1) {
+ /* no point creating 1 thread - the AudioEngine already gives us one
+ */
+ return;
+ }
+
if (AudioEngine::instance()->create_process_thread (boost::bind (&Graph::main_thread, this), &a_thread, 100000) == 0) {
_thread_list.push_back (a_thread);
}
@@ -139,9 +127,6 @@ Graph::reset_thread_list ()
_thread_list.push_back (a_thread);
}
}
-
- 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
diff --git a/libs/ardour/session_process.cc b/libs/ardour/session_process.cc
index 61c35da480..2c41594d21 100644
--- a/libs/ardour/session_process.cc
+++ b/libs/ardour/session_process.cc
@@ -106,7 +106,7 @@ Session::no_roll (pframes_t nframes)
_click_io->silence (nframes);
}
- if (Config->get_processor_usage() != 1) {
+ if (route_graph->threads_in_use() > 1) {
DEBUG_TRACE(DEBUG::Graph,"calling graph/no-roll\n");
route_graph->routes_no_roll( nframes, _transport_frame, end_frame, non_realtime_work_pending(), actively_recording(), declick);
} else {
@@ -148,10 +148,9 @@ Session::process_routes (pframes_t nframes, bool& need_butler)
const framepos_t start_frame = _transport_frame;
const framepos_t end_frame = _transport_frame + floor (nframes * _transport_speed);
- if (Config->get_processor_usage() != 1) {
+ if (route_graph->threads_in_use() > 1) {
DEBUG_TRACE(DEBUG::Graph,"calling graph/process-routes\n");
route_graph->process_routes( nframes, start_frame, end_frame, declick, record_active, rec_monitors, need_butler);
-
} else {
for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
@@ -190,8 +189,7 @@ Session::silent_process_routes (pframes_t nframes, bool& need_butler)
const framepos_t start_frame = _transport_frame;
const framepos_t end_frame = _transport_frame + lrintf(nframes * _transport_speed);
- if (Config->get_processor_usage() != 1) {
- cerr << "GRAPH PROCESS\n";
+ if (route_graph->threads_in_use() > 1) {
route_graph->silent_process_routes( nframes, start_frame, end_frame, record_active, rec_monitors, need_butler);
} else {
for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
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); }
}