Ticket #6948: 6948-v3.patch

File 6948-v3.patch, 24.0 KB (added by danielk, 9 years ago)

Update patch, applies against master. Otherwise completely untested.

  • mythtv/libs/libmythtv/channelbase.cpp

    diff --git a/mythtv/libs/libmythtv/channelbase.cpp b/mythtv/libs/libmythtv/channelbase.cpp
    index bbb7f8e..241beeb 100644
    a b bool ChannelBase::InitializeInputs(void) 
    927927        m_allchannels.insert(m_allchannels.end(),
    928928                           channels.begin(), channels.end());
    929929    }
    930     ChannelUtil::SortChannels(m_allchannels, order);
    931     ChannelUtil::EliminateDuplicateChanNum(m_allchannels);
     930    ChannelUtil::SortChannels(m_allchannels, order, true);
    932931
    933932    m_currentInputID = GetDefaultInput(cardid);
    934933
  • mythtv/libs/libmythtv/channelutil.cpp

    diff --git a/mythtv/libs/libmythtv/channelutil.cpp b/mythtv/libs/libmythtv/channelutil.cpp
    index 42d62a8..de85d8c 100644
    a b bool ChannelUtil::GetExtendedChannelData( 
    19651965                           dvb_transportid, dvb_networkid, dtv_si_std);
    19661966}
    19671967
    1968 DBChanList ChannelUtil::GetChannels(uint sourceid, bool vis_only, QString grp, int changrpid)
     1968DBChanList ChannelUtil::GetChannels(
     1969    uint sourceid, bool vis_only, QString grp, uint changrpid)
    19691970{
    19701971    DBChanList list;
    19711972
    DBChanList ChannelUtil::GetChannels(uint sourceid, bool vis_only, QString grp, i 
    19741975    QString qstr =
    19751976        "SELECT channum, callsign, channel.chanid, "
    19761977        "       atsc_major_chan, atsc_minor_chan, "
    1977         "       name, icon, mplexid, visible "
    1978         "FROM channel ";
     1978        "       name, icon, mplexid, visible, "
     1979        "       channel.sourceid, cardinput.cardid, channelgroup.grpid "
     1980        "FROM channel "
     1981        "LEFT JOIN channelgroup ON channel.chanid     = channelgroup.chanid "
     1982        "JOIN cardinput         ON cardinput.sourceid = channel.sourceid "
     1983        "JOIN capturecard       ON cardinput.cardid   = capturecard.cardid ";
    19791984
    1980     // Select only channels from the specified channel group
    1981     if (changrpid > -1)
    1982         qstr += QString(",channelgroup ");
     1985    QString cond = " WHERE ";
    19831986
    19841987    if (sourceid)
    1985         qstr += QString("WHERE sourceid='%1' ").arg(sourceid);
    1986     else
    1987         qstr += ",cardinput,capturecard "
    1988             "WHERE cardinput.sourceid = channel.sourceid   AND "
    1989             "      cardinput.cardid   = capturecard.cardid     ";
     1988    {
     1989        qstr += QString("WHERE channel.sourceid='%1' ").arg(sourceid);
     1990        cond = " AND ";
     1991    }
    19901992
    1991     if (changrpid > -1)
     1993    // Select only channels from the specified channel group
     1994    if (changrpid > 0)
    19921995    {
    1993         qstr += QString("AND channel.chanid = channelgroup.chanid "
    1994                         "AND channelgroup.grpid ='%1' ").arg(changrpid);
     1996        qstr += QString("%1 channelgroup.grpid = '%2' ")
     1997            .arg(cond).arg(changrpid);
     1998        cond = " AND ";
    19951999    }
    19962000
    19972001    if (vis_only)
    1998         qstr += "AND visible=1 ";
     2002    {
     2003        qstr += QString("%1 visible=1 ").arg(cond);
     2004        cond = " AND ";
     2005    }
    19992006
    20002007    if (!grp.isEmpty())
    2001         qstr += QString("GROUP BY %1 ").arg(grp);
     2008        qstr += QString(" GROUP BY %1 ").arg(grp);
    20022009
    20032010    query.prepare(qstr);
    2004     if (!query.exec() || !query.isActive())
     2011    if (!query.exec())
    20052012    {
    2006         MythDB::DBError("get channels -- sourceid", query);
     2013        MythDB::DBError("ChannelUtil::GetChannels()", query);
    20072014        return list;
    20082015    }
    20092016
    DBChanList ChannelUtil::GetChannels(uint sourceid, bool vis_only, QString grp, i 
    20212028            query.value(7).toUInt(),                      /* mplexid    */
    20222029            query.value(8).toBool(),                      /* visible    */
    20232030            query.value(5).toString(),                    /* name       */
    2024             query.value(6).toString());                   /* icon       */
     2031            query.value(6).toString(),                    /* icon       */
     2032            query.value(9).toUInt(),                      /* sourceid   */
     2033            query.value(11).toUInt(),                     /* cardid     */
     2034            query.value(10).toUInt());                    /* grpid      */
    20252035
    20262036        list.push_back(chan);
    20272037    }
    void ChannelUtil::SortChannels(DBChanList &list, const QString &order, 
    21892199    }
    21902200}
    21912201
    2192 void ChannelUtil::EliminateDuplicateChanNum(DBChanList &list)
    2193 {
    2194     typedef std::set<QString> seen_set;
    2195     seen_set seen;
    2196 
    2197     DBChanList::iterator it = list.begin();
    2198 
    2199     while (it != list.end())
    2200     {
    2201         QString tmp = it->channum; tmp.detach();
    2202         std::pair<seen_set::iterator, bool> insret = seen.insert(tmp);
    2203         if (insret.second)
    2204             ++it;
    2205         else
    2206             it = list.erase(it);
    2207     }
    2208 }
    2209 
    22102202uint ChannelUtil::GetNextChannel(
    22112203    const DBChanList &sorted,
    22122204    uint              old_chanid,
    22132205    uint              mplexid_restriction,
    2214     int               direction)
     2206    int               direction,
     2207    bool              skip_non_visible,
     2208    bool              skip_same_channum_and_callsign)
    22152209{
     2210    // TODO implement skip_same_channum_and_callsign
     2211
    22162212    DBChanList::const_iterator it =
    22172213        find(sorted.begin(), sorted.end(), old_chanid);
    22182214
    uint ChannelUtil::GetNextChannel( 
    22232219        return 0; // no channels..
    22242220
    22252221    DBChanList::const_iterator start = it;
    2226     bool skip_non_visible = true; // TODO make DB selectable
    22272222
    22282223    if (CHANNEL_DIRECTION_DOWN == direction)
    22292224    {
  • mythtv/libs/libmythtv/channelutil.h

    diff --git a/mythtv/libs/libmythtv/channelutil.h b/mythtv/libs/libmythtv/channelutil.h
    index 7e044b9..62283ea 100644
    a b class MTV_PUBLIC ChannelUtil 
    182182    static QString GetVideoFilters(uint sourceid, const QString &channum)
    183183        { return GetChannelValueStr("videofilters", sourceid, channum); }
    184184
    185     static DBChanList GetChannels(uint srcid, bool vis_only,
    186                                   QString grp = "", int changrpid = -1);
     185    static DBChanList GetChannels(
     186        uint sourceid, bool visible_only,
     187        QString group_by = "", uint channel_groupid = 0);
    187188    static vector<uint> GetChanIDs(int sourceid = -1);
    188189    static uint    GetChannelCount(int sourceid = -1);
    189190    static void    SortChannels(DBChanList &list, const QString &order,
    190191                                bool eliminate_duplicates = false);
    191     static void    EliminateDuplicateChanNum(DBChanList &list);
    192192
    193     static uint    GetNextChannel(const DBChanList  &sorted,
    194                                   uint               old_chanid,
    195                                   uint               mplexid_restriction,
    196                                   int                direction);
     193    static uint    GetNextChannel(const DBChanList &sorted,
     194                                  uint old_chanid,
     195                                  uint mplexid_restriction,
     196                                  int  direction,
     197                                  bool skip_non_visible = true,
     198                                  bool skip_same_channum_and_callsign = false);
    197199
    198200    static QString GetChannelValueStr(const QString &channel_field,
    199201                                      uint           sourceid,
  • mythtv/libs/libmythtv/dbchannelinfo.cpp

    diff --git a/mythtv/libs/libmythtv/dbchannelinfo.cpp b/mythtv/libs/libmythtv/dbchannelinfo.cpp
    index 81c2e7a..a22d802 100644
    a b DBChannel::DBChannel( 
    2424    const QString &_channum, const QString &_callsign,
    2525    uint _chanid, uint _major_chan, uint _minor_chan,
    2626    uint _mplexid, bool _visible,
    27     const QString &_name, const QString &_icon) :
     27    const QString &_name, const QString &_icon,
     28    uint _sourceid, uint _cardid, uint _grpid) :
    2829    channum(_channum),
    29     callsign(_callsign), chanid(_chanid),
     30    callsign(_callsign),
     31    name(_name), icon((_icon == "none") ? QString() : _icon),
     32    chanid(_chanid),
    3033    major_chan(_major_chan), minor_chan(_minor_chan),
    31     mplexid(_mplexid), visible(_visible),
    32     name(_name), icon(_icon)
     34    mplexid((_mplexid == 32767) ? 0 : _mplexid),
     35    sourceid(_sourceid), cardid(_cardid), grpid(_grpid),
     36    visible(_visible)
    3337{
    34     channum.detach();
    35     callsign.detach();
    36     name.detach();
    37     icon.detach();
    38     mplexid = (mplexid == 32767) ? 0 : mplexid;
    39     icon = (icon == "none") ? QString::null : icon;
    4038}
    4139
    4240DBChannel &DBChannel::operator=(const DBChannel &other)
    4341{
    44     channum    = other.channum;  channum.detach();
    45     callsign   = other.callsign; callsign.detach();
     42    channum    = other.channum;
     43    callsign   = other.callsign;
     44    name       = other.name;
     45    icon       = other.icon;
    4646    chanid     = other.chanid;
    4747    major_chan = other.major_chan;
    4848    minor_chan = other.minor_chan;
    4949    mplexid    = (other.mplexid == 32767) ? 0 : other.mplexid;
     50    sourceid   = other.sourceid;
     51    cardid     = other.cardid;
     52    grpid      = other.grpid;
    5053    visible    = other.visible;
    51     name       = other.name; name.detach();
    52     icon       = other.icon; icon.detach();
    5354
    5455    return *this;
    5556}
  • mythtv/libs/libmythtv/dbchannelinfo.h

    diff --git a/mythtv/libs/libmythtv/dbchannelinfo.h b/mythtv/libs/libmythtv/dbchannelinfo.h
    index 38b6d23..c22e973 100644
    a b class MTV_PUBLIC DBChannel 
    2525    DBChannel(const QString &_channum, const QString &_callsign,
    2626              uint _chanid, uint _major_chan, uint _minor_chan,
    2727              uint _mplexid, bool _visible,
    28               const QString &_name, const QString &_icon);
     28              const QString &_name, const QString &_icon,
     29              uint _sourceid, uint _cardid, uint _grpid);
    2930    DBChannel& operator=(const DBChannel&);
    3031
    3132    bool operator == (uint _chanid) const
    class MTV_PUBLIC DBChannel 
    3435  public:
    3536    QString channum;
    3637    QString callsign;
     38    QString name;
     39    QString icon;
    3740    uint    chanid;
    3841    uint    major_chan;
    3942    uint    minor_chan;
    4043    uint    mplexid;
     44    uint    sourceid;
     45    uint    cardid;
     46    uint    grpid;
    4147    bool    visible;
    42     QString name;
    43     QString icon;
    4448};
    4549typedef vector<DBChannel> DBChanList;
    4650
  • mythtv/libs/libmythtv/tv_play.cpp

    diff --git a/mythtv/libs/libmythtv/tv_play.cpp b/mythtv/libs/libmythtv/tv_play.cpp
    index 25ff274..efb80bd 100644
    a b bool TV::CommitQueuedInput(PlayerContext *ctx) 
    64936493        QString chaninput = GetQueuedInput();
    64946494        if (browsehelper->IsBrowsing())
    64956495        {
     6496            uint sourceid = 0;
     6497            ctx->LockPlayingInfo(__FILE__, __LINE__);
     6498            if (ctx->playingInfo)
     6499                sourceid = ctx->playingInfo->GetSourceID();
     6500            ctx->UnlockPlayingInfo(__FILE__, __LINE__);
     6501
    64966502            commited = true;
    64976503            if (channum.isEmpty())
    64986504                channum = browsehelper->GetBrowsedInfo().m_channum;
    6499 
    6500             if ((ctx->recorder && ctx->recorder->CheckChannel(channum)) ||
    6501                 (db_browse_all_tuners &&
    6502                  browsehelper->BrowseAllGetChanId(channum)))
    6503             {
     6505            uint chanid = browsehelper->GetChanId(
     6506                channum, ctx->GetCardID(), sourceid);
     6507            if (chanid)
    65046508                browsehelper->BrowseChannel(ctx, channum);
    6505             }
     6509
    65066510            HideOSDWindow(ctx, "osd_input");
    65076511        }
    65086512        else if (GetQueuedChanID() || !channum.isEmpty())
    void TV::ChangeChannel(PlayerContext *ctx, int direction) 
    65346538                return;
    65356539            }
    65366540            // Collect channel info
    6537             const ProgramInfo pginfo(*ctx->playingInfo);
    6538             old_chanid = pginfo.GetChanID();
     6541            old_chanid = ctx->playingInfo->GetChanID();
    65396542            ctx->UnlockPlayingInfo(__FILE__, __LINE__);
    65406543        }
    65416544
  • mythtv/libs/libmythtv/tvbrowsehelper.cpp

    diff --git a/mythtv/libs/libmythtv/tvbrowsehelper.cpp b/mythtv/libs/libmythtv/tvbrowsehelper.cpp
    index d08db85..204547f 100644
    a b  
    77#include "remoteencoder.h"
    88#include "recordinginfo.h"
    99#include "mythplayer.h"
     10#include "cardutil.h"
    1011#include "tv_play.h"
    1112
     13#define LOC      QString("BH: ")
     14#define LOC_WARN QString("BH Warning: ")
     15#define LOC_ERR  QString("BH Error: ")
     16
    1217#define GetPlayer(X,Y) GetPlayerHaveLock(X, Y, __FILE__ , __LINE__)
    1318#define GetOSDLock(X) GetOSDL(X, __FILE__, __LINE__)
    1419
    TVBrowseHelper::TVBrowseHelper( 
    4045    m_chanid(0),
    4146    m_run(true)
    4247{
    43     if (db_browse_all_tuners)
     48    db_all_channels = ChannelUtil::GetChannels(
     49        0, true, "channum, callsign");
     50    ChannelUtil::SortChannels(
     51        db_all_channels, db_channel_ordering, false);
     52
     53    DBChanList::const_iterator it = db_all_channels.begin();
     54    for (; it != db_all_channels.end(); ++it)
    4455    {
    45         db_browse_all_channels = ChannelUtil::GetChannels(
    46             0, true, "channum, callsign");
    47         ChannelUtil::SortChannels(
    48             db_browse_all_channels, db_channel_ordering, true);
     56        db_chanid_to_channum[(*it).chanid] = (*it).channum;
     57        db_channum_to_chanids.insert((*it).channum,(*it).chanid);
    4958    }
    5059
     60    db_all_visible_channels = ChannelUtil::GetChannels(
     61        0, true, "channum, callsign");
     62    ChannelUtil::SortChannels(
     63        db_all_visible_channels, db_channel_ordering, false);
     64
    5165    start();
    5266}
    5367
    TVBrowseHelper::TVBrowseHelper( 
    5670/// \note This may only be called from the UI thread.
    5771bool TVBrowseHelper::BrowseStart(PlayerContext *ctx, bool skip_browse)
    5872{
    59     VERBOSE(VB_IMPORTANT, "BrowseStart()");
     73    VERBOSE(VB_IMPORTANT, QString("BrowseStart(%1skip)")
     74            .arg(skip_browse?"":"no "));
    6075
    6176    if (!gCoreContext->IsUIThread())
    6277        return false;
    bool TVBrowseHelper::BrowseStart(PlayerContext *ctx, bool skip_browse) 
    7994    ctx->LockPlayingInfo(__FILE__, __LINE__);
    8095    if (ctx->playingInfo)
    8196    {
    82         m_ctx = ctx;
    83         BrowseInfo bi(BROWSE_SAME,
    84                       ctx->playingInfo->GetChanNum(),
    85                       ctx->playingInfo->GetChanID(),
    86                       ctx->playingInfo->GetScheduledStartTime(ISODate));
     97        m_ctx       = ctx;
     98        m_channum   = ctx->playingInfo->GetChanNum();
     99        m_chanid    = ctx->playingInfo->GetChanID();
     100        m_starttime = ctx->playingInfo->GetScheduledStartTime(ISODate);
    87101        ctx->UnlockPlayingInfo(__FILE__, __LINE__);
    88102
    89103        if (!skip_browse)
    90104        {
     105            BrowseInfo bi(BROWSE_SAME, m_channum, m_chanid, m_starttime);
    91106            locker.unlock();
    92107            BrowseDispInfo(ctx, bi);
    93108        }
    void TVBrowseHelper::BrowseEnd(PlayerContext *ctx, bool change_channel) 
    146161
    147162void TVBrowseHelper::BrowseDispInfo(PlayerContext *ctx, BrowseInfo &bi)
    148163{
    149     VERBOSE(VB_IMPORTANT, "BrowseDispInfo()");
     164    VERBOSE(VB_IMPORTANT, QString("BrowseDispInfo(..%1)")
     165            .arg(bi.toString()));
    150166
    151167    if (!gCoreContext->IsUIThread())
    152168        return;
    void TVBrowseHelper::BrowseDispInfo(PlayerContext *ctx, BrowseInfo &bi) 
    171187    m_wait.wakeAll();
    172188}
    173189
     190void TVBrowseHelper::BrowseChannel(PlayerContext *ctx, const QString &channum)
     191{
     192    VERBOSE(VB_IMPORTANT, QString("BrowseChannel(.. %1)").arg(channum));
     193
     194    if (!gCoreContext->IsUIThread())
     195        return;
     196
     197    if (db_browse_all_tuners)
     198    {
     199        BrowseInfo bi(channum, 0);
     200        BrowseDispInfo(ctx, bi);
     201        return;
     202    }
     203
     204    if (!ctx->recorder || !ctx->last_cardid)
     205        return;
     206
     207    QString inputname = ctx->recorder->GetInput();
     208    uint    inputid   = CardUtil::GetInputID(ctx->last_cardid, inputname);
     209    uint    sourceid  = CardUtil::GetSourceID(inputid);
     210    if (sourceid)
     211    {
     212        BrowseInfo bi(channum, sourceid);
     213        BrowseDispInfo(ctx, bi);
     214    }
     215}
     216
    174217BrowseInfo TVBrowseHelper::GetBrowsedInfo(void) const
    175218{
    176219    QMutexLocker locker(&m_lock);
    bool TVBrowseHelper::IsBrowsing(void) const 
    195238    return m_ctx != NULL;
    196239}
    197240
    198 /// Returns chanid of random channel with with matching channum
    199 uint TVBrowseHelper::BrowseAllGetChanId(const QString &channum) const
     241/** \brief Returns a chanid for the channum, or 0 if none is available.
     242 *
     243 *  This will prefer a given sourceid first, and then a given card id,
     244 *  but if one or the other can not be satisfied but db_browse_all_tuners
     245 *  is set then it will look to see if the chanid is available on any
     246 *  tuner.
     247 */
     248uint TVBrowseHelper::GetChanId(
     249    const QString &channum, uint pref_cardid, uint pref_sourceid) const
    200250{
    201     DBChanList::const_iterator it = db_browse_all_channels.begin();
    202     for (; it != db_browse_all_channels.end(); ++it)
     251    if (pref_sourceid)
    203252    {
    204         if ((*it).channum == channum)
    205             return (*it).chanid;
     253        DBChanList::const_iterator it = db_all_channels.begin();
     254        for (; it != db_all_channels.end(); ++it)
     255        {
     256            if ((*it).sourceid == pref_sourceid && (*it).channum == channum)
     257                return (*it).chanid;
     258        }
    206259    }
     260
     261    if (pref_cardid)
     262    {
     263        DBChanList::const_iterator it = db_all_channels.begin();
     264        for (; it != db_all_channels.end(); ++it)
     265        {
     266            if ((*it).cardid == pref_cardid && (*it).channum == channum)
     267                return (*it).chanid;
     268        }
     269    }
     270
     271    if (db_browse_all_tuners)
     272    {
     273        DBChanList::const_iterator it = db_all_channels.begin();
     274        for (; it != db_all_channels.end(); ++it)
     275        {
     276            if ((*it).channum == channum)
     277                return (*it).chanid;
     278        }
     279    }
     280
    207281    return 0;
    208282}
    209283
    void TVBrowseHelper::GetNextProgramDB( 
    279353{
    280354    uint chanid = infoMap["chanid"].toUInt();
    281355    if (!chanid)
    282         chanid = BrowseAllGetChanId(infoMap["channum"]);
     356    {
     357        VERBOSE(VB_IMPORTANT, LOC_ERR +
     358                "GetNextProgramDB() requires a chanid");
     359        return;
     360    }
    283361
    284362    int chandir = -1;
    285363    switch (direction)
    void TVBrowseHelper::GetNextProgramDB( 
    288366        case BROWSE_DOWN:     chandir = CHANNEL_DIRECTION_DOWN;     break;
    289367        case BROWSE_FAVORITE: chandir = CHANNEL_DIRECTION_FAVORITE; break;
    290368    }
    291     if (direction != BROWSE_INVALID)
     369    if (chandir != -1)
    292370    {
    293371        chanid = ChannelUtil::GetNextChannel(
    294             db_browse_all_channels, chanid, 0, chandir);
     372            db_all_visible_channels, chanid, 0 /*mplexid_restriction*/,
     373            chandir, true /*skip non visible*/, true /*skip same callsign*/);
    295374    }
    296375
    297     infoMap["chanid"] = QString::number(chanid);
    298 
    299     DBChanList::const_iterator it = db_browse_all_channels.begin();
    300     for (; it != db_browse_all_channels.end(); ++it)
    301     {
    302         if ((*it).chanid == chanid)
    303         {
    304             QString tmp = (*it).channum;
    305             tmp.detach();
    306             infoMap["channum"] = tmp;
    307             break;
    308         }
    309     }
     376    infoMap["chanid"]  = QString::number(chanid);
     377    infoMap["channum"] = db_chanid_to_channum[chanid];
    310378
    311379    QDateTime nowtime = QDateTime::currentDateTime();
    312380    QDateTime latesttime = nowtime.addSecs(6*60*60);
    void TVBrowseHelper::run() 
    370438
    371439        PlayerContext *ctx = m_ctx;
    372440
     441        vector<uint> chanids;
    373442        if (BROWSE_SAME == bi.m_dir)
    374443        {
    375444            m_channum   = bi.m_channum;
    376445            m_chanid    = bi.m_chanid;
    377446            m_starttime = bi.m_starttime;
     447            if (!m_chanid)
     448            {
     449
     450            // TODO When channum is given and not chanid,
     451            // we want to check all channels available to
     452            // us with that channum..
     453            }
    378454        }
    379455
    380456        BrowseDirection direction = bi.m_dir;
    void TVBrowseHelper::run() 
    444520            }
    445521            else
    446522            {
     523                // TODO handle browse_same...
     524                uint orig_chanid = infoMap["chanid"].toUInt();
    447525                GetNextProgramDB(direction, infoMap);
    448526                while (!m_tv->IsTunable(ctx, infoMap["chanid"].toUInt()) &&
    449                        (infoMap["channum"] != m_channum))
     527                       (infoMap["chanid"].toUInt() != orig_chanid))
    450528                {
    451529                    GetNextProgramDB(direction, infoMap);
    452530                }
  • mythtv/libs/libmythtv/tvbrowsehelper.h

    diff --git a/mythtv/libs/libmythtv/tvbrowsehelper.h b/mythtv/libs/libmythtv/tvbrowsehelper.h
    index 0ab6b38..8cb3a0c 100644
    a b  
    44#define _TV_BROWSE_HELPER_H_
    55
    66#include <QWaitCondition>
     7#include <QMultiMap>
    78#include <QThread>
    89#include <QString>
     10#include <QHash>
    911
    1012#include "dbchannelinfo.h" // for DBChanList
    1113#include "programtypes.h"  // for InfoMap
    class BrowseInfo 
    1921{
    2022  public:
    2123    BrowseInfo(BrowseDirection dir) :
    22         m_dir(dir), m_chanid(0)
     24        m_dir(dir), m_chanid(0), m_sourceid(0)
    2325    {
    2426    }
    2527    BrowseInfo(BrowseDirection dir,
    2628               const QString &channum,
    2729               uint           chanid,
    2830               const QString &starttime) :
    29         m_dir(dir),  m_channum(channum),
    30         m_chanid(0), m_starttime(starttime)
     31        m_dir(dir),         m_channum(channum),
     32        m_chanid(chanid),   m_starttime(starttime),
     33        m_sourceid(0)
     34    {
     35    }
     36    BrowseInfo(const QString &channum,
     37               uint           sourceid) :
     38        m_dir(BROWSE_SAME), m_channum(channum),
     39        m_chanid(0),        m_sourceid(sourceid)
    3140    {
    3241    }
    3342
     43    QString toString() const
     44    {
     45        return QString("%1;%2;%3;%4;%5")
     46            .arg(BROWSE_SAME==m_dir?"SAME":
     47                 BROWSE_UP  ==m_dir?"UP":
     48                 BROWSE_DOWN==m_dir?"DOWN":
     49                 QString::number(m_dir))
     50            .arg(m_channum)
     51            .arg(m_chanid)
     52            .arg(m_starttime)
     53            .arg(m_sourceid);
     54    }
     55
    3456    BrowseDirection m_dir;
    3557    QString         m_channum;
    3658    uint            m_chanid;
    3759    QString         m_starttime;
     60    uint            m_sourceid;
    3861};
    3962
    4063
    class TVBrowseHelper : public QThread 
    82105            BrowseDispInfo(ctx, bi);
    83106    }
    84107
    85     void BrowseChannel(PlayerContext *ctx, const QString &channum)
    86     {
    87         BrowseInfo bi(BROWSE_SAME, channum, 0, "");
    88         BrowseDispInfo(ctx, bi);
    89     }
     108    void BrowseChannel(PlayerContext *ctx, const QString &channum);
    90109
    91110    BrowseInfo GetBrowsedInfo(void) const;
    92111    bool IsBrowsing(void) const;
    93     uint BrowseAllGetChanId(const QString &channum) const;
     112    uint GetChanId(const QString &channum,
     113                   uint pref_cardid, uint pref_sourceid) const;
    94114
    95115  protected:
    96116    void GetNextProgram(BrowseDirection direction, InfoMap &infoMap) const;
    class TVBrowseHelper : public QThread 
    99119    virtual void run();
    100120
    101121    TV               *m_tv;
    102     DBChanList        db_browse_all_channels;
     122    DBChanList        db_all_channels;
     123    DBChanList        db_all_visible_channels;
    103124    QString           db_time_format;
    104125    QString           db_short_date_format;
    105126    uint              db_browse_max_forward;
    106127    bool              db_browse_all_tuners;
    107128    bool              db_use_channel_groups;
     129    QHash<uint,QString>     db_chanid_to_channum;
     130    QMultiMap<QString,uint> db_channum_to_chanids;
    108131
    109132    mutable QMutex    m_lock; // protects variables below
    110133    PlayerContext    *m_ctx;
  • mythtv/programs/mythfrontend/guidegrid.cpp

    diff --git a/mythtv/programs/mythfrontend/guidegrid.cpp b/mythtv/programs/mythfrontend/guidegrid.cpp
    index 458ce40..e86ad5d 100644
    a b void GuideGrid::RunProgramGuide(uint chanid, const QString &channum, 
    172172        changrpid = gCoreContext->GetNumSetting("ChannelGroupDefault", -1);
    173173
    174174    // check there are some channels setup
    175     DBChanList channels = ChannelUtil::GetChannels(0, true, "", changrpid);
     175    DBChanList channels = ChannelUtil::GetChannels(
     176        0, true, "", (changrpid<0) ? 0 : changrpid);
    176177    if (!channels.size())
    177178    {
    178179        QString message;
    void GuideGrid::fillChannelInfos(bool gotostartchannel) 
    832833    m_channelInfoIdx.clear();
    833834    m_currentStartChannel = 0;
    834835
    835     DBChanList channels = ChannelUtil::GetChannels(0, true, "", m_changrpid);
     836    DBChanList channels = ChannelUtil::GetChannels(
     837        0, true, "", (m_changrpid < 0) ? 0 : m_changrpid);
    836838    ChannelUtil::SortChannels(channels, m_channelOrdering, false);
    837839
    838840    typedef vector<uint> uint_list_t;