summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMika Salmela <mika.salmela@qt.io>2017-06-08 16:33:29 +0300
committerMika Salmela <mika.salmela@qt.io>2017-06-12 18:31:11 +0000
commit19a5884e8d6bfa9d3bdfce359ce39deef4c48110 (patch)
treef3078301f0fc7d1970f692914c49db0fad12e7d8 /src
parenta6cc1af0546ab10701c10475315139ebb50ad1e5 (diff)
OpenSL ES: Fix crash caused by overcommitting device with data
Sometimes m_format.bytesForDuration(delta) is larger than the QByteArray containing the data. Therefore select the minimum of these. Task-number: QTBUG-61085 Change-Id: I20a8ffb77095aecd2711f53d4c9fc7da7f9ae8e2 Reviewed-by: Christian Stromme <christian.stromme@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/opensles/qopenslesaudioinput.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/plugins/opensles/qopenslesaudioinput.cpp b/src/plugins/opensles/qopenslesaudioinput.cpp
index c3f5ed42..ad87cb05 100644
--- a/src/plugins/opensles/qopenslesaudioinput.cpp
+++ b/src/plugins/opensles/qopenslesaudioinput.cpp
@@ -475,8 +475,11 @@ void QOpenSLESAudioInput::flushBuffers()
qint64 delta = recorderPos * 1000 - devicePos;
- if (delta > 0)
- writeDataToDevice(m_buffers[m_currentBuffer].constData(), m_format.bytesForDuration(delta));
+ if (delta > 0) {
+ const int writeSize = std::min(m_buffers[m_currentBuffer].size(),
+ m_format.bytesForDuration(delta));
+ writeDataToDevice(m_buffers[m_currentBuffer].constData(), writeSize);
+ }
}
int QOpenSLESAudioInput::bytesReady() const