Blob Blame Raw
From 12cdb007c036fe6c03f592b7cc5f976440cd99b9 Mon Sep 17 00:00:00 2001
From: Harald Sitter <sitter@kde.org>
Date: Thu, 26 Jul 2012 15:11:18 +0200
Subject: [PATCH 2/4] only set skipgapless and wake the condition iff
 abouttofinish is active

---
 gstreamer/mediaobject.cpp | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/gstreamer/mediaobject.cpp b/gstreamer/mediaobject.cpp
index ded4bcd..957f7fd 100644
--- a/gstreamer/mediaobject.cpp
+++ b/gstreamer/mediaobject.cpp
@@ -817,10 +817,17 @@ void MediaObject::setMetaData(QMultiMap<QString, QString> newData)
 void MediaObject::requestState(Phonon::State state)
 {
     DEBUG_BLOCK;
-    m_aboutToFinishLock.tryLock();
-    m_skipGapless = true;
-    m_aboutToFinishWait.wakeAll();
-    m_aboutToFinishLock.unlock();
+    // Only abort handling here iff the handler is active.
+    if (m_aboutToFinishLock.tryLock()) {
+        // Note that this is not condition to unlocking, so the nesting is
+        // necessary.
+        if (m_handlingAboutToFinish) {
+            qDebug() << "Aborting aboutToFinish handling.";
+            m_skipGapless = true;
+            m_aboutToFinishWait.wakeAll();
+        }
+        m_aboutToFinishLock.unlock();
+    }
     debug() << state;
     switch (state) {
         case Phonon::PlayingState:
-- 
1.7.11.2