Ticket #927: tuning1.diff

File tuning1.diff, 7.1 KB (added by Mark.Buechler@…, 18 years ago)

The patch

  • mythtv/libs/libmythtv/dvbchannel.h

     
    6565    bool SwitchToInput(const QString &inputname, const QString &chan);
    6666    bool SwitchToInput(int newcapchannel, bool setstarting);
    6767    bool Tune(const dvb_channel_t& channel, bool force_reset=false);
     68    bool Tune_again(void);
    6869
    6970    // Set/Get/Command just for SIScan/ScanWizardScanner
    7071    void SetMultiplexID(int mplexid)          { currentTID = mplexid; };
     
    100101    dvb_frontend_info info;        ///< Contains info on tuning hardware
    101102    dvb_channel_t     chan_opts;   ///< Tuning options sent to tuning hardware
    102103    DVBTuning         prev_tuning; ///< Last tuning options sent to hardware
     104    dvb_channel_t     prev_channel; ///< Last tuning options sent to runing hardware
    103105
    104106    volatile int      fd_frontend; ///< File descriptor for tuning hardware
    105107    int               cardnum;     ///< DVB Card number
     
    111113    bool              first_tune;  ///< Used to force hardware reset
    112114
    113115    int               nextcapchannel; ///< Signal an input change
     116    int               frequency_incr; ///< Incrementer/decrementer for tuning
    114117};
    115118
    116119#endif
  • mythtv/libs/libmythtv/dvbchannel.cpp

     
    8686    bzero(&info, sizeof(info));
    8787    has_crc_bug = CardUtil::HasDVBCRCBug(aCardNum);
    8888    sigmon_delay = CardUtil::GetMinSignalMonitoringDelay(aCardNum);
     89    frequency_incr = -10;
    8990}
    9091
    9192DVBChannel::~DVBChannel()
     
    603604    bool has_diseq = (FE_QPSK == info.type) && diseqc;
    604605    struct dvb_frontend_parameters params = channel.tuning.params;
    605606
     607    prev_channel.tuning = channel.tuning;
     608
    606609    if (fd_frontend < 0)
    607610    {
    608611        ERROR("DVBChannel::Tune: Card not open!");
     
    630633        // Adjust for Satelite recievers which offset the frequency.
    631634        params.frequency = tuned_frequency(channel.tuning, info.type, NULL);
    632635
     636        frequency_incr = 0 - frequency_incr;
     637        params.frequency = params.frequency + frequency_incr;
     638
    633639        if (ioctl(fd_frontend, FE_SET_FRONTEND, &params) < 0)
    634640        {
    635641            ERRNO("DVBChannel::Tune: "
     
    652658    return true;
    653659}
    654660
     661/** \fn DVBChannel::Tune_again(void)
     662 *  \brief Calls DVBChannel::Tune() with the last known parameters
     663 *  \return DVBChannel::Tune()
     664 */
     665bool DVBChannel::Tune_again(void)
     666{
     667    return Tune(prev_channel, true);
     668}
     669
    655670/** \fn DVBChannel::GetTuningParams(DVBTuning& tuning) const
    656671 *  \brief Fetches DVBTuning params from driver
    657672 *  \return true on success, false on failure
  • mythtv/libs/libmythtv/tv_rec.cpp

     
    136136      // RingBuffer info
    137137      ringBuffer(NULL), rbFilePrefix(""), rbFileExt("mpg")
    138138{
     139      // Retune stuff
     140      retune_timer = new TuningTimer();
     141      retune_timer->setTimeout(10000);
     142      retune_timer->start();
     143      retune_requests = 0;
    139144}
    140145
    141146bool TVRec::CreateChannel(const QString &startchannel)
     
    32623267 */
    32633268void TVRec::HandleTuning(void)
    32643269{
     3270    bool handle_done = false;
     3271
    32653272    if (tuningRequests.size())
    32663273    {
    32673274        const TuningRequest *request = &tuningRequests.front();
     
    32733280                              kFlagEITScan|kFlagAntennaAdjust))
    32743281        {
    32753282            if (!recorder)
     3283            {
    32763284                TuningFrequency(*request);
     3285                retune_timer->restart();
     3286                retune_timer->addMSecs(1);
     3287                retune_requests = 0;
     3288            }
    32773289            else
    32783290                SetFlags(kFlagWaitingForRecPause);
    32793291        }
     
    33023314    if (HasFlags(kFlagWaitingForSignal))
    33033315    {
    33043316        if (!TuningSignalCheck())
    3305             return;
     3317            handle_done = true;
    33063318    }
    33073319
    33083320    if (HasFlags(kFlagWaitingForSIParser))
    33093321    {
    33103322        if (!TuningPMTCheck())
    3311             return;
     3323            handle_done = true;
    33123324    }
    33133325
     3326#ifdef USING_DVB
     3327    if (HasFlags(kFlagWaitingForSignal) ||  // Just because we have signal, we
     3328        HasFlags(kFlagWaitingForSIParser))  // may not have the right transponder
     3329        if (!retune_timer->elapsed() && (retune_requests < 30))
     3330        {
     3331            RetuneChannel();
     3332            retune_requests++;
     3333        }
     3334#endif // USING_DVB
     3335
     3336    if (handle_done)
     3337        return;
     3338
    33143339    if (HasFlags(kFlagNeedToStartRecorder))
    33153340    {
    33163341        if (recorder)
     
    34523477    ClearFlags(kFlagPendingActions);
    34533478}
    34543479
     3480/** \fn TVRec::RetuneChannel(void)
     3481 *  \brief Retunes a DVB channel
     3482 *  \return DVBChannel::Tune_again() or false if ifndef USING_DVB
     3483 */
     3484bool TVRec::RetuneChannel(void)
     3485{
     3486#ifdef USING_DVB
     3487    if (GetDVBChannel())
     3488        return GetDVBChannel()->Tune_again();
     3489#endif // USING_DVB
     3490    return false;
     3491}
     3492
    34553493/** \fn TVRec::TuningFrequency(const TuningRequest&)
    34563494 *  \brief Performs initial tuning required for any tuning event.
    34573495 *
  • mythtv/libs/libmythtv/tv_rec.h

     
    1313#include "mythdeque.h"
    1414#include "programinfo.h"
    1515#include "tv.h"
     16#include "util.h"
    1617
    1718#include "mythconfig.h"
    1819
     
    5152    BROWSE_FAVORITE ///< Fetch information on the next favorite channel
    5253} BrowseDirections;
    5354
     55class TuningTimer
     56{
     57  public:
     58    TuningTimer() {}
     59
     60    void setTimeout(long t) { _timeout = t; }
     61    long timeout(void) { return _timeout; }
     62    void start() { t_timer.start(); }
     63    int restart() { int ret = elapsed();
     64                    t_timer.restart();
     65                    return ret;
     66                  }
     67    int elapsed() { int ret = t_timer.elapsed();
     68                    if (ret > _timeout) { ret = 0;  t_timer.restart(); }
     69                    return ret;
     70                  }
     71
     72    void addMSecs(int ms) { t_timer.addMSecs(ms); }
     73
     74  private:
     75    QTime t_timer;
     76    long _timeout;
     77};
     78
    5479class GeneralDBOptions
    5580{
    5681  public:
     
    281306    bool TuningPMTCheck(void);
    282307    void TuningNewRecorder(void);
    283308    void TuningRestartRecorder(void);
     309    bool RetuneChannel(void);
    284310    uint TuningCheckForHWChange(const TuningRequest&,
    285311                                QString &channum,
    286312                                QString &inputname);
     
    371397    QString      rbFilePrefix;
    372398    QString      rbFileExt;
    373399
     400    // Retune stuff
     401    TuningTimer *retune_timer;
     402    int retune_requests;
     403
    374404  public:
    375405    static const uint kEITScanStartTimeout;
    376406    static const uint kSignalMonitoringRate;