summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPasi Petäjäjärvi <pasi.petajajarvi@theqtcompany.com>2016-01-05 15:37:21 +0200
committerYoann Lopes <yoann.lopes@theqtcompany.com>2016-01-07 11:54:43 +0000
commit9f35d7763e50676eb8521eaaf4542eaf6851c769 (patch)
tree59bf37d0d08e05f212edff0e547fc327036b80d9 /src
parent604a5753fa2d9b8e1ef65ccd8c5fb72465462479 (diff)
Fix playing sound in loop if sample size is small
If sample size is smaller that current periodsize, then playing sample multiple times in loop will fail. Reason is data offset of sample is set out of the bounds actual sample data size. Change-Id: I81f580cbb8dabf89db0d61528f5f1c9489216e0c Task-number: QTBUG-49838 Reviewed-by: Yoann Lopes <yoann.lopes@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/multimedia/audio/qsoundeffect_qaudio_p.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/multimedia/audio/qsoundeffect_qaudio_p.cpp b/src/multimedia/audio/qsoundeffect_qaudio_p.cpp
index e95e4e521..77ed48b4a 100644
--- a/src/multimedia/audio/qsoundeffect_qaudio_p.cpp
+++ b/src/multimedia/audio/qsoundeffect_qaudio_p.cpp
@@ -395,6 +395,8 @@ qint64 PrivateSoundSource::readData( char* data, qint64 len)
memcpy(data + dataOffset, sampleData + m_offset, sampleSize - m_offset);
bytesWritten += sampleSize - m_offset;
int wrapLen = periodSize - (sampleSize - m_offset);
+ if (wrapLen > sampleSize)
+ wrapLen = sampleSize;
#ifdef QT_QAUDIO_DEBUG
qDebug() << "END OF SOUND: bytesWritten=" << bytesWritten << ", offset=" << m_offset
<< ", part1=" << (sampleSize-m_offset);