Ticket #11288: DVDPlaybackCleanup-0.26.diff

File DVDPlaybackCleanup-0.26.diff, 6.8 KB (added by peper03@…, 13 years ago)

Same patch just adapted to apply cleanly to the current 0.26-fixes

  • mythtv/libs/libmythtv/DVD/avformatdecoderdvd.cpp

    diff --git a/mythtv/libs/libmythtv/DVD/avformatdecoderdvd.cpp b/mythtv/libs/libmythtv/DVD/avformatdecoderdvd.cpp
    index 0fb91b1..a6c423d 100644
    a b void AvFormatDecoderDVD::UpdateFramesPlayed(void)  
    2626    m_parent->SetFramesPlayed(currentpos + 1);
    2727}
    2828
     29bool AvFormatDecoderDVD::GetFrame(DecodeType decodetype)
     30{
     31    // Always try to decode audio and video for DVDs
     32    return AvFormatDecoder::GetFrame( kDecodeAV );
     33}
     34
    2935void AvFormatDecoderDVD::PostProcessTracks(void)
    3036{
    3137    if (!ringBuffer)
  • mythtv/libs/libmythtv/DVD/avformatdecoderdvd.h

    diff --git a/mythtv/libs/libmythtv/DVD/avformatdecoderdvd.h b/mythtv/libs/libmythtv/DVD/avformatdecoderdvd.h
    index 4c9c15d..5044ba4 100644
    a b class AvFormatDecoderDVD : public AvFormatDecoder  
    1010                       PlayerFlags flags);
    1111    virtual void Reset(bool reset_video_data, bool seek_reset, bool reset_file);
    1212    virtual void UpdateFramesPlayed(void);
     13    virtual bool GetFrame(DecodeType decodetype); // DecoderBase
    1314
    1415  private:
    1516    virtual bool DoRewindSeek(long long desiredFrame);
  • mythtv/libs/libmythtv/DVD/dvdringbuffer.cpp

    diff --git a/mythtv/libs/libmythtv/DVD/dvdringbuffer.cpp b/mythtv/libs/libmythtv/DVD/dvdringbuffer.cpp
    index 0913fe2..1a21400 100644
    a b bool DVDRingBuffer::OpenFile(const QString &lfilename, uint retry_ms)  
    340340    dvdnav_set_readahead_flag(m_dvdnav, 0);
    341341    dvdnav_set_PGC_positioning_flag(m_dvdnav, 1);
    342342
    343     int32_t num_titles = 0;
    344     res = dvdnav_get_number_of_titles(m_dvdnav, &num_titles);
    345     if (num_titles == 0 || res == DVDNAV_STATUS_ERR)
    346     {
    347         char buf[DVD_BLOCK_SIZE * 5];
    348         LOG(VB_GENERAL, LOG_INFO,
    349             LOC + QString("Reading %1 bytes from the drive")
    350                 .arg(DVD_BLOCK_SIZE * 5));
    351         safe_read(buf, DVD_BLOCK_SIZE * 5);
    352         res = dvdnav_get_number_of_titles(m_dvdnav, &num_titles);
    353     }
    354 
    355     if (res == DVDNAV_STATUS_ERR)
    356     {
    357         LOG(VB_GENERAL, LOG_ERR,
    358             LOC + QString("Failed to get the number of titles on the DVD" ));
    359     }
    360     else
    361     {
    362         LOG(VB_GENERAL, LOG_INFO,
    363             LOC + QString("There are %1 titles on the disk")
    364                 .arg(num_titles));
    365     }
    366 
    367     int startTitle = 1;
    368     dvdnav_status_t result;
    369     while (startTitle <= num_titles)
    370     {
    371         result = dvdnav_title_play(m_dvdnav, startTitle);
    372         if (result == DVDNAV_STATUS_OK)
    373             break;
    374         else if (startTitle < num_titles)
    375             LOG(VB_GENERAL, LOG_WARNING, QString("Unable to play DVD title %1, "
    376                                                  "trying next title")
    377                                                     .arg(startTitle));
    378         startTitle++;
    379     }
    380 
    381     if (result == DVDNAV_STATUS_ERR)
    382     {
    383         LOG(VB_GENERAL, LOG_ERR, QString("Unable to play any title on this "
    384                                          "DVD. Disc may be damaged or "
    385                                          "corrupted as a means of copy "
    386                                          "protection."));
    387 
    388         rwlock.unlock();
    389         return false;
    390     }
    391 
    392343    // Check we aren't starting in a still frame (which will probably fail as
    393344    // ffmpeg will be unable to create a decoder)
    394345    if (dvdnav_get_next_still_flag(m_dvdnav))
    bool DVDRingBuffer::StartFromBeginning(void)  
    444395    if (m_dvdnav)
    445396    {
    446397        QMutexLocker lock(&m_seekLock);
     398        dvdnav_reset(m_dvdnav);
    447399        dvdnav_first_play(m_dvdnav);
    448400        m_audioStreamsChanged = true;
    449401    }
  • mythtv/libs/libmythtv/avformatdecoder.cpp

    diff --git a/mythtv/libs/libmythtv/avformatdecoder.cpp b/mythtv/libs/libmythtv/avformatdecoder.cpp
    index 29f8dbb..5a4d965 100644
    a b AvFormatDecoder::AvFormatDecoder(MythPlayer *parent,  
    335335      // Audio
    336336      disable_passthru(false),
    337337      m_fps(0.0f),
    338       codec_is_mpeg(false)
     338      codec_is_mpeg(false),
     339      m_processFrames(true)
    339340{
    340341    memset(&readcontext, 0, sizeof(readcontext));
    341342    memset(ccX08_in_pmt, 0, sizeof(ccX08_in_pmt));
    bool AvFormatDecoder::DoFastForward(long long desiredFrame, bool discardFrames)  
    684685void AvFormatDecoder::SeekReset(long long newKey, uint skipFrames,
    685686                                bool doflush, bool discardFrames)
    686687{
    687     if (ringBuffer->IsInDiscMenuOrStillFrame() || newKey == 0)
    688         return;
    689 
    690688    LOG(VB_PLAYBACK, LOG_INFO, LOC +
    691689        QString("SeekReset(%1, %2, %3 flush, %4 discard)")
    692690            .arg(newKey).arg(skipFrames)
    int AvFormatDecoder::OpenFile(RingBuffer *rbuffer, bool novideo,  
    935933
    936934    ringBuffer = rbuffer;
    937935
     936    // Process frames immediately unless we're decoding
     937    // a DVD, in which case don't so that we don't show
     938    // anything whilst probing the data streams.
     939    m_processFrames = !ringBuffer->IsDVD();
     940
    938941    if (avfRingBuffer)
    939942        delete avfRingBuffer;
    940943    avfRingBuffer = new AVFRingBuffer(rbuffer);
    int AvFormatDecoder::OpenFile(RingBuffer *rbuffer, bool novideo,  
    982985    }
    983986
    984987    int ret = FindStreamInfo();
    985 
    986     // Reset DVD/bluray ringbuffers
    987     if (!ringBuffer->StartFromBeginning())
    988         return -1;
    989     ringBuffer->IgnoreWaitStates(false);
    990 
    991988    if (ret < 0)
    992989    {
    993990        LOG(VB_GENERAL, LOG_ERR, LOC + "Could not find codec parameters. " +
    int AvFormatDecoder::OpenFile(RingBuffer *rbuffer, bool novideo,  
    11441141    if (getenv("FORCE_DTS_TIMESTAMPS"))
    11451142        force_dts_timestamps = true;
    11461143
     1144    if (ringBuffer->IsDVD())
     1145    {
     1146        // Reset DVD playback and clear any of
     1147        // our buffers so that none of the data
     1148        // parsed so far to determine decoders
     1149        // gets shown.
     1150        if (!ringBuffer->StartFromBeginning())
     1151            return -1;
     1152        ringBuffer->IgnoreWaitStates(false);
     1153
     1154        Reset(true, true, true);
     1155
     1156        // Now we're ready to process and show frames
     1157        m_processFrames = true;
     1158    }
     1159
     1160
    11471161    // Return true if recording has position map
    11481162    return recordingHasPositionMap;
    11491163}
    bool AvFormatDecoder::GetFrame(DecodeType decodetype)  
    44184432
    44194433    skipaudio = (lastvpts == 0);
    44204434
     4435    if( !m_processFrames )
     4436    {
     4437        return false;
     4438    }
     4439
    44214440    hasVideo = HasVideo(ic);
    44224441    needDummyVideoFrames = false;
    44234442
  • mythtv/libs/libmythtv/avformatdecoder.h

    diff --git a/mythtv/libs/libmythtv/avformatdecoder.h b/mythtv/libs/libmythtv/avformatdecoder.h
    index 5a97dfd..012eb08 100644
    a b class AvFormatDecoder : public DecoderBase  
    360360
    361361    float m_fps;
    362362    bool  codec_is_mpeg;
     363    bool  m_processFrames;
    363364};
    364365
    365366#endif