summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2010-09-22 02:28:24 (GMT)
committerSamuli Piippo <samuli.piippo@digia.com>2011-06-09 10:07:04 (GMT)
commita87b556e72588212b1373f41270e2f935b5f44c5 (patch)
tree717de7a42a162eb7d4e1a0dd949a5a2bff3ecfc5 /examples
parent3650691c505607d5af7b2c7e7e2ab9db1739c836 (diff)
downloadQt-a87b556e72588212b1373f41270e2f935b5f44c5.zip
Qt-a87b556e72588212b1373f41270e2f935b5f44c5.tar.gz
Qt-a87b556e72588212b1373f41270e2f935b5f44c5.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 (cherry picked from commit a006881b2297e4dbf03051f82a8abb1363ceeebb)
Diffstat (limited to 'examples')
-rw-r--r--examples/multimedia/audiooutput/audiooutput.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/examples/multimedia/audiooutput/audiooutput.cpp b/examples/multimedia/audiooutput/audiooutput.cpp
index 2245748..6b64940 100644
--- a/examples/multimedia/audiooutput/audiooutput.cpp
+++ b/examples/multimedia/audiooutput/audiooutput.cpp
@@ -133,9 +133,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;
}