Ticket #8501: channelutil.cpp.diff

File channelutil.cpp.diff, 4.4 KB (added by frozball@…, 14 years ago)

a modified version of Stuart's patch

  • channelutil.cpp

     
    2828                              uint     transport_id,
    2929                              // tsid exists with other sistandards,
    3030                              // but we only trust it in dvb-land.
    31                               uint     network_id)
     31                              uint     network_id,
     32                              // must check polarity for dvb-s
     33                              signed char polarity)
    3234{
     35        VERBOSE(VB_CHANSCAN, QString(
     36                    "get_dtv_multiplex(db_source_id: %1, sistandard: '%2', "
     37                                "frequency: %3, transport_id: %4, network_id: %5, polarity: %6)")
     38                    .arg(db_source_id).arg(sistandard)
     39                    .arg(frequency).arg(transport_id)
     40                    .arg(network_id).arg(polarity));
     41
    3342    QString qstr =
    3443        "SELECT mplexid "
    3544        "FROM dtv_multiplex "
     
    4453        qstr += "AND networkid    = :NETWORKID   ";
    4554    }
    4655
     56    // REMOVE THIS COMMENT: When using my Twinhan AD-SP400 (DVB-S2) using the alpha
     57    // mantis driver with channels.conf scanning, it scans as "not dvb" mode even
     58    // though it's a DVB card (i.e. sistandard is a blank string) so I've made
     59    // it always check polarity if it's >0
     60    //
     61    // I'm not sure why an unsigned char is used for polarity, but I thought I'd
     62    // better add checks if it's ever <0 - remove/modify if it's never <0!
     63    if (polarity>0)
     64        qstr += "AND polarity     = :POLARITY    ";
     65
    4766    MSqlQuery query(MSqlQuery::InitCon());
    4867    query.prepare(qstr);
    4968
     
    5170    query.bindValue(":SISTANDARD",        sistandard);
    5271
    5372    if (sistandard.toLower() != "dvb")
    54         query.bindValue(":FREQUENCY", QString::number(frequency));
     73        query.bindValue(":FREQUENCY",   QString::number(frequency));
    5574    else
    5675    {
    57         query.bindValue(":TRANSPORTID",   transport_id);
    58         query.bindValue(":NETWORKID",     network_id);
     76        query.bindValue(":TRANSPORTID", transport_id);
     77        query.bindValue(":NETWORKID",   network_id);
    5978    }
    6079
     80        // REMOVE THIS COMMENT: polarity needs to be converted to a string as passing
     81    // a signed char will mean the integer is passed to the SQL query :-)
     82    if (polarity>0)
     83                query.bindValue(":POLARITY",    QString(polarity));
     84
    6185    if (!query.exec() || !query.isActive())
    6286    {
    6387        MythDB::DBError("get_dtv_multiplex", query);
     
    89113    uint mplex = get_dtv_multiplex(
    90114        db_source_id,  sistandard,    frequency,
    91115        // DVB specific
    92         transport_id,  network_id);
     116        transport_id,  network_id, polarity);
    93117
    94118    VERBOSE(VB_CHANSCAN, QString(
    95                 "insert_dtv_multiplex(%1, '%2', %3, %4, %5, %6...) mplexid:%7")
     119                "insert_dtv_multiplex(db_source_id: %1, sistandard: '%2', "
     120                                "frequency: %3, modulation: %4, transport_id: %5, "
     121                                "network_id: %6, polarity: %7...) mplexid:%8")
    96122            .arg(db_source_id).arg(sistandard)
    97123            .arg(frequency).arg(modulation)
    98124            .arg(transport_id).arg(network_id)
    99             .arg(mplex));
     125            .arg(polarity).arg(mplex));
    100126
    101127    bool isDVB = (sistandard.toLower() == "dvb");
    102128
     
    141167        "WHERE sourceid    = :SOURCEID      AND "
    142168        "      sistandard  = :SISTANDARD    AND ";
    143169
     170    // After inserting the channels, it UPDATEs ALL the items and replaces
     171    // the polarity of both v and h DVB-S transponders with the new value
     172    // without this line!
     173    // HACK: I used :WHEREPOLARITY to prevent :POLARITY overtaking :POLARITY2
     174    if (polarity > 0)
     175        updateStr += " polarity     = :WHEREPOLARITY      AND ";
     176
    144177    updateStr += (isDVB) ?
    145178        " transportid = :TRANSPORTID AND networkid = :NETWORKID " :
    146179        " frequency = :FREQUENCY2 ";
     
    211244            if (transport_id)
    212245                query.bindValue(":TRANSPORTID", transport_id);
    213246        }
     247
     248        if (polarity > 0)
     249                query.bindValue(":WHEREPOLARITY", QString("%1").arg((char)polarity));
    214250    }
    215251    else
    216252    {
     
    263299    mplex = get_dtv_multiplex(
    264300        db_source_id,  sistandard,    frequency,
    265301        // DVB specific
    266         transport_id,  network_id);
     302        transport_id,  network_id, polarity);
    267303
    268304    VERBOSE(VB_CHANSCAN, QString("insert_dtv_multiplex -- ") +
    269305            QString("inserted %1").arg(mplex));