Ticket #11739: libmythtv.patch

File libmythtv.patch, 13.4 KB (added by Ronald L Humble (Royboy626) <deadletterfile@…>, 6 years ago)

patch for <tv_rec programdata eitscanner eithelper>.cpp

  • eithelper.cpp

    diff -Naur libmythtv/eithelper.cpp libmythtvclone/eithelper.cpp
    old new  
    7272    uint insertCount = 0;
    7373
    7474    if (db_events.empty())
     75    {
     76        LOG(VB_EIT, LOG_INFO,
     77            LOC + QString("db_events.empty() - return from ProcessEvents"));
    7578        return 0;
     79    }
    7680
    7781    MSqlQuery query(MSqlQuery::InitCon());
    7882    for (uint i = 0; (i < kChunkSize) && (db_events.size() > 0); i++)
    7983    {
    8084        DBEventEIT *event = db_events.dequeue();
    81         eitList_lock.unlock();
    8285
    8386        eitfixup->Fix(*event);
    8487
     88        LOG(VB_EIT, LOG_INFO, LOC +
     89            QString("CHANID::%1<-\nSTARTTIME::%2<-\nTITLE::%3<-\nSUBTITLE::%4<-\nDESCRIPTION:: %5<-")
     90            .arg(event->chanid).arg(event->starttime.toString())
     91            .arg(event->title).arg(event->subtitle)
     92            .arg(event->description));
     93
    8594        insertCount += event->UpdateDB(query, 1000);
    8695        maxStarttime = max (maxStarttime, event->starttime);
    8796
    8897        delete event;
    89         eitList_lock.lock();
    9098    }
    9199
    92100    if (!insertCount)
  • eitscanner.cpp

    diff -Naur libmythtv/eitscanner.cpp libmythtvclone/eitscanner.cpp
    old new  
    4545
    4646void EITScanner::TeardownAll(void)
    4747{
     48LOG(VB_EIT, LOG_INFO,
     49    LOC_ID + QString("EITScanner::TeardownAll"));
    4850    StopActiveScan();
    4951    if (!exitThread)
    5052    {
     
    99101
    100102        if (list_size)
    101103        {
     104                            LOG(VB_EIT, LOG_INFO,
     105                    LOC_ID + QString("BEGIN eitHelper->ProcessEvents"));
    102106            eitCount += eitHelper->ProcessEvents();
    103107            t.start();
     108                            LOG(VB_EIT, LOG_INFO,
     109                    LOC_ID + QString("END   eitHelper->ProcessEvents"));
     110            t.start();
    104111        }
    105112
    106113        // Tell the scheduler to run if
     
    118125        // Is it time to move to the next transport in active scan?
    119126        if (activeScan && (MythDate::current() > activeScanNextTrig))
    120127        {
    121             // if there have been any new events, tell scheduler to run.
     128        LOG(VB_EIT, LOG_INFO,
     129                    LOC_ID + QString("activeScan and time to move to the next channel"));
     130    // if there have been any new events, tell scheduler to run.
    122131            if (eitCount)
    123132            {
    124133                LOG(VB_EIT, LOG_INFO,
     
    128137            }
    129138
    130139            if (activeScanNextChan == activeScanChannels.end())
     140            {
    131141                activeScanNextChan = activeScanChannels.begin();
     142                activeScanStopped = true;
     143                activeScanCond.wakeAll();
     144            }
    132145
    133146            if (!(*activeScanNextChan).isEmpty())
    134147            {
     
    150163
    151164            // 24 hours ago
    152165            eitHelper->PruneEITCache(activeScanNextTrig.toTime_t() - 86400);
     166            LOG(VB_EIT, LOG_INFO,
     167                        LOC_ID + QString("PruneEITCache DONE "));
    153168        }
    154169
    155170        lock.lock();
     
    158173
    159174        if (!activeScan && !activeScanStopped)
    160175        {
     176            LOG(VB_EIT, LOG_INFO,
     177                        LOC_ID + QString("Not activeScan and not activeScanStopped "));
    161178            activeScanStopped = true;
    162179            activeScanCond.wakeAll();
    163180        }
    164181    }
     182    LOG(VB_EIT, LOG_INFO, LOC_ID +
     183        QString("Exiting while not exitThread loop - channel %1"
     184                " activeScanNextTrig 2").arg(*activeScanNextChan));
    165185
    166186    if (eitCount) /* some events have been handled since the last schedule request */
    167187    {
     
    227247void EITScanner::StartActiveScan(TVRec *_rec, uint max_seconds_per_source)
    228248{
    229249    rec = _rec;
     250    uint i, randomStart;
    230251
    231252    if (activeScanChannels.isEmpty())
    232253    {
    233254        // TODO get input name and use it in crawl.
     255        // Place channels with earliest "latest starttime" first in list
    234256        MSqlQuery query(MSqlQuery::InitCon());
    235257        query.prepare(
    236             "SELECT channum, MIN(chanid) "
    237             "FROM channel, cardinput, capturecard, videosource "
     258            "SELECT channum, channel.chanid "
     259            "FROM cardinput, capturecard, videosource, channel LEFT JOIN program "
     260            "ON channel.chanid = program.chanid                "
    238261            "WHERE cardinput.sourceid   = channel.sourceid AND "
    239262            "      videosource.sourceid = channel.sourceid AND "
    240263            "      capturecard.cardid   = cardinput.cardid AND "
     
    244267            "      channum             != ''               AND "
    245268            "      cardinput.cardid     = :CARDID "
    246269            "GROUP BY mplexid "
    247             "ORDER BY cardinput.sourceid, mplexid, "
    248             "         atsc_major_chan, atsc_minor_chan ");
     270            "ORDER BY MAX(starttime) ");
     271
    249272        query.bindValue(":CARDID", rec->GetCaptureCardNum());
    250273
    251274        if (!query.exec() || !query.isActive())
     
    261284    }
    262285
    263286    LOG(VB_EIT, LOG_INFO, LOC_ID +
    264         QString("StartActiveScan called with %1 multiplexes")
    265             .arg(activeScanChannels.size()));
     287        QString("StartActiveScan called with %1 multiplexes %2")
     288         .arg(activeScanChannels.size()).arg(activeScanChannels.join(",")));
    266289
    267290    // Start at a random channel. This is so that multiple cards with
    268291    // the same source don't all scan the same channels in the same
    269292    // order when the backend is first started up.
    270293    if (activeScanChannels.size())
    271294    {
    272         uint randomStart = random() % activeScanChannels.size();
    273         activeScanNextChan = activeScanChannels.begin()+randomStart;
     295    srandom(time(0));
     296      // If more than 5 channels, only randomize the first five
     297        if (activeScanChannels.size() > 4){
     298          // randomstart one more than number in "if"
     299          randomStart = 5;
     300        }
     301        else{
     302          randomStart = activeScanChannels.size();
     303        }
     304        for (i=0;i<randomStart;i++)
     305          {
     306              activeScanChannels.swap(i,random() % randomStart);
     307              LOG(VB_EIT, LOG_DEBUG, LOC_ID +
     308                  QString("StartActiveScan swap   with %1 multiplexes %2")
     309                   .arg(activeScanChannels.size())
     310                   .arg(activeScanChannels.join(",")));
     311          }
     312        activeScanChannels.swap(activeScanChannels.size() -1 - random() % randomStart, activeScanChannels.size() - 1);
     313        activeScanNextChan = activeScanChannels.begin();
    274314
    275315        activeScanNextTrig = MythDate::current();
    276316        activeScanTrigTime = max_seconds_per_source;
     
    280320        activeScanStopped = false;
    281321        activeScan = true;
    282322    }
     323    LOG(VB_EIT, LOG_INFO, LOC_ID +
     324        QString("StartActiveScan random with %1 multiplexes %2")
     325            .arg(activeScanChannels.size()).arg(activeScanChannels.join(",")));
    283326}
    284327
    285328void EITScanner::StopActiveScan(void)
    286329{
     330    LOG(VB_EIT, LOG_INFO, LOC_ID +
     331        QString("EITScanner::StopActiveScan"));
    287332    QMutexLocker locker(&lock);
    288333
    289334    activeScanStopped = false;
  • programdata.cpp

    diff -Naur libmythtv/programdata.cpp libmythtvclone/programdata.cpp
    old new  
    215215    int  i     = -1;
    216216
    217217    if (!count)
     218    {
     219        LOG(VB_EIT, LOG_DEBUG,QString("GetOverlappingPrograms returned zero."));
    218220        return InsertDB(query, chanid);
    219 
     221    }
    220222    // move overlapping programs out of the way and update existing if possible
    221223    match = GetMatch(programs, i);
    222224
     
    483485    if (match.subtitle.length() >= lsubtitle.length())
    484486        lsubtitle = match.subtitle;
    485487
    486     if (match.description.length() >= ldesc.length())
    487         ldesc = match.description;
     488//    if (match.description.length() >= ldesc.length())
     489//        ldesc = match.description;
    488490
    489491    if (lcategory.isEmpty() && !match.category.isEmpty())
    490492        lcategory = match.category;
     
    528530    query.prepare(
    529531        "UPDATE program "
    530532        "SET title          = :TITLE,     subtitle      = :SUBTITLE, "
    531         "    description    = :DESC, "
     533        "    description    = :DESCR, "
    532534        "    category       = :CATEGORY,  category_type = :CATTYPE, "
    533535        "    starttime      = :STARTTIME, endtime       = :ENDTIME, "
    534536        "    closecaptioned = :CC,        subtitled     = :HASSUBTITLES, "
     
    548550    query.bindValue(":OLDSTART",    match.starttime);
    549551    query.bindValue(":TITLE",       denullify(ltitle));
    550552    query.bindValue(":SUBTITLE",    denullify(lsubtitle));
    551     query.bindValue(":DESC",        denullify(ldesc));
     553    query.bindValue(":DESCR",        denullify(ldesc));
    552554    query.bindValue(":CATEGORY",    denullify(lcategory));
    553555    query.bindValue(":CATTYPE",     lcattype);
    554556    query.bindValue(":STARTTIME",   starttime);
     
    570572    query.bindValue(":PROGRAMID",   denullify(lprogramId));
    571573    query.bindValue(":PREVSHOWN",   lpreviouslyshown);
    572574
     575    QString description = QString("");
     576
    573577    if (!query.exec())
    574578    {
    575579        MythDB::DBError("InsertDB", query);
     
    722726        " :AIRDATE,       :ORIGAIRDATE,   :LSOURCE, "
    723727        " :SERIESID,      :PROGRAMID,     :PREVSHOWN) ");
    724728
     729//    if(description == NULL)
     730//    {
     731//       LOG(VB_GENERAL, LOG_INFO,
     732//        QString("program.description NULL - starttime %1 title: %2")
     733//                .arg(starttime.toString()).arg(title));
     734//
     735//    }
    725736    QString cattype = myth_category_type_to_string(categoryType);
    726737    QString empty("");
    727738    query.bindValue(":CHANID",      chanid);
     
    750761    query.bindValue(":PROGRAMID",   denullify(programId));
    751762    query.bindValue(":PREVSHOWN",   previouslyshown);
    752763
     764    QString description = QString("");
     765
    753766    if (!query.exec())
    754767    {
    755768        MythDB::DBError("InsertDB", query);
     
    823836            .arg(endtime.toString(Qt::ISODate))
    824837            .arg(channel)
    825838            .arg(title));
     839//    if(description == NULL)
     840//    {
     841//       LOG(VB_GENERAL, LOG_INFO,
     842//        QString("New program program.description NULL - starttime %1 title: %2")
     843//                .arg(starttime.toString()).arg(title));
     844//
     845//    }
    826846
    827847    query.prepare(
    828848        "REPLACE INTO program ("
     
    884904    query.bindValue(":TITLEPRON",   title_pronounce);
    885905    query.bindValue(":COLORCODE",   colorcode);
    886906
     907    QString description = QString("");
     908
    887909    if (!query.exec())
    888910    {
    889911        MythDB::DBError("program insert", query);
     
    12191241        "      endtime         = :END        AND "
    12201242        "      title           = :TITLE      AND "
    12211243        "      subtitle        = :SUBTITLE   AND "
    1222         "      description     = :DESC       AND "
     1244        "      description     = :DESCR      AND "
    12231245        "      category        = :CATEGORY   AND "
    12241246        "      category_type   = :CATEGORY_TYPE AND "
    12251247        "      airdate         = :AIRDATE    AND "
     
    12451267    query.bindValue(":END",        pi.endtime);
    12461268    query.bindValue(":TITLE",      denullify(pi.title));
    12471269    query.bindValue(":SUBTITLE",   denullify(pi.subtitle));
    1248     query.bindValue(":DESC",       denullify(pi.description));
     1270    query.bindValue(":DESCR",      denullify(pi.description));
    12491271    query.bindValue(":CATEGORY",   denullify(pi.category));
    12501272    query.bindValue(":CATEGORY_TYPE", cattype);
    12511273    query.bindValue(":AIRDATE",    pi.airdate);
     
    12651287                    denullify(pi.syndicatedepisodenumber));
    12661288    query.bindValue(":PROGRAMID",  denullify(pi.programId));
    12671289
     1290//    QString pi.description = QString("");
     1291
    12681292    if (query.exec() && query.next())
    12691293        return query.value(0).toUInt() > 0;
    12701294
  • tv_rec.cpp

    diff -Naur libmythtv/tv_rec.cpp libmythtvclone/tv_rec.cpp
    old new  
    12641264        scanner = new EITScanner(cardid);
    12651265        eitScanStartTime = eitScanStartTime.addSecs(
    12661266            eitCrawlIdleStart + eit_start_rand(cardid, eitTransportTimeout));
     1267        LOG(VB_GENERAL, LOG_INFO, LOC + "Adjusted Scan start " + eitScanStartTime.toString());
    12671268    }
    12681269    else
     1270    {
    12691271        eitScanStartTime = eitScanStartTime.addYears(1);
     1272        LOG(VB_GENERAL, LOG_INFO, LOC + "EIT scan DISABLED " + eitScanStartTime.toString());
     1273    }
    12701274
    12711275    while (HasFlags(kFlagRunMainLoop))
    12721276    {
     
    14131417            }
    14141418            else
    14151419            {
     1420                LOG(VB_GENERAL, LOG_INFO, LOC + QString("StartActiveScan eitTransportTimeout is %1 ")
     1421                    .arg(eitTransportTimeout));
    14161422                scanner->StartActiveScan(this, eitTransportTimeout);
    14171423                SetFlags(kFlagEITScannerRunning);
    1418                 eitScanStartTime = MythDate::current().addYears(1);
     1424                eitScanStartTime = MythDate::current().addSecs(8192);
     1425                //eitScanStartTime = MythDate::current().addYears(1);
    14191426            }
    14201427        }
    14211428
     
    39283935        ClearFlags(kFlagNeedToStartRecorder);
    39293936        newRecStatus = rsFailed;
    39303937
    3931         if (scanner && HasFlags(kFlagEITScannerRunning))
    3932         {
    3933             scanner->StopActiveScan();
    3934             ClearFlags(kFlagEITScannerRunning);
    3935         }
     3938        return NULL;
     3939//        if (scanner && HasFlags(kFlagEITScannerRunning))
     3940//        //        {
     3941//        //            scanner->StopActiveScan();
     3942//        //            ClearFlags(kFlagEITScannerRunning);
     3943//        //        }
     3944
    39363945    }
    39373946    else
    39383947    {