Ticket #3031: 3031-dbg-5.patch

File 3031-dbg-5.patch, 15.6 KB (added by danielk, 17 years ago)

Another debugging patch

  • libs/libmythtv/hdhrchannel.cpp

     
    8787
    8888bool HDHRChannel::EnterPowerSavingMode(void)
    8989{
     90#if 0
    9091    return QString::null != TunerSet("channel", "none", false);
     92#endif
    9193}
    9294
    9395bool HDHRChannel::FindDevice(void)
     
    275277    if (!inputName.isEmpty())
    276278        return SwitchToInput(inputName, channum);
    277279
    278     ClearDTVInfo();
    279     _ignore_filters = false;
     280    SetCachedATSCInfo("");
    280281
    281282    InputMap::const_iterator it = inputs.find(currentInputID);
    282283    if (it == inputs.end())
     
    331332    curchannelname = QDeepCopy<QString>(channum);
    332333
    333334    // Set the major and minor channel for any additional multiplex tuning
    334     SetDTVInfo(atsc_major, atsc_minor, netid, tsid, mpeg_prog_num);
     335    if (atsc_major || atsc_minor)
     336        SetCachedATSCInfo(QString("%1_%2").arg(atsc_major).arg(atsc_minor));
     337    else if (mpeg_prog_num >= 0)
     338        SetCachedATSCInfo(QString("0-%1").arg(mpeg_prog_num));
     339    else
     340        SetCachedATSCInfo(QString("%1_0").arg(channum));
    335341
    336342    // Set this as the future start channel for this source
    337     inputs[currentInputID]->startChanNum = QDeepCopy<QString>(curchannelname);
     343    inputs[currentInputID]->startChanNum = curchannelname;
    338344
    339     // Turn on the HDHomeRun program filtering if it is supported
    340     // and we are tuning to an MPEG program number.
    341     if (mpeg_prog_num && (GetTuningMode() == "mpeg"))
    342     {
    343         QString pnum = QString::number(mpeg_prog_num);
    344         _ignore_filters = QString::null != TunerSet("program", pnum, false);
    345     }
    346 
    347345    return true;
    348346}
    349347
     
    529527    vector<uint> range_min;
    530528    vector<uint> range_max;
    531529
    532     if (_ignore_filters)
    533         return true;
    534 
    535530    for (uint i = 0; i < _pids.size(); i++)
    536531    {
    537532        uint pid_min = _pids[i];
  • libs/libmythtv/dvbchannel.h

     
    7272
    7373  private:
    7474    int  GetChanID(void) const;
     75    bool InitChannelParams(DTVMultiplex &t,
     76                           uint sourceid, const QString &channum);
    7577
    7678    void CheckOptions(DTVMultiplex &t) const;
    7779    bool CheckModulation(DTVModulation modulation) const;
  • libs/libmythtv/dtvchannel.h

     
    100100                    uint dvb_orig_netid,
    101101                    uint mpeg_tsid, int mpeg_pnum);
    102102    void ClearDTVInfo(void) { SetDTVInfo(0, 0, 0, 0, -1); }
     103    void SetCachedATSCInfo(const QString &chan);
    103104
    104105    static void GetCachedPids(int chanid, pid_cache_t&);
    105106    static void SaveCachedPids(int chanid, const pid_cache_t&);
  • libs/libmythtv/dvbchannel.cpp

     
    238238    QString loc_err = LOC_ERR + tmp;
    239239
    240240    VERBOSE(VB_CHANNEL, loc);
    241 
    242241    if (fd_frontend < 0)
    243242    {
    244243        VERBOSE(VB_IMPORTANT, loc_err + "Channel object "
    245244                "will not open, can not change channels.");
    246245
    247         ClearDTVInfo();
    248246        return false;
    249247    }
    250248
     
    254252        return true;
    255253    }
    256254
    257     ClearDTVInfo();
    258 
    259255    QString inputName;
    260256    if (!CheckChannel(channum, inputName))
    261257    {
     
    276272    if (it == inputs.end())
    277273        return false;
    278274
    279     // Get the input data for the channel
    280     QString tvformat, modulation, freqtable, freqid, si_std;
    281     int finetune;
    282     uint64_t frequency;
    283     int mpeg_prog_num;
    284     uint atsc_major, atsc_minor, mplexid, tsid, netid;
    285 
    286     if (!ChannelUtil::GetChannelData(
    287         (*it)->sourceid, channum,
    288         tvformat, modulation, freqtable, freqid,
    289         finetune, frequency,
    290         si_std, mpeg_prog_num, atsc_major, atsc_minor, tsid, netid,
    291         mplexid, commfree))
    292     {
    293         VERBOSE(VB_IMPORTANT, loc_err +
    294                 "Unable to find channel in database.");
    295 
    296         return false;
    297     }
    298 
    299     // Initialize basic the tuning parameters
     275    // Initialize all the tuning parameters
    300276    DTVMultiplex tuning;
    301     if (!mplexid || !tuning.FillFromDB(card_type, mplexid))
     277    if (!InitChannelParams(tuning, (*it)->sourceid, channum))
    302278    {
    303279        VERBOSE(VB_IMPORTANT, loc_err +
    304                 "Failed to initialize multiplex options");
     280                "Failed to initialize channel options");
    305281
    306282        return false;
    307283    }
    308284
    309     SetDTVInfo(atsc_major, atsc_minor, netid, tsid, mpeg_prog_num);
    310 
    311     // Try to fix any problems with the multiplex
    312285    CheckOptions(tuning);
    313286
    314287    if (!Tune(tuning, ""))
    315288    {
    316289        VERBOSE(VB_IMPORTANT, loc_err + "Tuning to frequency.");
    317290
    318         ClearDTVInfo();
    319291        return false;
    320292    }
    321293
     
    360332    return SetChannelByString((*it)->startChanNum);
    361333}
    362334
     335/** \fn DVBChannel::InitChannelParams(DTVMultiplex&,uint,const QString&)
     336 *  \brief Initializes all variables pertaining to a channel.
     337 *
     338 *  \return true on success and false on failure
     339 */
     340bool DVBChannel::InitChannelParams(DTVMultiplex  &tuning,
     341                                   uint           sourceid,
     342                                   const QString &channum)
     343{
     344    QString tvformat, modulation, freqtable, freqid, si_std;
     345    int finetune;
     346    uint64_t frequency;
     347    uint mplexid;
     348
     349    if (!ChannelUtil::GetChannelData(
     350            sourceid,   channum,
     351            tvformat,   modulation,   freqtable,   freqid,
     352            finetune,   frequency,
     353            si_std,                   currentProgramNum,
     354            currentATSCMajorChannel,  currentATSCMinorChannel,
     355            currentTransportID,       currentOriginalNetworkID,
     356            mplexid,    commfree))
     357    {
     358        return false;
     359    }
     360
     361    if (currentATSCMinorChannel)
     362        currentProgramNum = -1;
     363
     364    if (mplexid)
     365        return tuning.FillFromDB(card_type, mplexid);
     366
     367    VERBOSE(VB_IMPORTANT, LOC_ERR + "Unable to find channel in database.");
     368    return false;
     369}
     370
    363371/** \fn DVBChannel::CheckOptions(DTVMultiplex&) const
    364372 *  \brief Checks tuning for problems, and tries to fix them.
    365373 */
  • libs/libmythtv/tv_rec.cpp

     
    765765    changeState = false;
    766766
    767767    eitScanStartTime = QDateTime::currentDateTime();   
    768     if ((internalState == kState_None) &&
    769         CardUtil::IsEITCapable(genOpt.cardtype))
     768    if ((internalState == kState_None) && (genOpt.cardtype == "DVB"))
    770769    {
    771770        // Add some randomness to avoid all cards starting
    772771        // EIT scanning at nearly the same time.
     
    981980    MythEvent me("RECORDING_LIST_CHANGE");
    982981    gContext->dispatch(me);
    983982    pauseNotify = true;
     983}   
    984984
    985     if (GetDTVChannel())
    986         GetDTVChannel()->EnterPowerSavingMode();
    987 }
    988 
    989985DVBRecorder *TVRec::GetDVBRecorder(void)
    990986{
    991987#ifdef USING_DVB
     
    10571053        }
    10581054        VERBOSE(VB_IMPORTANT, LOC_ERR + msg1 + "\n\t\t\t" + msg2);
    10591055    }
    1060 
    1061     if (GetDTVChannel())
    1062         GetDTVChannel()->EnterPowerSavingMode();
    10631056}
    10641057
    10651058void TVRec::CloseChannel(void)
     
    16561649        sd->SetCaching(true);
    16571650    }
    16581651
    1659     uint neededVideo = 0;
    1660     uint neededAudio = 0;
     1652    QString sistandard = dtvchan->GetSIStandard();
    16611653
    1662     ProgramInfo *rec = lastTuningRequest.program;
    1663     RecordingProfile profile;
    1664     load_profile(genOpt.cardtype, tvchain, rec, profile);
    1665     const Setting *setting = profile.byName("recordingtype");
    1666     if (setting)
    1667     {
    1668         neededVideo = (setting->getValue() == "tv") ? 1 : 0;
    1669         neededAudio = (setting->getValue() == "audio") ? 1 : 0;
    1670     }
    1671 
    1672     const QString tuningmode = dtvchan->GetTuningMode();
    1673 
    16741654    // Check if this is an ATSC Channel
    16751655    int major = dtvchan->GetMajorChannel();
    16761656    int minor = dtvchan->GetMinorChannel();
    1677     if ((minor > 0) && (tuningmode == "atsc"))
     1657    if ((minor > 0) && (sistandard == "atsc"))
    16781658    {
    16791659        QString msg = QString("ATSC channel: %1_%2").arg(major).arg(minor);
    16801660        VERBOSE(VB_RECORD, LOC + msg);
     
    16911671        asd->Reset(major, minor);
    16921672        sm->SetStreamData(sd);
    16931673        sm->SetChannel(major, minor);
    1694         sd->SetVideoStreamsRequired(neededVideo);
    1695         sd->SetAudioStreamsRequired(neededAudio);
     1674        sd->SetVideoStreamsRequired(1);
    16961675
    16971676        // Try to get pid of VCT from cache and
    16981677        // require MGT if we don't have VCT pid.
     
    17061685    // Check if this is an DVB channel
    17071686    int progNum = dtvchan->GetProgramNumber();
    17081687#ifdef USING_DVB
    1709     if ((progNum >= 0) && (tuningmode == "dvb"))
     1688    if ((progNum >= 0) && (sistandard == "dvb"))
    17101689    {
    17111690        int netid   = dtvchan->GetOriginalNetworkID();
    17121691        int tsid    = dtvchan->GetTransportID();
    17131692
     1693        uint neededVideo = 0;
     1694        uint neededAudio = 0;
     1695
    17141696        DVBStreamData *dsd = dynamic_cast<DVBStreamData*>(sd);
    17151697        if (!dsd)
    17161698        {
     
    17201702                GetDTVRecorder()->SetStreamData(dsd);
    17211703        }
    17221704
     1705        ProgramInfo *rec = lastTuningRequest.program;
     1706        RecordingProfile profile;
     1707        load_profile(genOpt.cardtype, tvchain, rec, profile);
     1708        const Setting *setting = profile.byName("recordingtype");
     1709        if (setting)
     1710        {
     1711            neededVideo = (setting->getValue() == "tv") ? 1 : 0;
     1712            neededAudio = (setting->getValue() == "audio") ? 1 : 0;
     1713        }
     1714
    17231715        VERBOSE(VB_RECORD, LOC +
    17241716                QString("DVB service_id %1 on net_id %2 tsid %3")
    17251717                .arg(progNum).arg(netid).arg(tsid));
     
    17711763        sd->Reset(progNum);
    17721764        sm->SetStreamData(sd);
    17731765        sm->SetProgramNumber(progNum);
    1774         sd->SetVideoStreamsRequired(neededVideo);
    1775         sd->SetAudioStreamsRequired(neededAudio);
    1776 
     1766        sd->SetVideoStreamsRequired(1);
    17771767        sm->AddFlags(SignalMonitor::kDTVSigMon_WaitForPAT |
    17781768                     SignalMonitor::kDTVSigMon_WaitForPMT |
    17791769                     SignalMonitor::kDVBSigMon_WaitForPos);
     
    17841774    }
    17851775
    17861776    QString msg = "No valid DTV info, ATSC maj(%1) min(%2), MPEG pn(%3)";
    1787     VERBOSE(VB_IMPORTANT, LOC_ERR + msg.arg(major).arg(minor).arg(progNum));
     1777    VERBOSE(VB_RECORD, LOC_ERR + msg.arg(major).arg(minor).arg(progNum));
    17881778    return false;
    17891779}
    17901780
     
    23122302    long long bitrate;
    23132303    if (genOpt.cardtype == "MPEG")
    23142304        bitrate = 10080000LL; // use DVD max bit rate
    2315     else if (genOpt.cardtype == "DBOX2")
    2316         bitrate = 10080000LL; // use DVD max bit rate
    2317     else if (!CardUtil::IsEncoder(genOpt.cardtype))
     2305    else if (genOpt.cardtype == "HDTV")
    23182306        bitrate = 19400000LL; // 1080i
     2307    else if (genOpt.cardtype == "FIREWIRE")
     2308        bitrate = 19400000LL; // 1080i
     2309    else if (genOpt.cardtype == "DVB")
     2310        bitrate = 19400000LL; // 1080i
    23192311    else // frame grabber
    23202312        bitrate = 10080000LL; // use DVD max bit rate, probably too big
    23212313
     
    33903382 */
    33913383void TVRec::TuningFrequency(const TuningRequest &request)
    33923384{
    3393     DTVChannel *dtvchan = GetDTVChannel();
    3394     if (dtvchan)
     3385    if (request.minorChan)
    33953386    {
    3396         MPEGStreamData *mpeg = NULL;
    3397 
    3398         if (GetDTVRecorder())
    3399             mpeg = GetDTVRecorder()->GetStreamData();
    3400 
    3401         const QString tuningmode = (HasFlags(kFlagEITScannerRunning)) ?
    3402             dtvchan->GetSIStandard() :
    3403             dtvchan->GetSuggestedTuningMode(
    3404                 kState_WatchingLiveTV == internalState);
    3405 
    3406         dtvchan->SetTuningMode(tuningmode);
    3407 
    3408         if (request.minorChan && (tuningmode == "atsc"))
    3409         {
    3410             channel->SetChannelByString(request.channel);
    3411 
    3412             ATSCStreamData *atsc = dynamic_cast<ATSCStreamData*>(mpeg);
    3413             if (atsc)
    3414                 atsc->SetDesiredChannel(request.majorChan, request.minorChan);
    3415         }
    3416         else if (request.progNum >= 0)
    3417         {
    3418             channel->SetChannelByString(request.channel);
    3419 
    3420             if (mpeg)
    3421                 mpeg->SetDesiredProgram(request.progNum);
    3422         }
     3387        MPEGStreamData *mpeg = GetDTVRecorder()->GetStreamData();
     3388        ATSCStreamData *atsc = dynamic_cast<ATSCStreamData*>(mpeg);
     3389        channel->SetChannelByString(request.channel);
     3390        atsc->SetDesiredChannel(request.majorChan, request.minorChan);
    34233391    }
    3424 
     3392    else if (request.progNum >= 0)
     3393    {
     3394        MPEGStreamData *mpeg = GetDTVRecorder()->GetStreamData();
     3395        channel->SetChannelByString(request.channel);
     3396        mpeg->SetDesiredProgram(request.progNum);
     3397    }
    34253398    if (request.IsOnSameMultiplex())
    34263399    {
    34273400        QStringList slist;
  • libs/libmythtv/channel.cpp

     
    441441    if (!inputName.isEmpty())
    442442        return ChannelBase::SwitchToInput(inputName, channum);
    443443
    444     ClearDTVInfo();
     444    SetCachedATSCInfo("");
    445445
    446446    InputMap::const_iterator it = inputs.find(currentInputID);
    447447    if (it == inputs.end())
     
    516516    InitPictureAttributes();
    517517
    518518    // Set the major and minor channel for any additional multiplex tuning
    519     SetDTVInfo(atsc_major, atsc_minor, netid, tsid, mpeg_prog_num);
     519    if (atsc_major || atsc_minor)
     520        SetCachedATSCInfo(QString("%1_%2").arg(atsc_major).arg(atsc_minor));
     521    else
     522        SetCachedATSCInfo(QString("%1_0").arg(channum));
    520523
    521524    // Set this as the future start channel for this source
    522     inputs[currentInputID]->startChanNum = QDeepCopy<QString>(curchannelname);
     525    inputs[currentInputID]->startChanNum = curchannelname;
    523526
    524527    return true;
    525528}
  • libs/libmythtv/dtvchannel.cpp

     
    142142    QMutexLocker locker(&dtvinfo_lock);
    143143    tuningMode = QDeepCopy<QString>(tuning_mode.lower());
    144144}
     145
     146void DTVChannel::SetCachedATSCInfo(const QString &chan)
     147{
     148    int progsep = chan.find("-");
     149    int chansep = chan.find("_");
     150
     151    currentProgramNum        = -1;
     152    currentOriginalNetworkID = 0;
     153    currentTransportID       = 0;
     154    currentATSCMajorChannel  = 0;
     155    currentATSCMinorChannel  = 0;
     156
     157    if (progsep >= 0)
     158    {
     159        currentProgramNum = chan.right(chan.length() - progsep - 1).toInt();
     160        currentATSCMajorChannel = chan.left(progsep).toInt();
     161    }
     162    else if (chansep >= 0)
     163    {
     164        currentATSCMinorChannel =
     165            chan.right(chan.length() - chansep - 1).toInt();
     166        currentATSCMajorChannel = chan.left(chansep).toInt();
     167    }
     168    else
     169    {
     170        bool ok;
     171        int chanNum = chan.toInt(&ok);
     172        if (ok && chanNum >= 10)
     173        {
     174            currentATSCMinorChannel = chanNum % 10;
     175            currentATSCMajorChannel = chanNum / 10;
     176        }
     177    }
     178
     179    if (currentATSCMinorChannel > 0)
     180    {
     181        VERBOSE(VB_CHANNEL, LOC +
     182                QString("SetCachedATSCInfo(%2): %3_%4").arg(chan)
     183                .arg(currentATSCMajorChannel).arg(currentATSCMinorChannel));
     184    }
     185    else if ((0 == currentATSCMajorChannel) && (0 == currentProgramNum))
     186    {
     187        VERBOSE(VB_CHANNEL, LOC +
     188                QString("SetCachedATSCInfo(%2): RESET").arg(chan));
     189    }
     190    else
     191    {
     192        VERBOSE(VB_CHANNEL, LOC +
     193                QString("SetCachedATSCInfo(%2): %3-%4").arg(chan)
     194                .arg(currentATSCMajorChannel).arg(currentProgramNum));
     195    }
     196}