Ticket #1485: getbettermplex.patch

File getbettermplex.patch, 2.8 KB (added by stuart@…, 15 years ago)

Nasty hack fix to stop more duplicate multiplexes being added to db and prevent some errors.

  • libs/libmythtv/channelutil.h

     
    3535    static int     GetMplexID(int sourceid, uint freq);
    3636    static int     GetMplexID(int sourceid, uint frequency,
    3737                              int transport_id, int network_id);
     38    static int     GetExistingMplexID(int transport_id, int network_id);
    3839    static int     GetBetterMplexID(int current_mplexid,
    3940                                    int transport_id, int network_id);
    4041
  • libs/libmythtv/siscan.cpp

     
    12301230    if (!sdt->ServiceCount())
    12311231        return;
    12321232
    1233     int db_mplexid = ChannelUtil::GetBetterMplexID(
    1234         tid_db, sdt->TSID(), sdt->OriginalNetworkID());
     1233    int db_mplexid = ChannelUtil::GetExistingMplexID(sdt->TSID(),
     1234        sdt->OriginalNetworkID());
    12351235
    12361236    if (db_mplexid == -1)
    12371237    {
     
    16551655    {
    16561656        MSqlQuery query(MSqlQuery::InitCon());
    16571657        // See if transport already in database
    1658         QString theQuery = QString("select * from dtv_multiplex where NetworkID = %1 and "
    1659                    " TransportID = %2 and Frequency = %3 and sourceID = %4")
     1658        QString theQuery = QString("SELECT * FROM dtv_multiplex WHERE networkid = %1 AND "
     1659                   " transportid = %2 AND frequency = %3 AND sourceid = %4")
    16601660                   .arg((*t).NetworkID)
    16611661                   .arg((*t).TransportID)
    16621662                   .arg((*t).Frequency)
  • libs/libmythtv/channelutil.cpp

     
    303303    return -1;
    304304}
    305305
     306int ChannelUtil::GetExistingMplexID(int transport_id, int network_id)
     307{
     308    MSqlQuery query(MSqlQuery::InitCon());
     309    // See if transport already in database
     310    query.prepare("SELECT mplexid FROM dtv_multiplex "
     311                  "WHERE networkid=:NETWORKID AND transportid=:TRANSPORTID");
     312
     313    query.bindValue(":NETWORKID",   network_id);
     314    query.bindValue(":TRANSPORTID", transport_id);
     315
     316    if (!query.exec() || !query.isActive())
     317    {
     318        MythContext::DBError("Selecting transports", query);
     319        return -1;
     320    }
     321
     322    if (query.size() > 0)
     323    {
     324        query.next();
     325        VERBOSE(VB_SIPARSER,
     326            QString("Matched existing MplexID"));
     327        return query.value(0).toInt();
     328    }
     329
     330    return -1;
     331}
     332
    306333/** \fn ChannelUtil::GetBetterMplexID(int, int, int)
    307334 *  \brief Returns best match multiplex ID, creating one if needed.
    308335 *