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:
parent
418e7ec229
commit
e61b5e23c4
@ -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);
|
||||
|
@ -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__
|
||||
|
@ -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
|
||||
uint32_t num_threads = how_many_dsp_threads ();
|
||||
|
||||
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) {
|
||||
|
||||
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
|
||||
|
@ -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) {
|
||||
|
@ -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); }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user