aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2017-04-30 10:41:59 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2017-04-30 10:41:59 +0000
commit4a4d8f5ac86cd0e7cea6417b29856438d9a7e640 (patch)
treef61e66dce2c16751839f38ac1ee856693174c863 /src
parent1ba41aa59308259a23f784717a9e774433ea86b6 (diff)
downloadqmmp-4a4d8f5ac86cd0e7cea6417b29856438d9a7e640.tar.gz
qmmp-4a4d8f5ac86cd0e7cea6417b29856438d9a7e640.tar.bz2
qmmp-4a4d8f5ac86cd0e7cea6417b29856438d9a7e640.zip
some visualization fixes
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@7139 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src')
-rw-r--r--src/qmmp/visualbuffer.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/qmmp/visualbuffer.cpp b/src/qmmp/visualbuffer.cpp
index 6d081d598..5841d9f47 100644
--- a/src/qmmp/visualbuffer.cpp
+++ b/src/qmmp/visualbuffer.cpp
@@ -53,11 +53,7 @@ VisualBuffer::VisualBuffer()
void VisualBuffer::add(float *pcm, int samples, int channels, qint64 ts, qint64 delay)
{
m_add_index++;
- if (m_add_index == VISUAL_BUFFER_SIZE)
- {
- m_add_index = 0;
- }
-
+ m_add_index %= VISUAL_BUFFER_SIZE;
VisualNode *b = &m_buffer[m_add_index];
stereo_from_multichannel(b->data[0], b->data[1], pcm, qMin(512, samples / channels), channels);
b->ts = ts;
@@ -74,14 +70,14 @@ VisualNode *VisualBuffer::take()
((m_buffer[m_take_index].ts < t) && (steps++ < VISUAL_BUFFER_SIZE)))
{
m_take_index++;
- if(m_take_index == VISUAL_BUFFER_SIZE)
- {
- m_take_index = 0;
- }
+ m_take_index %= VISUAL_BUFFER_SIZE;
}
if(m_buffer[m_take_index].ts < t) //unable to find node
return 0;
+ if(m_buffer[m_take_index].ts > t + 100) //node is more than 100 ms in the future. So, ignore it.
+ return 0;
+
return &m_buffer[m_take_index];
}