From 8bd465fc615c66fbdbaa17876d055290ddfd9912 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sun, 29 Nov 2020 12:44:25 -0700 Subject: [PATCH] Add method to set thread_local _thread_sample_rate complete with debugging output --- libs/temporal/superclock.cc | 14 ++++++++++++++ libs/temporal/temporal/superclock.h | 1 + 2 files changed, 15 insertions(+) diff --git a/libs/temporal/superclock.cc b/libs/temporal/superclock.cc index d98883f996..eb46364d92 100644 --- a/libs/temporal/superclock.cc +++ b/libs/temporal/superclock.cc @@ -16,9 +16,23 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include + +#include +#include + +#include "pbd/pthread_utils.h" + #include "temporal/superclock.h" namespace Temporal { thread_local uint32_t _thread_sample_rate = 0; } +void +Temporal::set_thread_sample_rate (uint32_t sr) +{ + _thread_sample_rate = sr; + std::cout << pthread_name() << " 0x" << std::hex << pthread_self() << std::dec << " TID " << syscall(SYS_gettid) << " set TSR @ " << &_thread_sample_rate << " to " << sr << " = " << _thread_sample_rate << '\n'; +} + diff --git a/libs/temporal/temporal/superclock.h b/libs/temporal/temporal/superclock.h index d42dd2bcdc..369aed174a 100644 --- a/libs/temporal/temporal/superclock.h +++ b/libs/temporal/temporal/superclock.h @@ -35,6 +35,7 @@ static inline superclock_t samples_to_superclock (int samples, int sr) { return /* this needs to be updated per-thread at a suitable time */ extern thread_local uint32_t _thread_sample_rate; +void set_thread_sample_rate (uint32_t sr); }