Commit 8db5599d authored by Matěj Laitl's avatar Matěj Laitl
Browse files

EngineController: thread safety for supportedMimeTypes()

This hopefully fixes mentioned bug.

BUGFIXES:
 * Fix crash on startup due to EngineController.

BUG: 300659
FIXED-IN: 2.6
DIGEST: Bugfix
parent 6eaab47c
......@@ -94,6 +94,7 @@ VERSION 2.6-Beta 1
"1.2 GB free" is shown instead of "85% used"; thicker capacity bar.
BUGFIXES:
* Fix crash on startup due to EngineController. (BR 300659)
* Fix problem building tests with google mock 1.6.0 on Ubuntu
* Fix dynamic playlist album play bias with MetaProxy::Tracks.
* Transcoding: fix compatibility with libav's ffmpeg. (BR 300551)
......
......@@ -58,6 +58,8 @@ namespace The {
EngineController* engineController() { return EngineController::instance(); }
}
QMutex EngineController::s_supportedMimeTypesMutex;
EngineController*
EngineController::instance()
{
......@@ -263,13 +265,19 @@ EngineController::supportedMimeTypes() //static
//NOTE this function must be thread-safe
// Filter the available mime types to only include audio and video, as amarok does not intend to play photos
static QRegExp avFilter( "^(audio|video)/", Qt::CaseInsensitive );
// NB: we can't make this static, as we edit it later in the method; however, this method
// should not be called too often.
QStringList mimeTable = Phonon::BackendCapabilities::availableMimeTypes().filter( avFilter );
static QStringList mimeTable;
// theoretically not needed, but static initialization of mimeTable may have threading
// issues, so rather use boolean flag for it:
static bool mimeTableAlreadyFilled = false;
// Add whitelist hacks
QMutexLocker locker( &s_supportedMimeTypesMutex );
if( mimeTableAlreadyFilled )
return mimeTable;
QRegExp avFilter( "^(audio|video)/", Qt::CaseInsensitive );
mimeTable = Phonon::BackendCapabilities::availableMimeTypes().filter( avFilter );
// Add whitelist hacks
// MP4 Audio Books have a different extension that KFileItem/Phonon don't grok
if( !mimeTable.contains( "audio/x-m4b" ) )
mimeTable << "audio/x-m4b";
......@@ -293,6 +301,7 @@ EngineController::supportedMimeTypes() //static
mimeTable << "audio/mp3" << "audio/x-mp3";
}
mimeTableAlreadyFilled = true;
return mimeTable;
}
......
......@@ -538,6 +538,8 @@ private:
Q_DISABLE_COPY( EngineController )
static QMutex s_supportedMimeTypesMutex; // guards access to supportedMimeTypes()::mimeTable
QWeakPointer<Phonon::MediaObject> m_media;
QWeakPointer<Phonon::VolumeFaderEffect> m_preamp;
QWeakPointer<Phonon::Effect> m_equalizer;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment