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);
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__
#include <cmath>
#include "pbd/compose.h"
-#include "pbd/cpus.h"
#include "pbd/debug_rt_alloc.h"
#include "ardour/debug.h"
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);
}
_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
_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 {
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) {
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) {
#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"
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); }
}