mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 06:44:57 +01:00
Use PBD namespace for free CPU functions
Ideally never put methods in the global namespace to prevent potential conflicts.
This commit is contained in:
parent
b1d5f065db
commit
5ffc3aa28b
8 changed files with 14 additions and 10 deletions
|
|
@ -157,7 +157,7 @@ namespace ARDOUR {
|
|||
|
||||
ExportGraphBuilder::ExportGraphBuilder (Session const & session)
|
||||
: session (session)
|
||||
, thread_pool (hardware_concurrency())
|
||||
, thread_pool (PBD::hardware_concurrency())
|
||||
{
|
||||
process_buffer_samples = session.engine().samples_per_cycle();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -749,7 +749,7 @@ ARDOUR::init (bool try_optimization, const char* localedir, bool with_gui)
|
|||
* WaveViewThreads::start_threads adds `min (8, hw - 1)`
|
||||
*
|
||||
*/
|
||||
BufferManager::init (hardware_concurrency () * 3 + 6);
|
||||
BufferManager::init (PBD::hardware_concurrency () * 3 + 6);
|
||||
|
||||
PannerManager::instance ().discover_panners ();
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ IOTaskList::IOTaskList (uint32_t n_threads)
|
|||
, _exec_sem ("io thread exec", 0)
|
||||
, _idle_sem ("io thread idle", 0)
|
||||
{
|
||||
assert (n_threads <= hardware_concurrency ());
|
||||
assert (n_threads <= PBD::hardware_concurrency ());
|
||||
|
||||
if (n_threads < 2) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -610,8 +610,8 @@ LuaBindings::common (lua_State* L)
|
|||
.addConst ("UseGroup", PBD::Controllable::GroupControlDisposition(PBD::Controllable::UseGroup))
|
||||
.endNamespace ()
|
||||
|
||||
.addFunction ("hardware_concurrency", hardware_concurrency)
|
||||
.addFunction ("max_mmcss_threads_per_process", max_mmcss_threads_per_process)
|
||||
.addFunction ("hardware_concurrency", PBD::hardware_concurrency)
|
||||
.addFunction ("max_mmcss_threads_per_process", PBD::max_mmcss_threads_per_process)
|
||||
|
||||
.endNamespace (); // PBD
|
||||
|
||||
|
|
|
|||
|
|
@ -718,7 +718,7 @@ ARDOUR::how_many_dsp_threads ()
|
|||
{
|
||||
/* CALLER MUST HOLD PROCESS LOCK */
|
||||
|
||||
int num_cpu = hardware_concurrency();
|
||||
int num_cpu = PBD::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
|
||||
|
||||
|
|
@ -750,7 +750,7 @@ ARDOUR::how_many_dsp_threads ()
|
|||
uint32_t
|
||||
ARDOUR::how_many_io_threads ()
|
||||
{
|
||||
int num_cpu = hardware_concurrency();
|
||||
int num_cpu = PBD::hardware_concurrency();
|
||||
int pu = Config->get_io_thread_count ();
|
||||
uint32_t num_threads = max (num_cpu - 2, 2);
|
||||
if (pu < 0) {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
#endif
|
||||
|
||||
int32_t
|
||||
max_mmcss_threads_per_process ()
|
||||
PBD::max_mmcss_threads_per_process ()
|
||||
{
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
DWORD dwType = REG_DWORD;
|
||||
|
|
@ -61,7 +61,7 @@ max_mmcss_threads_per_process ()
|
|||
}
|
||||
|
||||
uint32_t
|
||||
hardware_concurrency()
|
||||
PBD::hardware_concurrency()
|
||||
{
|
||||
if (getenv("ARDOUR_CONCURRENCY")) {
|
||||
int c = atoi (getenv("ARDOUR_CONCURRENCY"));
|
||||
|
|
|
|||
|
|
@ -22,5 +22,9 @@
|
|||
|
||||
#include "pbd/libpbd_visibility.h"
|
||||
|
||||
namespace PBD{
|
||||
|
||||
LIBPBD_API extern uint32_t hardware_concurrency ();
|
||||
LIBPBD_API extern int32_t max_mmcss_threads_per_process ();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -342,7 +342,7 @@ WaveViewThreads::start_threads ()
|
|||
{
|
||||
assert (!_threads.size());
|
||||
|
||||
const int num_cpus = hardware_concurrency ();
|
||||
const int num_cpus = PBD::hardware_concurrency ();
|
||||
|
||||
/* the upper limit of 8 here is entirely arbitrary. It just doesn't
|
||||
* seem worthwhile having "ncpus" of low priority threads for
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue