File PHONON_GSTREAMER_46_BRANCH.diff of Package phonon-backend-gstreamer-0_10
diff --git a/gstreamer/gstreamer.desktop.cmake b/gstreamer/gstreamer.desktop.cmake
index b12f533..8192852 100644
--- a/gstreamer/gstreamer.desktop.cmake
+++ b/gstreamer/gstreamer.desktop.cmake
@@ -77,7 +77,7 @@ Comment[en_GB]=Phonon GStreamer backend
Comment[es]=Motor GStreamer para Phonon
Comment[et]=Phononi GStreameri taustaprogramm
Comment[eu]=Phonon GStreamer backend
-Comment[fi]=Phonon GStreamer-taustaohjelma
+Comment[fi]=Phonon GStreamer -taustaohjelma
Comment[fr]=Moteur GStreamer pour Phonon
Comment[ga]=Inneall GStreamer le haghaidh Phonon
Comment[gl]=Infraestrutura de GStreamer para Phonon
diff --git a/gstreamer/mediaobject.cpp b/gstreamer/mediaobject.cpp
index dab18ba..d1d4900 100644
--- a/gstreamer/mediaobject.cpp
+++ b/gstreamer/mediaobject.cpp
@@ -77,8 +77,9 @@ MediaObject::MediaObject(Backend *backend, QObject *parent)
, m_waitingForNextSource(false)
, m_waitingForPreviousSource(false)
, m_skippingEOS(false)
- , m_skipGapless(false)
, m_doingEOS(false)
+ , m_skipGapless(false)
+ , m_handlingAboutToFinish(false)
{
qRegisterMetaType<GstCaps*>("GstCaps*");
qRegisterMetaType<State>("State");
@@ -338,23 +339,27 @@ void MediaObject::autoDetectSubtitle()
void MediaObject::setNextSource(const MediaSource &source)
{
DEBUG_BLOCK;
- debug() << "Got next source. Waiting for end of current.";
m_aboutToFinishLock.lock();
-
- // If next source is valid and is not empty (an empty source is sent by Phonon if
- // there are no more sources) skip EOS for the current source in order to seamlessly
- // pass to the next source.
- if (source.type() == Phonon::MediaSource::Invalid ||
- source.type() == Phonon::MediaSource::Empty)
- m_skippingEOS = false;
- else
- m_skippingEOS = true;
-
- m_waitingForNextSource = true;
- m_waitingForPreviousSource = false;
- m_pipeline->setSource(source);
- m_aboutToFinishWait.wakeAll();
+ if (m_handlingAboutToFinish) {
+ debug() << "Got next source. Waiting for end of current.";
+
+ // If next source is valid and is not empty (an empty source is sent by Phonon if
+ // there are no more sources) skip EOS for the current source in order to seamlessly
+ // pass to the next source.
+ if (source.type() == Phonon::MediaSource::Invalid ||
+ source.type() == Phonon::MediaSource::Empty)
+ m_skippingEOS = false;
+ else
+ m_skippingEOS = true;
+
+ m_waitingForNextSource = true;
+ m_waitingForPreviousSource = false;
+ m_skipGapless = false;
+ m_pipeline->setSource(source);
+ m_aboutToFinishWait.wakeAll();
+ } else
+ qDebug() << "Ignoring source as no aboutToFinish handling is in progress.";
m_aboutToFinishLock.unlock();
}
@@ -387,6 +392,7 @@ void MediaObject::setSource(const MediaSource &source)
m_source = source;
autoDetectSubtitle();
m_pipeline->setSource(source);
+ m_skipGapless = false;
m_aboutToFinishWait.wakeAll();
//emit currentSourceChanged(source);
}
@@ -816,10 +822,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:
@@ -846,6 +859,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
@@ -853,13 +867,19 @@ void MediaObject::handleAboutToFinish()
if (!m_skipGapless) {
if (m_aboutToFinishWait.wait(&m_aboutToFinishLock, 3000)) {
debug() << "Finally got a source";
+ if (m_skipGapless) { // Was explicitly set by stateChange interrupt
+ debug() << "...oh, no, just got aborted, skipping EOS";
+ m_skippingEOS = false;
+ }
} else {
+ warning() << "aboutToFinishWait timed out!";
m_skippingEOS = false;
}
} 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