summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPekka Gehör <pekka.gehor@qt.io>2022-04-27 15:57:49 +0300
committerPekka Gehör <pekka.gehor@qt.io>2022-04-28 12:37:13 +0300
commit2acad746d7f6ce5f22dbdf3d0c53e7d85d52317e (patch)
tree69ecadd484100ad637dded164dfe55cae99b7673
parent41af1f5d8f8154dec1458eccf93aa5660b6be49e (diff)
Android: Fix destroying QThread while it is still running issue
Destroying Decoder thread in destructor of the QAndroidAudioDecoder while it is still running, will cause a fatal error. Task-number: QTBUG-100079 Change-Id: I43cdc3f9a8f718f3fce64a8aca7f1c2208fd7c48 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> (cherry picked from commit f686479d6decf22dc5f93ce5596186dca148cc33)
-rw-r--r--src/multimedia/platform/android/audio/qandroidaudiodecoder.cpp12
-rw-r--r--src/multimedia/platform/android/audio/qandroidaudiodecoder_p.h2
2 files changed, 9 insertions, 5 deletions
diff --git a/src/multimedia/platform/android/audio/qandroidaudiodecoder.cpp b/src/multimedia/platform/android/audio/qandroidaudiodecoder.cpp
index 15450f0af..1d7c03346 100644
--- a/src/multimedia/platform/android/audio/qandroidaudiodecoder.cpp
+++ b/src/multimedia/platform/android/audio/qandroidaudiodecoder.cpp
@@ -277,7 +277,8 @@ QAndroidAudioDecoder::QAndroidAudioDecoder(QAudioDecoder *parent)
QAndroidAudioDecoder::~QAndroidAudioDecoder()
{
- m_decoder->thread()->exit();
+ m_decoder->thread()->quit();
+ m_decoder->thread()->wait();
m_decoder->deleteLater();
}
@@ -323,9 +324,12 @@ void QAndroidAudioDecoder::start()
setIsDecoding(true);
m_position = -1;
- m_threadDecoder = new QThread(this);
- m_decoder->moveToThread(m_threadDecoder);
- m_threadDecoder->start();
+ if (!m_threadDecoder) {
+ m_threadDecoder = new QThread(this);
+ m_decoder->moveToThread(m_threadDecoder);
+ m_threadDecoder->start();
+ }
+
decode();
}
diff --git a/src/multimedia/platform/android/audio/qandroidaudiodecoder_p.h b/src/multimedia/platform/android/audio/qandroidaudiodecoder_p.h
index efb7cdc24..07a3aff3a 100644
--- a/src/multimedia/platform/android/audio/qandroidaudiodecoder_p.h
+++ b/src/multimedia/platform/android/audio/qandroidaudiodecoder_p.h
@@ -145,7 +145,7 @@ private:
QByteArray m_deviceBuffer;
- QThread *m_threadDecoder;
+ QThread *m_threadDecoder = nullptr;
};
QT_END_NAMESPACE