summaryrefslogtreecommitdiffstats
path: root/src/ManagementServer.h
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2018-02-19 11:24:26 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2018-02-19 11:24:26 +0100
commiteff41c50e52d6ce7ef1d3d7be8072a6c27875df4 (patch)
treea3511dc28d469d63decd70f799a7483acfb0b28a /src/ManagementServer.h
parent07b303a738c82c53c835221f675d6d3b82948357 (diff)
downloaddabmux-eff41c50e52d6ce7ef1d3d7be8072a6c27875df4.tar.gz
dabmux-eff41c50e52d6ce7ef1d3d7be8072a6c27875df4.tar.bz2
dabmux-eff41c50e52d6ce7ef1d3d7be8072a6c27875df4.zip
ManagementServer: make audio_levels statistic more responsive
Diffstat (limited to 'src/ManagementServer.h')
-rw-r--r--src/ManagementServer.h76
1 files changed, 8 insertions, 68 deletions
diff --git a/src/ManagementServer.h b/src/ManagementServer.h
index 1b432d5..885565a 100644
--- a/src/ManagementServer.h
+++ b/src/ManagementServer.h
@@ -57,14 +57,10 @@
#include <chrono>
#include <deque>
#include <boost/thread.hpp>
-#include <boost/bind.hpp>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
-#include <ctime>
#include <cmath>
-#define MIN_FILL_BUFFER_UNDEF (-1)
-
/*** State handing ***/
/* An input can be in one of the following three states:
*/
@@ -82,62 +78,6 @@ enum input_state_t
Streaming
};
-
-/* The delay after which the glitch counter is reset */
-#define INPUT_COUNTER_RESET_TIME 30 // minutes
-
-/* How many glitches we tolerate in Streaming state before
- * we consider the input Unstable */
-#define INPUT_UNSTABLE_THRESHOLD 3
-
-/* For how long the input buffers must be empty before we move an input to the
- * NoData state. */
-#define INPUT_NODATA_TIMEOUT 30 // seconds
-
-/* For silence detection, we count the number of occurrences the audio level
- * falls below a threshold.
- *
- * The counter is decreased for each frame that has good audio level.
- *
- * The counter saturates, and this value defines for how long the
- * input will be considered silent after a cut.
- *
- * If the count reaches a certain value, the input changes state
- * to Silence. */
-#define INPUT_AUDIO_LEVEL_THRESHOLD -50 // dB
-#define INPUT_AUDIO_LEVEL_SILENCE_COUNT 100 // superframes (120ms)
-#define INPUT_AUDIO_LEVEL_COUNT_SATURATION 500 // superframes (120ms)
-
-/* An example of how the state changes work.
- * The timeout is set to expire in 30 minutes
- * at each under-/overrun.
- *
- * The glitch counter is increased by one for each glitch (can be a
- * saturating counter), and set to zero when the counter timeout expires.
- *
- * The state is then simply depending on the glitch counter value.
- *
- * Graphical example:
-
- state STREAMING | UNSTABLE | STREAMING
- xruns U U U
- glitch
- counter 0 1 2 3 0
- reset
- timeout \ |\ |\ |\
- \ | \ | \ | \
- \ | \ | \ | \
- \| \ | \| \
- ` \| ` \
- ` \
- \
- \
- \
- \
- timeout expires ___________________\
- <--30min-->
- */
-
/* InputStat takes care of
* - saving the statistics for graphing
* - calculating the state of the input for monitoring
@@ -168,24 +108,24 @@ class InputStat
/************ STATISTICS ***********/
// Calculate minimum and maximum buffer fill from
// a FIFO of values from the last few seconds
- std::deque<long> buffer_fill_stats;
- std::chrono::time_point<std::chrono::steady_clock> time_last_buffer_notify;
+ std::deque<long> m_buffer_fill_stats;
+ std::chrono::time_point<std::chrono::steady_clock> m_time_last_buffer_notify;
// counter of number of overruns and underruns since startup
- uint32_t num_underruns;
- uint32_t num_overruns;
+ uint32_t m_num_underruns;
+ uint32_t m_num_overruns;
// Peak audio levels (linear 16-bit PCM) for the two channels.
// Keep a FIFO of values from the last few seconds
- std::deque<int> peaks_left;
- std::deque<int> peaks_right;
- std::chrono::time_point<std::chrono::steady_clock> time_last_peak_notify;
+ 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;
/************* STATE ***************/
/* Variables used for determining the input state */
int m_glitch_counter; // saturating counter
int m_silence_counter; // saturating counter
- time_t m_time_last_event;
+ std::chrono::time_point<std::chrono::steady_clock> m_time_last_event;
// The mutex that has to be held during all notify and readout
mutable boost::mutex m_mutex;