summaryrefslogtreecommitdiff
path: root/libs/backends/dummy/dummy_audiobackend.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2014-11-07 12:17:15 +0100
committerRobin Gareus <robin@gareus.org>2014-11-07 12:17:15 +0100
commit159cb4d2f916401329593cf7aaec1e6fc68d91ac (patch)
tree7d27b197e50f40aa1d67a9c24d35b9ea699c81ce /libs/backends/dummy/dummy_audiobackend.cc
parent7670e463cc98c351bc9203ede7d95da06af59b21 (diff)
another hack for windows timers, DSP load calculation
Diffstat (limited to 'libs/backends/dummy/dummy_audiobackend.cc')
-rw-r--r--libs/backends/dummy/dummy_audiobackend.cc17
1 files changed, 13 insertions, 4 deletions
diff --git a/libs/backends/dummy/dummy_audiobackend.cc b/libs/backends/dummy/dummy_audiobackend.cc
index a128e56437..7c2f101ae7 100644
--- a/libs/backends/dummy/dummy_audiobackend.cc
+++ b/libs/backends/dummy/dummy_audiobackend.cc
@@ -1167,17 +1167,24 @@ DummyAudioBackend::main_process_thread ()
}
if (!_freewheeling) {
+ const int64_t nomial_time = 1e6 * _samples_per_period / _samplerate;
clock2 = _x_get_monotonic_usec();
#ifdef PLATFORM_WINDOWS
- // querying the performance counter can fail occasionally
- if (clock1 < 0 || clock2 < 0) {
+ bool win_timers_ok = true;
+ /* 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 (clock1 < 0 || clock2 < 0 || (clock1 > clock2) || (clock2 - clock1) > 4 * nomial_time) {
clock2 = clock1 = 0;
+ win_timers_ok = false;
}
#endif
const int64_t elapsed_time = clock2 - clock1;
- const int64_t nomial_time = 1e6 * _samples_per_period / _samplerate;
#ifdef PLATFORM_WINDOWS
- if (clock1 >= 0 && clock2 >= 0)
+ if (win_timers_ok)
#endif
{ // low pass filter
_dsp_load = _dsp_load + .05 * ((elapsed_time / (float) nomial_time) - _dsp_load) + 1e-12;
@@ -1192,6 +1199,8 @@ DummyAudioBackend::main_process_thread ()
_dsp_load = 1.0f;
Glib::usleep (100); // don't hog cpu
}
+
+ /* beginning of netx cycle */
clock1 = _x_get_monotonic_usec();
bool connections_changed = false;