diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2010-09-22 02:28:24 (GMT) |
---|---|---|
committer | Andrew den Exter <andrew.den-exter@nokia.com> | 2010-09-22 02:28:24 (GMT) |
commit | a006881b2297e4dbf03051f82a8abb1363ceeebb (patch) | |
tree | 5efa5d6fa0a38bf299eded6d96aa63d474594c7d /examples/multimedia | |
parent | 660ec910ef60513b511e2292255e53701dbb239b (diff) | |
download | Qt-a006881b2297e4dbf03051f82a8abb1363ceeebb.zip Qt-a006881b2297e4dbf03051f82a8abb1363ceeebb.tar.gz Qt-a006881b2297e4dbf03051f82a8abb1363ceeebb.tar.bz2 |
Fix audio glitches in the audiooutput example.
The data copy loop didn't advance the write position, resulting in some
of the output buffer being overwritten and some of it not written to at
all.
Task-number: QTBUG-13751
Reviewed-by: Justin McPherson
Diffstat (limited to 'examples/multimedia')
-rw-r--r-- | examples/multimedia/audiooutput/audiooutput.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/examples/multimedia/audiooutput/audiooutput.cpp b/examples/multimedia/audiooutput/audiooutput.cpp index bc2324e..451cc67 100644 --- a/examples/multimedia/audiooutput/audiooutput.cpp +++ b/examples/multimedia/audiooutput/audiooutput.cpp @@ -132,9 +132,9 @@ void Generator::generateData(const QAudioFormat &format, qint64 durationUs, int qint64 Generator::readData(char *data, qint64 len) { qint64 total = 0; - while (len - total) { + while (len - total > 0) { const qint64 chunk = qMin((m_buffer.size() - m_pos), len - total); - memcpy(data, m_buffer.constData() + m_pos, chunk); + memcpy(data + total, m_buffer.constData() + m_pos, chunk); m_pos = (m_pos + chunk) % m_buffer.size(); total += chunk; } |