summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorTim Mayberry <mojofunk@gmail.com>2015-09-11 23:26:31 +1000
committerTim Mayberry <mojofunk@gmail.com>2015-09-16 11:22:16 +1000
commit08e18a0cb47d862aaa42909fe92e554350dfe302 (patch)
tree6dd4fb054ab554ec55581711ee62d4e081789d75 /libs
parentf5e7aa11f9a601e400dbe859ccafc94c275cb885 (diff)
Move implementation for DSPLoadCalculator back into header
It can be inline now that it is much simpler
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/dsp_load_calculator.h33
-rw-r--r--libs/ardour/dsp_load_calculator.cc53
-rw-r--r--libs/ardour/wscript1
3 files changed, 29 insertions, 58 deletions
diff --git a/libs/ardour/ardour/dsp_load_calculator.h b/libs/ardour/ardour/dsp_load_calculator.h
index 42386e2cb0..1da9786d36 100644
--- a/libs/ardour/ardour/dsp_load_calculator.h
+++ b/libs/ardour/ardour/dsp_load_calculator.h
@@ -23,11 +23,9 @@
#include <cassert>
#include <algorithm>
-#include "ardour/libardour_visibility.h"
-
namespace ARDOUR {
-class LIBARDOUR_API DSPLoadCalculator {
+class DSPLoadCalculator {
public:
DSPLoadCalculator()
: m_max_time_us(0)
@@ -50,7 +48,34 @@ public:
m_start_timestamp_us = start_timestamp_us;
}
- void set_stop_timestamp_us(int64_t stop_timestamp_us);
+ void set_stop_timestamp_us(int64_t stop_timestamp_us)
+ {
+ m_stop_timestamp_us = stop_timestamp_us;
+
+ /* querying the performance counter can fail occasionally (-1).
+ * Also on some multi-core systems, timers are CPU specific and not
+ * synchronized. We assume they differ more than a few milliseconds
+ * (4 * nominal cycle time) and simply ignore cases where the
+ * execution switches cores.
+ */
+ if (m_start_timestamp_us < 0 || m_stop_timestamp_us < 0 ||
+ m_start_timestamp_us > m_stop_timestamp_us ||
+ elapsed_time_us() > max_timer_error()) {
+ return;
+ }
+
+ if (elapsed_time_us() > m_max_time_us) {
+ m_dsp_load = 1.0f;
+ } else {
+ const float load = elapsed_time_us() / (float)m_max_time_us;
+ if (load > m_dsp_load) {
+ m_dsp_load = load;
+ } else {
+ const float alpha = 0.2f * (m_max_time_us * 1e-6f);
+ m_dsp_load = m_dsp_load + alpha * (load - m_dsp_load) + 1e-12;
+ }
+ }
+ }
int64_t elapsed_time_us()
{
diff --git a/libs/ardour/dsp_load_calculator.cc b/libs/ardour/dsp_load_calculator.cc
deleted file mode 100644
index 789d3704f4..0000000000
--- a/libs/ardour/dsp_load_calculator.cc
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2015 Tim Mayberry <mojofunk@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include "ardour/dsp_load_calculator.h"
-
-namespace ARDOUR {
-
-void
-DSPLoadCalculator::set_stop_timestamp_us(int64_t stop_timestamp_us)
-{
- m_stop_timestamp_us = stop_timestamp_us;
-
- /* querying the performance counter can fail occasionally (-1).
- * Also on some multi-core systems, timers are CPU specific and not
- * synchronized. We assume they differ more than a few milliseconds
- * (4 * nominal cycle time) and simply ignore cases where the
- * execution switches cores.
- */
- if (m_start_timestamp_us < 0 || m_stop_timestamp_us < 0 ||
- m_start_timestamp_us > m_stop_timestamp_us ||
- elapsed_time_us() > max_timer_error()) {
- return;
- }
-
- if (elapsed_time_us() > m_max_time_us) {
- m_dsp_load = 1.0f;
- } else {
- const float load = elapsed_time_us() / (float)m_max_time_us;
- if (load > m_dsp_load) {
- m_dsp_load = load;
- } else {
- const float alpha = 0.2f * (m_max_time_us * 1e-6f);
- m_dsp_load = m_dsp_load + alpha * (load - m_dsp_load) + 1e-12;
- }
- }
-}
-
-} // namespace ARDOUR
diff --git a/libs/ardour/wscript b/libs/ardour/wscript
index becb2e117d..c0049b55fe 100644
--- a/libs/ardour/wscript
+++ b/libs/ardour/wscript
@@ -65,7 +65,6 @@ libardour_sources = [
'delivery.cc',
'directory_names.cc',
'diskstream.cc',
- 'dsp_load_calculator.cc',
'element_import_handler.cc',
'element_importer.cc',
'engine_slave.cc',