summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/phonon/ds9/mediaobject.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/phonon/ds9/mediaobject.cpp')
-rw-r--r--src/3rdparty/phonon/ds9/mediaobject.cpp55
1 files changed, 18 insertions, 37 deletions
diff --git a/src/3rdparty/phonon/ds9/mediaobject.cpp b/src/3rdparty/phonon/ds9/mediaobject.cpp
index 10782c251..b163ad4dd 100644
--- a/src/3rdparty/phonon/ds9/mediaobject.cpp
+++ b/src/3rdparty/phonon/ds9/mediaobject.cpp
@@ -57,24 +57,6 @@ namespace Phonon
{
}
- WorkerThread::Work WorkerThread::dequeueWork()
- {
- QMutexLocker locker(&m_mutex);
- if (m_finished) {
- return Work();
- }
- Work ret = m_queue.dequeue();
-
- //we ensure to have the wait condition in the right state
- if (m_queue.isEmpty()) {
- m_waitCondition.reset();
- } else {
- m_waitCondition.set();
- }
-
- return ret;
- }
-
void WorkerThread::run()
{
while (m_finished == false) {
@@ -88,11 +70,6 @@ namespace Phonon
}
DWORD result = ::WaitForMultipleObjects(count, handles, FALSE, INFINITE);
if (result == WAIT_OBJECT_0) {
- if (m_finished) {
- //that's the end of the thread execution
- return;
- }
-
handleTask();
} else {
//this is the event management
@@ -199,22 +176,25 @@ namespace Phonon
void WorkerThread::handleTask()
{
- const Work w = dequeueWork();
-
- if (m_finished) {
+ QMutexLocker locker(&m_mutex);
+ if (m_finished || m_queue.isEmpty()) {
return;
}
- HRESULT hr = S_OK;
+ const Work w = m_queue.dequeue();
- {
- QMutexLocker locker(&m_mutex);
- m_currentRender = w.graph;
- m_currentRenderId = w.id;
+ //we ensure to have the wait condition in the right state
+ if (m_queue.isEmpty()) {
+ m_waitCondition.reset();
+ } else {
+ m_waitCondition.set();
}
+ HRESULT hr = S_OK;
+
+ m_currentRender = w.graph;
+ m_currentRenderId = w.id;
if (w.task == ReplaceGraph) {
- QMutexLocker locker(&m_mutex);
int index = -1;
for(int i = 0; i < FILTER_COUNT; ++i) {
if (m_graphHandle[i].graph == w.oldGraph) {
@@ -237,6 +217,9 @@ 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);
@@ -255,6 +238,7 @@ 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);
@@ -327,11 +311,8 @@ namespace Phonon
}
}
- {
- QMutexLocker locker(&m_mutex);
- m_currentRender = Graph();
- m_currentRenderId = 0;
- }
+ m_currentRender = Graph();
+ m_currentRenderId = 0;
}
void WorkerThread::abortCurrentRender(qint16 renderId)