77
77
, m_waitingForNextSource(false)
78
78
, m_waitingForPreviousSource(false)
79
79
, m_skippingEOS(false)
80
81
, m_skipGapless(false)
82
, m_handlingAboutToFinish(false)
83
84
qRegisterMetaType<GstCaps*>("GstCaps*");
84
85
qRegisterMetaType<State>("State");
338
339
void MediaObject::setNextSource(const MediaSource &source)
341
debug() << "Got next source. Waiting for end of current.";
343
343
m_aboutToFinishLock.lock();
345
// If next source is valid and is not empty (an empty source is sent by Phonon if
346
// there are no more sources) skip EOS for the current source in order to seamlessly
347
// pass to the next source.
348
if (source.type() == Phonon::MediaSource::Invalid ||
349
source.type() == Phonon::MediaSource::Empty)
350
m_skippingEOS = false;
352
m_skippingEOS = true;
354
m_waitingForNextSource = true;
355
m_waitingForPreviousSource = false;
356
m_pipeline->setSource(source);
357
m_aboutToFinishWait.wakeAll();
344
if (m_handlingAboutToFinish) {
345
debug() << "Got next source. Waiting for end of current.";
347
// If next source is valid and is not empty (an empty source is sent by Phonon if
348
// there are no more sources) skip EOS for the current source in order to seamlessly
349
// pass to the next source.
350
if (source.type() == Phonon::MediaSource::Invalid ||
351
source.type() == Phonon::MediaSource::Empty)
352
m_skippingEOS = false;
354
m_skippingEOS = true;
356
m_waitingForNextSource = true;
357
m_waitingForPreviousSource = false;
358
m_skipGapless = false;
359
m_pipeline->setSource(source);
360
m_aboutToFinishWait.wakeAll();
362
qDebug() << "Ignoring source as no aboutToFinish handling is in progress.";
358
363
m_aboutToFinishLock.unlock();
816
822
void MediaObject::requestState(Phonon::State state)
819
m_aboutToFinishLock.tryLock();
820
m_skipGapless = true;
821
m_aboutToFinishWait.wakeAll();
822
m_aboutToFinishLock.unlock();
825
// Only abort handling here iff the handler is active.
826
if (m_aboutToFinishLock.tryLock()) {
827
// Note that this is not condition to unlocking, so the nesting is
829
if (m_handlingAboutToFinish) {
830
qDebug() << "Aborting aboutToFinish handling.";
831
m_skipGapless = true;
832
m_aboutToFinishWait.wakeAll();
834
m_aboutToFinishLock.unlock();
823
836
debug() << state;
825
838
case Phonon::PlayingState:
847
860
debug() << "About to finish";
848
861
m_aboutToFinishLock.lock();
862
m_handlingAboutToFinish = true;
849
863
emit aboutToFinish();
850
864
// Three seconds should be more than enough for any application to get their act together.
851
865
// Any longer than that and they have bigger issues. If Phonon does no supply a next source
853
867
if (!m_skipGapless) {
854
868
if (m_aboutToFinishWait.wait(&m_aboutToFinishLock, 3000)) {
855
869
debug() << "Finally got a source";
870
if (m_skipGapless) { // Was explicitly set by stateChange interrupt
871
debug() << "...oh, no, just got aborted, skipping EOS";
872
m_skippingEOS = false;
875
warning() << "aboutToFinishWait timed out!";
857
876
m_skippingEOS = false;
860
879
debug() << "Skipping gapless audio";
880
m_skippingEOS = false;
862
m_skipGapless = false;
882
m_handlingAboutToFinish = false;
863
883
m_aboutToFinishLock.unlock();