Add silence threshold for alsa stream

This commit is contained in:
badaix 2021-05-05 21:59:36 +02:00
parent 5d7aedeb31
commit 216714bd33
5 changed files with 61 additions and 4 deletions

View file

@ -47,6 +47,9 @@ protected:
void initAlsa();
void uninitAlsa();
/// check if the chunk's volume is below the silence threshold
bool isSilent(const msg::PcmChunk& chunk) const;
snd_pcm_t* handle_;
std::unique_ptr<msg::PcmChunk> chunk_;
bool first_;
@ -61,6 +64,7 @@ protected:
bool send_silence_;
/// silence duration before switching the stream to idle
std::chrono::milliseconds idle_threshold_;
int32_t silence_threshold_ = 0;
};
} // namespace streamreader