summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrzej Rybczak <andrzej@rybczak.net>2020-12-17 13:37:09 +0100
committerAndrzej Rybczak <andrzej@rybczak.net>2020-12-17 13:37:09 +0100
commitfbbb5637e7a133cdcda3205c9e5cbd7bc3f6c917 (patch)
treebb96b659ca138368380d4c1a6b85b46c07116ed1 /src
parent95c0678792580a8bb6564c50f13e09fed8284230 (diff)
Discard any lingering data from the source
Diffstat (limited to 'src')
-rw-r--r--src/screens/visualizer.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/screens/visualizer.cpp b/src/screens/visualizer.cpp
index 72c42f87..937b963e 100644
--- a/src/screens/visualizer.cpp
+++ b/src/screens/visualizer.cpp
@@ -678,6 +678,17 @@ void Visualizer::Clear()
{
w.clear();
std::fill(m_rendered_samples.begin(), m_rendered_samples.end(), 0);
+
+ // Discard any lingering data from the data source.
+ if (m_fifo >= 0)
+ {
+ ssize_t bytes_read;
+ do
+ bytes_read = read(m_fifo, m_incoming_samples.data(),
+ sizeof(int16_t) * m_incoming_samples.size());
+ while (bytes_read > 0);
+ }
+
}
void Visualizer::ToggleVisualizationType()