summaryrefslogtreecommitdiffstats
path: root/src/3rdparty
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-08-11 13:16:51 +0200
committerThierry Bastian <thierry.bastian@nokia.com>2009-08-11 15:27:44 +0200
commit1ba7eaafff489d70455404ac394e80a11f5ed5fa (patch)
tree4f4b1ef0199571b2e0d28d6b7e30793c9f6a50ca /src/3rdparty
parent8a5e1fbd4f42a0f5cc23ac797d06424c1b362536 (diff)
Phonon: improve locking to make it safer to load a source
Task-number: 259482
Diffstat (limited to 'src/3rdparty')
-rw-r--r--src/3rdparty/phonon/ds9/mediaobject.cpp39
-rw-r--r--src/3rdparty/phonon/ds9/mediaobject.h3
2 files changed, 25 insertions, 17 deletions
diff --git a/src/3rdparty/phonon/ds9/mediaobject.cpp b/src/3rdparty/phonon/ds9/mediaobject.cpp
index 23e392c0a7..f7fd6aec0e 100644
--- a/src/3rdparty/phonon/ds9/mediaobject.cpp
+++ b/src/3rdparty/phonon/ds9/mediaobject.cpp
@@ -192,8 +192,11 @@ namespace Phonon
HRESULT hr = S_OK;
- m_currentRender = w.graph;
- m_currentRenderId = w.id;
+ {
+ QMutexLocker locker(&m_currentMutex);
+ m_currentRender = w.graph;
+ m_currentRenderId = w.id;
+ }
if (w.task == ReplaceGraph) {
HANDLE h;
@@ -218,9 +221,6 @@ namespace Phonon
m_graphHandle[index].handle = h;
}
} else if (w.task == Render) {
- //we need to unlock here because the use might trigger a call to abort
- //which uses the same mutex
- locker.unlock();
if (w.filter) {
//let's render pins
w.graph->AddFilter(w.filter, 0);
@@ -239,7 +239,6 @@ namespace Phonon
if (hr != E_ABORT) {
emit asyncRenderFinished(w.id, hr, w.graph);
}
- locker.relock();
} else if (w.task == Seek) {
//that's a seekrequest
ComPointer<IMediaSeeking> mediaSeeking(w.graph, IID_IMediaSeeking);
@@ -312,13 +311,22 @@ namespace Phonon
}
}
- m_currentRender = Graph();
- m_currentRenderId = 0;
-
+ {
+ QMutexLocker locker(&m_currentMutex);
+ m_currentRender = Graph();
+ m_currentRenderId = 0;
+ }
}
- void WorkerThread::abortCurrentRender(qint16 renderId)
- {
+ void WorkerThread::abortCurrentRender(qint16 renderId)
+ {
+ {
+ QMutexLocker locker(&m_currentMutex);
+ if (m_currentRender && m_currentRenderId == renderId) {
+ m_currentRender->Abort();
+ }
+ }
+
QMutexLocker locker(&m_mutex);
bool found = false;
//we try to see if there is already an attempt to seek and we remove it
@@ -327,13 +335,12 @@ namespace Phonon
if (w.id == renderId) {
found = true;
m_queue.removeAt(i);
+ if (m_queue.isEmpty()) {
+ m_waitCondition.reset();
+ }
}
}
-
- if (m_currentRender && m_currentRenderId == renderId) {
- m_currentRender->Abort();
- }
- }
+ }
//tells the thread to stop processing
void WorkerThread::signalStop()
diff --git a/src/3rdparty/phonon/ds9/mediaobject.h b/src/3rdparty/phonon/ds9/mediaobject.h
index fe52604aeb..a6beb5f593 100644
--- a/src/3rdparty/phonon/ds9/mediaobject.h
+++ b/src/3rdparty/phonon/ds9/mediaobject.h
@@ -143,7 +143,8 @@ namespace Phonon
bool m_finished;
quint16 m_currentWorkId;
QWinWaitCondition m_waitCondition;
- QMutex m_mutex;
+ QMutex m_mutex; // mutex for the m_queue, m_finished and m_currentWorkId
+ QMutex m_currentMutex; //mutex for current renderer and id
//this is for WaitForMultipleObjects
struct