Add support for CPU DMA latency requests
This commit is contained in:
@@ -218,6 +218,7 @@ CONFIG_VARIABLE_SPECIAL (std::string, default_session_parent_dir, "default-sessi
|
||||
#endif
|
||||
CONFIG_VARIABLE (bool, allow_special_bus_removal, "allow-special-bus-removal", false)
|
||||
CONFIG_VARIABLE (int32_t, processor_usage, "processor-usage", -1)
|
||||
CONFIG_VARIABLE (int32_t, cpu_dma_latency, "cpu-dma-latency", 0) /* >=0 to enable */
|
||||
CONFIG_VARIABLE (gain_t, max_gain, "max-gain", 2.0) /* +6.0dB */
|
||||
CONFIG_VARIABLE (uint32_t, max_recent_sessions, "max-recent-sessions", 10)
|
||||
CONFIG_VARIABLE (uint32_t, max_recent_templates, "max-recent-templates", 10)
|
||||
|
||||
@@ -166,6 +166,7 @@ std::map<std::string, bool> ARDOUR::reserved_io_names;
|
||||
|
||||
static bool have_old_configuration_files = false;
|
||||
static bool running_from_gui = false;
|
||||
static int cpu_dma_latency_fd = -1;
|
||||
|
||||
namespace ARDOUR {
|
||||
extern void setup_enum_writer ();
|
||||
@@ -283,6 +284,42 @@ setup_hardware_optimization (bool try_optimization)
|
||||
AudioGrapher::Routines::override_apply_gain_to_buffer (apply_gain_to_buffer);
|
||||
}
|
||||
|
||||
static bool
|
||||
request_dma_latency ()
|
||||
{
|
||||
#if !(defined PLATFORM_WINDOWS || defined __APPLE__)
|
||||
if (!Glib::file_test ("/dev/cpu_dma_latency", Glib::FILE_TEST_EXISTS)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* maximum latency in usecs, or 0 to prevent transitions to deep sleep states */
|
||||
int32_t target = Config->get_cpu_dma_latency ();
|
||||
|
||||
cpu_dma_latency_fd = ::open("/dev/cpu_dma_latency", O_WRONLY);
|
||||
if (cpu_dma_latency_fd < 0) {
|
||||
warning << string_compose (_("Could not set DMA latency to %1 usec (%2)"), target, strerror (errno)) << endmsg;
|
||||
return false;
|
||||
}
|
||||
if (::write (cpu_dma_latency_fd, &target, sizeof(target)) > 0) {
|
||||
info << string_compose (_("Set DMA latency to %1 usec"), target) << endmsg;
|
||||
} else {
|
||||
warning << string_compose (_("Could not set DMA latency to %1 usec (%2)"), target, strerror (errno)) << endmsg;
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
release_dma_latency ()
|
||||
{
|
||||
#if !(defined PLATFORM_WINDOWS || defined __APPLE__)
|
||||
if (cpu_dma_latency_fd >= 0) {
|
||||
::close (cpu_dma_latency_fd);
|
||||
}
|
||||
cpu_dma_latency_fd = -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
lotsa_files_please ()
|
||||
{
|
||||
@@ -564,6 +601,10 @@ ARDOUR::init (bool use_windows_vst, bool try_optimization, const char* localedir
|
||||
|
||||
setup_hardware_optimization (try_optimization);
|
||||
|
||||
if (Config->get_cpu_dma_latency () >= 0) {
|
||||
request_dma_latency ();
|
||||
}
|
||||
|
||||
SourceFactory::init ();
|
||||
Analyser::init ();
|
||||
|
||||
@@ -669,6 +710,7 @@ ARDOUR::cleanup ()
|
||||
return;
|
||||
}
|
||||
|
||||
release_dma_latency ();
|
||||
engine_startup_connection.disconnect ();
|
||||
|
||||
delete &ControlProtocolManager::instance ();
|
||||
|
||||
Reference in New Issue
Block a user