aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2018-02-24 17:40:16 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2018-02-24 17:40:16 +0100
commit0ad10f6aeebf75ef550cfa2ce772d28b2b9fd7e0 (patch)
tree92ec7b189debd4ee5559bb9a1500c8ce6b8a9cfe /src
parentc27252b79363b46658fccbe743dc911049dd3450 (diff)
downloaddabmux-0ad10f6aeebf75ef550cfa2ce772d28b2b9fd7e0.tar.gz
dabmux-0ad10f6aeebf75ef550cfa2ce772d28b2b9fd7e0.tar.bz2
dabmux-0ad10f6aeebf75ef550cfa2ce772d28b2b9fd7e0.zip
Use enum class for input_state_t
Diffstat (limited to 'src')
-rw-r--r--src/ManagementServer.cpp18
-rw-r--r--src/ManagementServer.h2
2 files changed, 9 insertions, 11 deletions
diff --git a/src/ManagementServer.cpp b/src/ManagementServer.cpp
index 917d3c7..cd70b77 100644
--- a/src/ManagementServer.cpp
+++ b/src/ManagementServer.cpp
@@ -514,20 +514,18 @@ std::string InputStat::encodeValuesJSON()
ss << "\"state\": ";
switch (determineState()) {
- case NoData:
+ case input_state_t::NoData:
ss << "\"NoData (1)\"";
break;
- case Unstable:
+ case input_state_t::Unstable:
ss << "\"Unstable (2)\"";
break;
- case Silence:
+ case input_state_t::Silence:
ss << "\"Silent (3)\"";
break;
- case Streaming:
+ case input_state_t::Streaming:
ss << "\"Streaming (4)\"";
break;
- default:
- ss << "\"Unknown (0)\"";
}
ss << " } }";
@@ -558,20 +556,20 @@ input_state_t InputStat::determineState()
if (std::all_of(
m_buffer_fill_stats.begin(), m_buffer_fill_stats.end(),
[](long fill) { return fill == 0; }) ) {
- state = NoData;
+ state = input_state_t::NoData;
}
/* Otherwise, the state depends on the glitch counter */
else if (m_glitch_counter >= INPUT_UNSTABLE_THRESHOLD) {
- state = Unstable;
+ state = input_state_t::Unstable;
}
else {
/* The input is streaming, check if the audio level is too low */
if (m_silence_counter > INPUT_AUDIO_LEVEL_SILENCE_COUNT) {
- state = Silence;
+ state = input_state_t::Silence;
}
else {
- state = Streaming;
+ state = input_state_t::Streaming;
}
}
diff --git a/src/ManagementServer.h b/src/ManagementServer.h
index c0b50e7..274dece 100644
--- a/src/ManagementServer.h
+++ b/src/ManagementServer.h
@@ -65,7 +65,7 @@
/*** State handing ***/
/* An input can be in one of the following three states:
*/
-enum input_state_t
+enum class input_state_t
{
/* The input is waiting for data, all buffers are empty */
NoData,