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>
This commit is contained in:
Pasi Petäjäjärvi
2016-01-05 15:37:21 +02:00
committed by Yoann Lopes
parent 604a5753fa
commit 9f35d7763e

View File

@@ -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);