~ubuntu-branches/ubuntu/quantal/phonon-backend-gstreamer/quantal

« back to all changes in this revision

Viewing changes to gstreamer/mediaobject.cpp

  • Committer: Package Import Robot
  • Author(s): Harald Sitter
  • Date: 2012-08-14 10:41:07 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20120814104107-rggdzqqxuc9fh90d
Tags: 4:4.7.0really4.6.2-0ubuntu1
* New upstream release
* Update watch file from bz2 archives to xz archives

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
        , m_waitingForNextSource(false)
78
78
        , m_waitingForPreviousSource(false)
79
79
        , m_skippingEOS(false)
 
80
        , m_doingEOS(false)
80
81
        , m_skipGapless(false)
81
 
        , m_doingEOS(false)
 
82
        , m_handlingAboutToFinish(false)
82
83
{
83
84
    qRegisterMetaType<GstCaps*>("GstCaps*");
84
85
    qRegisterMetaType<State>("State");
338
339
void MediaObject::setNextSource(const MediaSource &source)
339
340
{
340
341
    DEBUG_BLOCK;
341
 
    debug() << "Got next source. Waiting for end of current.";
342
342
 
343
343
    m_aboutToFinishLock.lock();
344
 
 
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;
351
 
    else
352
 
        m_skippingEOS = true;
353
 
 
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.";
 
346
 
 
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;
 
353
        else
 
354
            m_skippingEOS = true;
 
355
 
 
356
        m_waitingForNextSource = true;
 
357
        m_waitingForPreviousSource = false;
 
358
        m_skipGapless = false;
 
359
        m_pipeline->setSource(source);
 
360
        m_aboutToFinishWait.wakeAll();
 
361
    } else
 
362
        qDebug() << "Ignoring source as no aboutToFinish handling is in progress.";
358
363
    m_aboutToFinishLock.unlock();
359
364
}
360
365
 
387
392
    m_source = source;
388
393
    autoDetectSubtitle();
389
394
    m_pipeline->setSource(source);
 
395
    m_skipGapless = false;
390
396
    m_aboutToFinishWait.wakeAll();
391
397
    //emit currentSourceChanged(source);
392
398
}
816
822
void MediaObject::requestState(Phonon::State state)
817
823
{
818
824
    DEBUG_BLOCK;
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
 
828
        // necessary.
 
829
        if (m_handlingAboutToFinish) {
 
830
            qDebug() << "Aborting aboutToFinish handling.";
 
831
            m_skipGapless = true;
 
832
            m_aboutToFinishWait.wakeAll();
 
833
        }
 
834
        m_aboutToFinishLock.unlock();
 
835
    }
823
836
    debug() << state;
824
837
    switch (state) {
825
838
        case Phonon::PlayingState:
846
859
    DEBUG_BLOCK;
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;
 
873
          }
856
874
      } else {
 
875
          warning() << "aboutToFinishWait timed out!";
857
876
          m_skippingEOS = false;
858
877
      }
859
878
    } else {
860
879
      debug() << "Skipping gapless audio";
 
880
      m_skippingEOS = false;
861
881
    }
862
 
    m_skipGapless = false;
 
882
    m_handlingAboutToFinish = false;
863
883
    m_aboutToFinishLock.unlock();
864
884
}
865
885