Blob Blame Raw
From a13ae0338ce6e5b1ddd40b04b18ef77287488a51 Mon Sep 17 00:00:00 2001
From: Harald Sitter <sitter@kde.org>
Date: Thu, 26 Jul 2012 15:10:47 +0200
Subject: [PATCH 1/4] introduce bool to track whether abouttofinish is running
 and reset skipping

---
 gstreamer/mediaobject.cpp | 4 ++++
 gstreamer/mediaobject.h   | 3 +++
 2 files changed, 7 insertions(+)

diff --git a/gstreamer/mediaobject.cpp b/gstreamer/mediaobject.cpp
index dab18ba..ded4bcd 100644
--- a/gstreamer/mediaobject.cpp
+++ b/gstreamer/mediaobject.cpp
@@ -79,6 +79,7 @@ MediaObject::MediaObject(Backend *backend, QObject *parent)
         , m_skippingEOS(false)
         , m_skipGapless(false)
         , m_doingEOS(false)
+        , m_handlingAboutToFinish(false)
 {
     qRegisterMetaType<GstCaps*>("GstCaps*");
     qRegisterMetaType<State>("State");
@@ -846,6 +847,7 @@ void MediaObject::handleAboutToFinish()
     DEBUG_BLOCK;
     debug() << "About to finish";
     m_aboutToFinishLock.lock();
+    m_handlingAboutToFinish = true;
     emit aboutToFinish();
     // Three seconds should be more than enough for any application to get their act together.
     // Any longer than that and they have bigger issues.  If Phonon does no supply a next source
@@ -858,8 +860,10 @@ void MediaObject::handleAboutToFinish()
       }
     } else {
       debug() << "Skipping gapless audio";
+      m_skippingEOS = false;
     }
     m_skipGapless = false;
+    m_handlingAboutToFinish = false;
     m_aboutToFinishLock.unlock();
 }
 
diff --git a/gstreamer/mediaobject.h b/gstreamer/mediaobject.h
index 62374a2..be62eda 100644
--- a/gstreamer/mediaobject.h
+++ b/gstreamer/mediaobject.h
@@ -283,6 +283,9 @@ private:
 
     qint64 m_lastTime;
     bool m_skipGapless;
+
+    /*** Tracks whereever the MO is actively handling an aboutToFinish CB right now. */
+    bool m_handlingAboutToFinish;
 };
 }
 } //namespace Phonon::Gstreamer
-- 
1.7.11.2