Ticket #3842: 3842-validation-head-v2.patch

File 3842-validation-head-v2.patch, 7.2 KB (added by danielk, 18 years ago)

Updated patch, this fixes a validation bug that caused channels to be added to unconnected sources in safe mode. And also the first time fetch failing problem reported by Robert K.

  • libs/libmythtv/cardutil.h

     
    107107            (rawtype == "HDHOMERUN");
    108108    }
    109109
     110    static bool         IsTuningDigital(const QString &rawtype)
     111    {
     112        return
     113            (rawtype == "DVB")       || (rawtype == "HDTV")  ||
     114            (rawtype == "HDHOMERUN");
     115    }
     116
     117    static bool         IsTuningAnalog(const QString &rawtype)
     118    {
     119        return (rawtype == "V4L");
     120    }
     121
    110122    static int          GetCardID(const QString &videodevice,
    111123                                  QString hostname = QString::null);
    112124    static uint         GetChildCardID(uint cardid);
  • libs/libmythtv/sourceutil.h

     
    1616    static bool    GetListingsLoginData(uint sourceid,
    1717                                        QString &grabber, QString &userid,
    1818                                        QString &passwd,  QString &lineupid);
     19    static uint    GetConnectionCount(uint sourceid);
     20    static bool    IsProperlyConnected(uint sourceid, bool strich = false);
    1921    static bool    IsEncoder(uint sourceid, bool strict = false);
    2022    static bool    IsUnscanable(uint sourceid);
    2123    static bool    IsAnySourceScanable(void);
  • libs/libmythtv/datadirect.cpp

     
    686686{
    687687    int new_channels = 0;
    688688
     689    if (!SourceUtil::GetConnectionCount(sourceid))
     690    {
     691        VERBOSE(VB_IMPORTANT, LOC +
     692                "Not inserting channels into disconnected source "
     693                <<sourceid<<".");
     694        return -1;
     695    }
     696
     697    if (!SourceUtil::IsProperlyConnected(sourceid, true))
     698        return -1;
     699
    689700    // Find all the channels in the dd_v_station temp table
    690701    // where there is no channel with the same xmltvid in the
    691702    // DB using the same source.
     
    706717        return -1;
    707718    }
    708719
    709     bool is_encoder = SourceUtil::IsEncoder(sourceid, true);
     720    bool is_encoder = (SourceUtil::IsEncoder(sourceid, true) ||
     721                       SourceUtil::IsUnscanable(sourceid));
    710722
    711723    while (query.next())
    712724    {
     
    750762bool DataDirectProcessor::UpdateChannelsUnsafe(
    751763    uint sourceid, bool filter_new_channels)
    752764{
     765    if (filter_new_channels &&
     766        !SourceUtil::IsProperlyConnected(sourceid, false))
     767    {
     768        return false;
     769    }
     770
    753771    MSqlQuery dd_station_info(MSqlQuery::DDCon());
    754772    dd_station_info.prepare(
    755773        "SELECT callsign,         stationname, stationid,"
     
    770788        "    atsc_minor_chan = :MINORCHAN "
    771789        "WHERE xmltvid = :STATIONID AND sourceid = :SOURCEID");
    772790
    773     bool is_encoder = SourceUtil::IsEncoder(sourceid, true);
     791    bool is_encoder = (SourceUtil::IsEncoder(sourceid, true) ||
     792                       SourceUtil::IsUnscanable(sourceid));
    774793
    775794    while (dd_station_info.next())       
    776795    {
  • libs/libmythtv/videosource.cpp

     
    19241924
    19251925    if (cardid && srcid)
    19261926    {
     1927        save(); // save info for fetch..
     1928
    19271929        QString cardtype = CardUtil::GetRawCardType(crdid, 0);
    19281930
    19291931        if (!CardUtil::IsUnscanable(cardtype) &&
  • libs/libmythtv/sourceutil.cpp

     
    114114    return list;
    115115}
    116116
     117uint SourceUtil::GetConnectionCount(uint sourceid)
     118{
     119    QStringList types = get_cardtypes(sourceid);
     120    return types.size();
     121}
     122
     123bool SourceUtil::IsProperlyConnected(uint sourceid, bool strict)
     124{
     125    QStringList types = get_cardtypes(sourceid);
     126    QMap<QString,uint> counts;
     127    QStringList::const_iterator it = types.begin();
     128    for (; it != types.end(); ++it)
     129    {
     130        counts[*it]++;
     131
     132        counts[CardUtil::IsEncoder(*it)    ? "ENCODER" : "NOT_ENCODER"]++;
     133        counts[CardUtil::IsUnscanable(*it) ? "NO_SCAN" : "SCAN"]++;
     134
     135        if (CardUtil::IsTuningAnalog(*it))
     136            counts["ANALOG_TUNING"]++;
     137        else if (CardUtil::IsTuningDigital(*it))
     138            counts["DIGITAL_TUNING"]++;
     139        else
     140            counts["OTHER_TUNING"]++;
     141    }
     142
     143    bool tune_mismatch = counts["ANALOG_TUNING"]   && counts["DIGITAL_TUNING"];
     144    bool enc_mismatch  = counts["ENCODER"]         && counts["NOT_ENCODER"];
     145    bool scan_mismatch = counts["SCAN"]            && counts["NO_SCAN"];
     146    bool fw_mismatch   = (counts["FIREWIRE"] &&
     147                          (counts["FIREWIRE"] < types.size()));
     148
     149    if (tune_mismatch)
     150    {
     151        uint a = counts["ANALOG_TUNERS"];
     152        uint d = counts["DIGITAL_TUNERS"];
     153        VERBOSE(VB_GENERAL, QString("SourceUtil::IsProperlyConnected(): ") +
     154                QString("Source ID %1 ").arg(sourceid) +
     155                QString("appears to be connected\n\t\t\tto %1 analog tuner%2,")
     156                .arg(a).arg((1 == a) ? "":"s") +
     157                QString("and %1 digital tuner%2.\n\t\t\t")
     158                .arg(d).arg((1 == d) ? "":"s") +
     159                QString("Can't mix analog and digital tuning information."));
     160    }
     161
     162    if (enc_mismatch)
     163    {
     164        uint a = counts["ENCODER"];
     165        uint d = counts["NOT_ENCODER"];
     166        VERBOSE(VB_GENERAL, QString("SourceUtil::IsProperlyConnected(): ") +
     167                QString("Source ID %1 ").arg(sourceid) +
     168                QString("appears to be connected\n\t\t\tto %1 encoder%2, ")
     169                .arg(a).arg((1 == a) ? "":"s") +
     170                QString("and %1 non-encoder%2. ")
     171                .arg(d).arg((1 == d) ? "":"s") +
     172                QString("This is probably a bad idea."));
     173    }
     174
     175    if (scan_mismatch)
     176    {
     177        uint a = counts["SCAN"];
     178        uint d = counts["NO_SCAN"];
     179        VERBOSE(VB_GENERAL, QString("SourceUtil::IsProperlyConnected(): ") +
     180                QString("Source ID %1 ").arg(sourceid) +
     181                QString("appears to be connected\n\t\t\t"
     182                        "to %1 scanable input%2, ")
     183                .arg(a).arg((1 == a) ? "":"s") +
     184                QString("and %1 non-scanable input%2. ")
     185                .arg(d).arg((1 == d) ? "":"s") +
     186                QString("This may be a problem."));
     187    }
     188
     189    if (fw_mismatch)
     190    {
     191        VERBOSE(VB_GENERAL, QString("SourceUtil::IsProperlyConnected(): ") +
     192                QString(
     193                    "Source ID %1 appears to be connected\n\t\t\t"
     194                    "to both firewire and non-firewire inputs. "
     195                    "This is probably a bad idea.").arg(sourceid));
     196    }
     197
     198    if (!strict)
     199        return !tune_mismatch;
     200
     201    return !tune_mismatch && !enc_mismatch && !scan_mismatch && !fw_mismatch;
     202}
     203
    117204bool SourceUtil::IsEncoder(uint sourceid, bool strict)
    118205{
    119206    bool encoder = true;