diff options
author | Lars Knoll <lars.knoll@qt.io> | 2021-05-20 10:42:53 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2021-05-20 09:08:27 +0000 |
commit | f3526fd7af8b9ca7e2929c21e5bd364fad0eaa3e (patch) | |
tree | ae2a9de39280ef38aa140d828794a11bd8f2c4a9 /src | |
parent | 1b630c9b4961956ca121b8dd50ea6b33ab6c43c3 (diff) |
QSampleCache: Don't start the loader thread unless we need to
Starting the loader thread was causing some instability in the
auto test for QSampleCache and leads to doing unnecessary work
if the sample is already loaded.
Change-Id: I31fef1b0e7348f0397999be113f8516e8985ade3
Reviewed-by: Doris Verria <doris.verria@qt.io>
Reviewed-by: André de la Rocha <andre.rocha@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/multimedia/audio/qsamplecache_p.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/multimedia/audio/qsamplecache_p.cpp b/src/multimedia/audio/qsamplecache_p.cpp index 3c5df717d..6c4163080 100644 --- a/src/multimedia/audio/qsamplecache_p.cpp +++ b/src/multimedia/audio/qsamplecache_p.cpp @@ -169,14 +169,13 @@ QSample* QSampleCache::requestSample(const QUrl& url) m_loadingRefCount++; m_loadingMutex.unlock(); - if (!m_loadingThread.isRunning()) - m_loadingThread.start(); - qCDebug(qLcSampleCache) << "QSampleCache: request sample [" << url << "]"; std::unique_lock<QRecursiveMutex> locker(m_mutex); QMap<QUrl, QSample*>::iterator it = m_samples.find(url); QSample* sample; if (it == m_samples.end()) { + if (!m_loadingThread.isRunning()) + m_loadingThread.start(); sample = new QSample(url, this); m_samples.insert(url, sample); sample->moveToThread(&m_loadingThread); |