diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2018-10-29 15:35:13 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2018-10-29 15:35:13 +0100 |
commit | bf82967d4c04946ae6e0490ea28e160a856fc81b (patch) | |
tree | e6eaffeed8741ea6203a0323826153179a3d91df /src/ManagementServer.h | |
parent | 234420f5c8a37acd94a41ddd1dc33979bc843e76 (diff) | |
download | dabmux-bf82967d4c04946ae6e0490ea28e160a856fc81b.tar.gz dabmux-bf82967d4c04946ae6e0490ea28e160a856fc81b.tar.bz2 dabmux-bf82967d4c04946ae6e0490ea28e160a856fc81b.zip |
Rework inputstat to use absolute timestamps internally
Diffstat (limited to 'src/ManagementServer.h')
-rw-r--r-- | src/ManagementServer.h | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/ManagementServer.h b/src/ManagementServer.h index 17b8bda..18af48c 100644 --- a/src/ManagementServer.h +++ b/src/ManagementServer.h @@ -107,28 +107,34 @@ class InputStat std::string m_name; /************ STATISTICS ***********/ - // Calculate minimum and maximum buffer fill from - // a FIFO of values from the last few seconds - std::deque<long> m_buffer_fill_stats; - std::chrono::time_point<std::chrono::steady_clock> m_time_last_buffer_notify; + // Keep track of buffer fill with timestamps, so that we + // can calculate the correct state from it. + struct fill_stat_t { + std::chrono::time_point<std::chrono::steady_clock> timestamp; + long bufsize; + }; + std::deque<fill_stat_t> m_buffer_fill_stats; // counter of number of overruns and underruns since startup - uint32_t m_num_underruns; - uint32_t m_num_overruns; + uint32_t m_num_underruns = 0; + uint32_t m_num_overruns = 0; // Peak audio levels (linear 16-bit PCM) for the two channels. // Keep a FIFO of values from the last minutes, apply // a short window to also see short-term fluctuations. - std::deque<int> m_peaks_left; - std::deque<int> m_peaks_right; - std::chrono::time_point<std::chrono::steady_clock> m_time_last_peak_notify; + struct peak_stat_t { + std::chrono::time_point<std::chrono::steady_clock> timestamp; + int peak_left; + int peak_right; + }; + std::deque<peak_stat_t> m_peak_stats; size_t m_short_window_length = 0; /************* STATE ***************/ /* Variables used for determining the input state */ - int m_glitch_counter; // saturating counter - int m_silence_counter; // saturating counter + int m_glitch_counter = 0; // saturating counter + int m_silence_counter = 0; // saturating counter std::chrono::time_point<std::chrono::steady_clock> m_time_last_event; // The mutex that has to be held during all notify and readout |