Ticket #12092: 0023-delay-concurent-tunings.patch

File 0023-delay-concurent-tunings.patch, 2.6 KB (added by warpme@…, 10 years ago)
  • mythtv/libs/libmythtv/recorders/dvbchannel.cpp

    diff -Naur mythtv-0.27-20140225-g28b768a-old/mythtv/libs/libmythtv/recorders/dvbchannel.cpp mythtv-0.27-20140225-g28b768a-new/mythtv/libs/libmythtv/recorders/dvbchannel.cpp
    old new  
    5555static DTVMultiplex dvbparams_to_dtvmultiplex(
    5656    DTVTunerType, const dvb_frontend_parameters&);
    5757
     58qint64 concurrent_tunings_delay = 1000;
     59QDateTime DVBChannel::last_tuning = QDateTime::currentDateTime();
     60
    5861#define LOC QString("DVBChan[%1](%2): ").arg(GetCardID()).arg(GetDevice())
    5962
    6063/** \class DVBChannel
     
    9699    master_map_lock.unlock();
    97100
    98101    sigmon_delay = CardUtil::GetMinSignalMonitoringDelay(device);
     102
    99103}
    100104
    101105DVBChannel::~DVBChannel()
     
    710714
    711715    if (reset || !prev_tuning.IsEqual(tunerType, tuning, 500 * freq_mult))
    712716    {
     717
    713718        LOG(VB_CHANNEL, LOG_INFO, LOC + QString("Tune(): Tuning to %1%2")
    714719                .arg(intermediate_freq ? intermediate_freq : tuning.frequency)
    715720                .arg(suffix));
    716721
     722        tune_delay_lock.lock();
     723
     724        if (QDateTime::currentDateTime() < last_tuning)
     725        {
     726            LOG(VB_GENERAL, LOG_INFO, LOC + QString("Next tuning after less than %1ms. Delaying by %1ms")
     727                .arg(concurrent_tunings_delay));
     728            usleep(concurrent_tunings_delay * 1000);
     729        }
     730
     731        last_tuning = QDateTime::currentDateTime();
     732        last_tuning = last_tuning.addMSecs(concurrent_tunings_delay);
     733
     734        tune_delay_lock.unlock();
     735
    717736        // send DVB-S setup
    718737        if (diseqc_tree)
    719738        {
     
    812831                    "Tune(): Setting Frontend tuning parameters failed." + ENO);
    813832                return false;
    814833            }
     834
    815835        }
    816836        else
    817837#endif
  • mythtv/libs/libmythtv/recorders/dvbchannel.h

    diff -Naur mythtv-0.27-20140225-g28b768a-old/mythtv/libs/libmythtv/recorders/dvbchannel.h mythtv-0.27-20140225-g28b768a-new/mythtv/libs/libmythtv/recorders/dvbchannel.h
    old new  
    144144    int               fd_frontend; ///< File descriptor for tuning hardware
    145145    QString           device;      ///< DVB Device
    146146    bool              has_crc_bug; ///< true iff our driver munges PMT
     147
     148    static QDateTime  last_tuning;
     149    QMutex            tune_delay_lock;
     150
    147151};
    148152
    149153#endif