From 9f35d7763e50676eb8521eaaf4542eaf6851c769 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pasi=20Pet=C3=A4j=C3=A4j=C3=A4rvi?= Date: Tue, 5 Jan 2016 15:37:21 +0200 Subject: [PATCH 1/2] 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 --- src/multimedia/audio/qsoundeffect_qaudio_p.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/multimedia/audio/qsoundeffect_qaudio_p.cpp b/src/multimedia/audio/qsoundeffect_qaudio_p.cpp index e95e4e52..77ed48b4 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); From c953ef391086f4b689f6adc6d29cb8021db64845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Fri, 8 Jan 2016 17:46:20 +0100 Subject: [PATCH 2/2] Android: Don't call restartViewfinder() for audio only recordings. Calling restartViewfinder() would try to access m_cameraSession without checking if it was valid. This change adds guards around the calls to restartViewfinder(), and one in the function itself. Task-number: QTBUG-50282 Change-Id: I1f2b4d2b2342bf2dc2b7f28a7bcd00e08a0edb44 Reviewed-by: jian liang Reviewed-by: Yoann Lopes --- .../android/src/mediacapture/qandroidcapturesession.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/plugins/android/src/mediacapture/qandroidcapturesession.cpp b/src/plugins/android/src/mediacapture/qandroidcapturesession.cpp index f2ea1b9d..cf62e610 100644 --- a/src/plugins/android/src/mediacapture/qandroidcapturesession.cpp +++ b/src/plugins/android/src/mediacapture/qandroidcapturesession.cpp @@ -219,13 +219,15 @@ void QAndroidCaptureSession::start() if (!m_mediaRecorder->prepare()) { emit error(QMediaRecorder::FormatError, QLatin1String("Unable to prepare the media recorder.")); - restartViewfinder(); + if (m_cameraSession) + restartViewfinder(); return; } if (!m_mediaRecorder->start()) { emit error(QMediaRecorder::FormatError, QLatin1String("Unable to start the media recorder.")); - restartViewfinder(); + if (m_cameraSession) + restartViewfinder(); return; } @@ -418,6 +420,9 @@ void QAndroidCaptureSession::updateViewfinder() void QAndroidCaptureSession::restartViewfinder() { + if (!m_cameraSession) + return; + m_cameraSession->camera()->reconnect(); m_cameraSession->camera()->startPreview(); m_cameraSession->setReadyForCapture(true);