diff options
-rw-r--r-- | src/decoders/qalmpg123audiodecoder.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/decoders/qalmpg123audiodecoder.cpp b/src/decoders/qalmpg123audiodecoder.cpp index e871e7a..21e21b2 100644 --- a/src/decoders/qalmpg123audiodecoder.cpp +++ b/src/decoders/qalmpg123audiodecoder.cpp @@ -23,7 +23,7 @@ #include <QtCore/QString> #include <QtCore/QUrl> #include <QtCore/QDebug> -#include <QtCore/QMutexLocker> +#include <QtCore/QMutex> #include <mpg123.h> @@ -33,12 +33,14 @@ class QALMpg123AudioDecoder::Private Private() : mpg123Handle(0) { - QMutexLocker mutexLocker; + mutex.lock(); if (++referenceCounter == 1) { int error; if ((error = mpg123_init()) == MPG123_OK) { + mutex.unlock(); isValid = true; } else { + mutex.unlock(); qWarning() << Q_FUNC_INFO << "Failed to initialize the mpg123 library:" << error; } } @@ -46,10 +48,11 @@ class QALMpg123AudioDecoder::Private ~Private() { - QMutexLocker mutexLocker; + mutex.lock(); if (--referenceCounter == 0) { mpg123_exit(); } + mutex.unlock(); } static sf_count_t fileLengthCallback(void *user_data); @@ -60,6 +63,8 @@ class QALMpg123AudioDecoder::Private static int referenceCounter; static bool isValid; + QMutex mutex; + QFile file; QByteArray encodedData; |