summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Kristjansson <danielk@cuymedia.net>2011-05-17 23:45:05 (GMT)
committer Daniel Kristjansson <danielk@cuymedia.net>2011-05-17 23:50:55 (GMT)
commitd14b660c168b3ead0ce0ea8bec49243325e73047 (patch)
treee74ba7c0e103bf0c92f6e216ea1c695cc8ae5d75
parentf5cc88398cf57ad770f8487ca55f1bd8e5f2864b (diff)
Fixes #6948. Refs #8211. Fixes a few bugs in channel browse mode.
-rw-r--r--mythtv/libs/libmythtv/channelbase.cpp3
-rw-r--r--mythtv/libs/libmythtv/channelutil.cpp80
-rw-r--r--mythtv/libs/libmythtv/channelutil.h16
-rw-r--r--mythtv/libs/libmythtv/dbchannelinfo.cpp29
-rw-r--r--mythtv/libs/libmythtv/dbchannelinfo.h10
-rw-r--r--mythtv/libs/libmythtv/tv_play.cpp19
-rw-r--r--mythtv/libs/libmythtv/tvbrowsehelper.cpp195
-rw-r--r--mythtv/libs/libmythtv/tvbrowsehelper.h44
-rw-r--r--mythtv/programs/mythfrontend/guidegrid.cpp6
9 files changed, 270 insertions, 132 deletions
diff --git a/mythtv/libs/libmythtv/channelbase.cpp b/mythtv/libs/libmythtv/channelbase.cpp
index b44a7d5..5427c8d 100644
--- a/mythtv/libs/libmythtv/channelbase.cpp
+++ b/mythtv/libs/libmythtv/channelbase.cpp
@@ -927,8 +927,7 @@ bool ChannelBase::InitializeInputs(void)
m_allchannels.insert(m_allchannels.end(),
channels.begin(), channels.end());
}
- ChannelUtil::SortChannels(m_allchannels, order);
- ChannelUtil::EliminateDuplicateChanNum(m_allchannels);
+ ChannelUtil::SortChannels(m_allchannels, order, true);
m_currentInputID = GetDefaultInput(cardid);
diff --git a/mythtv/libs/libmythtv/channelutil.cpp b/mythtv/libs/libmythtv/channelutil.cpp
index 42d62a8..81aa4c7 100644
--- a/mythtv/libs/libmythtv/channelutil.cpp
+++ b/mythtv/libs/libmythtv/channelutil.cpp
@@ -1965,7 +1965,8 @@ bool ChannelUtil::GetExtendedChannelData(
dvb_transportid, dvb_networkid, dtv_si_std);
}
-DBChanList ChannelUtil::GetChannels(uint sourceid, bool vis_only, QString grp, int changrpid)
+DBChanList ChannelUtil::GetChannels(
+ uint sourceid, bool vis_only, QString grp, uint changrpid)
{
DBChanList list;
@@ -1974,36 +1975,42 @@ DBChanList ChannelUtil::GetChannels(uint sourceid, bool vis_only, QString grp, i
QString qstr =
"SELECT channum, callsign, channel.chanid, "
" atsc_major_chan, atsc_minor_chan, "
- " name, icon, mplexid, visible "
- "FROM channel ";
+ " name, icon, mplexid, visible, "
+ " channel.sourceid, cardinput.cardid, channelgroup.grpid "
+ "FROM channel "
+ "LEFT JOIN channelgroup ON channel.chanid = channelgroup.chanid "
+ "JOIN cardinput ON cardinput.sourceid = channel.sourceid "
+ "JOIN capturecard ON cardinput.cardid = capturecard.cardid ";
- // Select only channels from the specified channel group
- if (changrpid > -1)
- qstr += QString(",channelgroup ");
+ QString cond = " WHERE ";
if (sourceid)
- qstr += QString("WHERE sourceid='%1' ").arg(sourceid);
- else
- qstr += ",cardinput,capturecard "
- "WHERE cardinput.sourceid = channel.sourceid AND "
- " cardinput.cardid = capturecard.cardid ";
+ {
+ qstr += QString("WHERE channel.sourceid='%1' ").arg(sourceid);
+ cond = " AND ";
+ }
- if (changrpid > -1)
+ // Select only channels from the specified channel group
+ if (changrpid > 0)
{
- qstr += QString("AND channel.chanid = channelgroup.chanid "
- "AND channelgroup.grpid ='%1' ").arg(changrpid);
+ qstr += QString("%1 channelgroup.grpid = '%2' ")
+ .arg(cond).arg(changrpid);
+ cond = " AND ";
}
if (vis_only)
- qstr += "AND visible=1 ";
+ {
+ qstr += QString("%1 visible=1 ").arg(cond);
+ cond = " AND ";
+ }
if (!grp.isEmpty())
- qstr += QString("GROUP BY %1 ").arg(grp);
+ qstr += QString(" GROUP BY %1 ").arg(grp);
query.prepare(qstr);
- if (!query.exec() || !query.isActive())
+ if (!query.exec())
{
- MythDB::DBError("get channels -- sourceid", query);
+ MythDB::DBError("ChannelUtil::GetChannels()", query);
return list;
}
@@ -2021,7 +2028,10 @@ DBChanList ChannelUtil::GetChannels(uint sourceid, bool vis_only, QString grp, i
query.value(7).toUInt(), /* mplexid */
query.value(8).toBool(), /* visible */
query.value(5).toString(), /* name */
- query.value(6).toString()); /* icon */
+ query.value(6).toString(), /* icon */
+ query.value(9).toUInt(), /* sourceid */
+ query.value(11).toUInt(), /* cardid */
+ query.value(10).toUInt()); /* grpid */
list.push_back(chan);
}
@@ -2189,29 +2199,13 @@ void ChannelUtil::SortChannels(DBChanList &list, const QString &order,
}
}
-void ChannelUtil::EliminateDuplicateChanNum(DBChanList &list)
-{
- typedef std::set<QString> seen_set;
- seen_set seen;
-
- DBChanList::iterator it = list.begin();
-
- while (it != list.end())
- {
- QString tmp = it->channum; tmp.detach();
- std::pair<seen_set::iterator, bool> insret = seen.insert(tmp);
- if (insret.second)
- ++it;
- else
- it = list.erase(it);
- }
-}
-
uint ChannelUtil::GetNextChannel(
const DBChanList &sorted,
uint old_chanid,
uint mplexid_restriction,
- int direction)
+ int direction,
+ bool skip_non_visible,
+ bool skip_same_channum_and_callsign)
{
DBChanList::const_iterator it =
find(sorted.begin(), sorted.end(), old_chanid);
@@ -2223,7 +2217,6 @@ uint ChannelUtil::GetNextChannel(
return 0; // no channels..
DBChanList::const_iterator start = it;
- bool skip_non_visible = true; // TODO make DB selectable
if (CHANNEL_DIRECTION_DOWN == direction)
{
@@ -2237,10 +2230,14 @@ uint ChannelUtil::GetNextChannel(
}
while ((it != start) &&
((skip_non_visible && !it->visible) ||
+ (skip_same_channum_and_callsign &&
+ it->channum == start->channum &&
+ it->callsign == start->callsign) ||
(mplexid_restriction &&
(mplexid_restriction != it->mplexid))));
}
- else if ((CHANNEL_DIRECTION_UP == direction) || (CHANNEL_DIRECTION_FAVORITE == direction))
+ else if ((CHANNEL_DIRECTION_UP == direction) ||
+ (CHANNEL_DIRECTION_FAVORITE == direction))
{
do
{
@@ -2250,6 +2247,9 @@ uint ChannelUtil::GetNextChannel(
}
while ((it != start) &&
((skip_non_visible && !it->visible) ||
+ (skip_same_channum_and_callsign &&
+ it->channum == start->channum &&
+ it->callsign == start->callsign) ||
(mplexid_restriction &&
(mplexid_restriction != it->mplexid))));
}
diff --git a/mythtv/libs/libmythtv/channelutil.h b/mythtv/libs/libmythtv/channelutil.h
index 7e044b9..62283ea 100644
--- a/mythtv/libs/libmythtv/channelutil.h
+++ b/mythtv/libs/libmythtv/channelutil.h
@@ -182,18 +182,20 @@ class MTV_PUBLIC ChannelUtil
static QString GetVideoFilters(uint sourceid, const QString &channum)
{ return GetChannelValueStr("videofilters", sourceid, channum); }
- static DBChanList GetChannels(uint srcid, bool vis_only,
- QString grp = "", int changrpid = -1);
+ static DBChanList GetChannels(
+ uint sourceid, bool visible_only,
+ QString group_by = "", uint channel_groupid = 0);
static vector<uint> GetChanIDs(int sourceid = -1);
static uint GetChannelCount(int sourceid = -1);
static void SortChannels(DBChanList &list, const QString &order,
bool eliminate_duplicates = false);
- static void EliminateDuplicateChanNum(DBChanList &list);
- static uint GetNextChannel(const DBChanList &sorted,
- uint old_chanid,
- uint mplexid_restriction,
- int direction);
+ static uint GetNextChannel(const DBChanList &sorted,
+ uint old_chanid,
+ uint mplexid_restriction,
+ int direction,
+ bool skip_non_visible = true,
+ bool skip_same_channum_and_callsign = false);
static QString GetChannelValueStr(const QString &channel_field,
uint sourceid,
diff --git a/mythtv/libs/libmythtv/dbchannelinfo.cpp b/mythtv/libs/libmythtv/dbchannelinfo.cpp
index 81c2e7a..a22d802 100644
--- a/mythtv/libs/libmythtv/dbchannelinfo.cpp
+++ b/mythtv/libs/libmythtv/dbchannelinfo.cpp
@@ -24,32 +24,33 @@ DBChannel::DBChannel(
const QString &_channum, const QString &_callsign,
uint _chanid, uint _major_chan, uint _minor_chan,
uint _mplexid, bool _visible,
- const QString &_name, const QString &_icon) :
+ const QString &_name, const QString &_icon,
+ uint _sourceid, uint _cardid, uint _grpid) :
channum(_channum),
- callsign(_callsign), chanid(_chanid),
+ callsign(_callsign),
+ name(_name), icon((_icon == "none") ? QString() : _icon),
+ chanid(_chanid),
major_chan(_major_chan), minor_chan(_minor_chan),
- mplexid(_mplexid), visible(_visible),
- name(_name), icon(_icon)
+ mplexid((_mplexid == 32767) ? 0 : _mplexid),
+ sourceid(_sourceid), cardid(_cardid), grpid(_grpid),
+ visible(_visible)
{
- channum.detach();
- callsign.detach();
- name.detach();
- icon.detach();
- mplexid = (mplexid == 32767) ? 0 : mplexid;
- icon = (icon == "none") ? QString::null : icon;
}
DBChannel &DBChannel::operator=(const DBChannel &other)
{
- channum = other.channum; channum.detach();
- callsign = other.callsign; callsign.detach();
+ channum = other.channum;
+ callsign = other.callsign;
+ name = other.name;
+ icon = other.icon;
chanid = other.chanid;
major_chan = other.major_chan;
minor_chan = other.minor_chan;
mplexid = (other.mplexid == 32767) ? 0 : other.mplexid;
+ sourceid = other.sourceid;
+ cardid = other.cardid;
+ grpid = other.grpid;
visible = other.visible;
- name = other.name; name.detach();
- icon = other.icon; icon.detach();
return *this;
}
diff --git a/mythtv/libs/libmythtv/dbchannelinfo.h b/mythtv/libs/libmythtv/dbchannelinfo.h
index 38b6d23..c22e973 100644
--- a/mythtv/libs/libmythtv/dbchannelinfo.h
+++ b/mythtv/libs/libmythtv/dbchannelinfo.h
@@ -25,7 +25,8 @@ class MTV_PUBLIC DBChannel
DBChannel(const QString &_channum, const QString &_callsign,
uint _chanid, uint _major_chan, uint _minor_chan,
uint _mplexid, bool _visible,
- const QString &_name, const QString &_icon);
+ const QString &_name, const QString &_icon,
+ uint _sourceid, uint _cardid, uint _grpid);
DBChannel& operator=(const DBChannel&);
bool operator == (uint _chanid) const
@@ -34,13 +35,16 @@ class MTV_PUBLIC DBChannel
public:
QString channum;
QString callsign;
+ QString name;
+ QString icon;
uint chanid;
uint major_chan;
uint minor_chan;
uint mplexid;
+ uint sourceid;
+ uint cardid;
+ uint grpid;
bool visible;
- QString name;
- QString icon;
};
typedef vector<DBChannel> DBChanList;
diff --git a/mythtv/libs/libmythtv/tv_play.cpp b/mythtv/libs/libmythtv/tv_play.cpp
index 25ff274..efb80bd 100644
--- a/mythtv/libs/libmythtv/tv_play.cpp
+++ b/mythtv/libs/libmythtv/tv_play.cpp
@@ -6493,16 +6493,20 @@ bool TV::CommitQueuedInput(PlayerContext *ctx)
QString chaninput = GetQueuedInput();
if (browsehelper->IsBrowsing())
{
+ uint sourceid = 0;
+ ctx->LockPlayingInfo(__FILE__, __LINE__);
+ if (ctx->playingInfo)
+ sourceid = ctx->playingInfo->GetSourceID();
+ ctx->UnlockPlayingInfo(__FILE__, __LINE__);
+
commited = true;
if (channum.isEmpty())
channum = browsehelper->GetBrowsedInfo().m_channum;
-
- if ((ctx->recorder && ctx->recorder->CheckChannel(channum)) ||
- (db_browse_all_tuners &&
- browsehelper->BrowseAllGetChanId(channum)))
- {
+ uint chanid = browsehelper->GetChanId(
+ channum, ctx->GetCardID(), sourceid);
+ if (chanid)
browsehelper->BrowseChannel(ctx, channum);
- }
+
HideOSDWindow(ctx, "osd_input");
}
else if (GetQueuedChanID() || !channum.isEmpty())
@@ -6534,8 +6538,7 @@ void TV::ChangeChannel(PlayerContext *ctx, int direction)
return;
}
// Collect channel info
- const ProgramInfo pginfo(*ctx->playingInfo);
- old_chanid = pginfo.GetChanID();
+ old_chanid = ctx->playingInfo->GetChanID();
ctx->UnlockPlayingInfo(__FILE__, __LINE__);
}
diff --git a/mythtv/libs/libmythtv/tvbrowsehelper.cpp b/mythtv/libs/libmythtv/tvbrowsehelper.cpp
index d08db85..ad5b583 100644
--- a/mythtv/libs/libmythtv/tvbrowsehelper.cpp
+++ b/mythtv/libs/libmythtv/tvbrowsehelper.cpp
@@ -1,3 +1,6 @@
+#include <algorithm>
+using namespace std;
+
#include "mythcorecontext.h"
#include <QCoreApplication>
@@ -7,8 +10,13 @@
#include "remoteencoder.h"
#include "recordinginfo.h"
#include "mythplayer.h"
+#include "cardutil.h"
#include "tv_play.h"
+#define LOC QString("BH: ")
+#define LOC_WARN QString("BH Warning: ")
+#define LOC_ERR QString("BH Error: ")
+
#define GetPlayer(X,Y) GetPlayerHaveLock(X, Y, __FILE__ , __LINE__)
#define GetOSDLock(X) GetOSDL(X, __FILE__, __LINE__)
@@ -40,14 +48,24 @@ TVBrowseHelper::TVBrowseHelper(
m_chanid(0),
m_run(true)
{
- if (db_browse_all_tuners)
+ db_all_channels = ChannelUtil::GetChannels(
+ 0, true, "channum, callsign");
+ ChannelUtil::SortChannels(
+ db_all_channels, db_channel_ordering, false);
+
+ DBChanList::const_iterator it = db_all_channels.begin();
+ for (; it != db_all_channels.end(); ++it)
{
- db_browse_all_channels = ChannelUtil::GetChannels(
- 0, true, "channum, callsign");
- ChannelUtil::SortChannels(
- db_browse_all_channels, db_channel_ordering, true);
+ db_chanid_to_channum[(*it).chanid] = (*it).channum;
+ db_chanid_to_sourceid[(*it).chanid] = (*it).sourceid;
+ db_channum_to_chanids.insert((*it).channum,(*it).chanid);
}
+ db_all_visible_channels = ChannelUtil::GetChannels(
+ 0, true, "channum, callsign");
+ ChannelUtil::SortChannels(
+ db_all_visible_channels, db_channel_ordering, false);
+
start();
}
@@ -56,8 +74,6 @@ TVBrowseHelper::TVBrowseHelper(
/// \note This may only be called from the UI thread.
bool TVBrowseHelper::BrowseStart(PlayerContext *ctx, bool skip_browse)
{
- VERBOSE(VB_IMPORTANT, "BrowseStart()");
-
if (!gCoreContext->IsUIThread())
return false;
@@ -79,15 +95,15 @@ bool TVBrowseHelper::BrowseStart(PlayerContext *ctx, bool skip_browse)
ctx->LockPlayingInfo(__FILE__, __LINE__);
if (ctx->playingInfo)
{
- m_ctx = ctx;
- BrowseInfo bi(BROWSE_SAME,
- ctx->playingInfo->GetChanNum(),
- ctx->playingInfo->GetChanID(),
- ctx->playingInfo->GetScheduledStartTime(ISODate));
+ m_ctx = ctx;
+ m_channum = ctx->playingInfo->GetChanNum();
+ m_chanid = ctx->playingInfo->GetChanID();
+ m_starttime = ctx->playingInfo->GetScheduledStartTime(ISODate);
ctx->UnlockPlayingInfo(__FILE__, __LINE__);
if (!skip_browse)
{
+ BrowseInfo bi(BROWSE_SAME, m_channum, m_chanid, m_starttime);
locker.unlock();
BrowseDispInfo(ctx, bi);
}
@@ -108,8 +124,6 @@ bool TVBrowseHelper::BrowseStart(PlayerContext *ctx, bool skip_browse)
*/
void TVBrowseHelper::BrowseEnd(PlayerContext *ctx, bool change_channel)
{
- VERBOSE(VB_IMPORTANT, "BrowseEnd()");
-
if (!gCoreContext->IsUIThread())
return;
@@ -146,8 +160,6 @@ void TVBrowseHelper::BrowseEnd(PlayerContext *ctx, bool change_channel)
void TVBrowseHelper::BrowseDispInfo(PlayerContext *ctx, BrowseInfo &bi)
{
- VERBOSE(VB_IMPORTANT, "BrowseDispInfo()");
-
if (!gCoreContext->IsUIThread())
return;
@@ -171,6 +183,31 @@ void TVBrowseHelper::BrowseDispInfo(PlayerContext *ctx, BrowseInfo &bi)
m_wait.wakeAll();
}
+void TVBrowseHelper::BrowseChannel(PlayerContext *ctx, const QString &channum)
+{
+ if (!gCoreContext->IsUIThread())
+ return;
+
+ if (db_browse_all_tuners)
+ {
+ BrowseInfo bi(channum, 0);
+ BrowseDispInfo(ctx, bi);
+ return;
+ }
+
+ if (!ctx->recorder || !ctx->last_cardid)
+ return;
+
+ QString inputname = ctx->recorder->GetInput();
+ uint inputid = CardUtil::GetInputID(ctx->last_cardid, inputname);
+ uint sourceid = CardUtil::GetSourceID(inputid);
+ if (sourceid)
+ {
+ BrowseInfo bi(channum, sourceid);
+ BrowseDispInfo(ctx, bi);
+ }
+}
+
BrowseInfo TVBrowseHelper::GetBrowsedInfo(void) const
{
QMutexLocker locker(&m_lock);
@@ -195,15 +232,46 @@ bool TVBrowseHelper::IsBrowsing(void) const
return m_ctx != NULL;
}
-/// Returns chanid of random channel with with matching channum
-uint TVBrowseHelper::BrowseAllGetChanId(const QString &channum) const
+/** \brief Returns a chanid for the channum, or 0 if none is available.
+ *
+ * This will prefer a given sourceid first, and then a given card id,
+ * but if one or the other can not be satisfied but db_browse_all_tuners
+ * is set then it will look to see if the chanid is available on any
+ * tuner.
+ */
+uint TVBrowseHelper::GetChanId(
+ const QString &channum, uint pref_cardid, uint pref_sourceid) const
{
- DBChanList::const_iterator it = db_browse_all_channels.begin();
- for (; it != db_browse_all_channels.end(); ++it)
+ if (pref_sourceid)
{
- if ((*it).channum == channum)
- return (*it).chanid;
+ DBChanList::const_iterator it = db_all_channels.begin();
+ for (; it != db_all_channels.end(); ++it)
+ {
+ if ((*it).sourceid == pref_sourceid && (*it).channum == channum)
+ return (*it).chanid;
+ }
}
+
+ if (pref_cardid)
+ {
+ DBChanList::const_iterator it = db_all_channels.begin();
+ for (; it != db_all_channels.end(); ++it)
+ {
+ if ((*it).cardid == pref_cardid && (*it).channum == channum)
+ return (*it).chanid;
+ }
+ }
+
+ if (db_browse_all_tuners)
+ {
+ DBChanList::const_iterator it = db_all_channels.begin();
+ for (; it != db_all_channels.end(); ++it)
+ {
+ if ((*it).channum == channum)
+ return (*it).chanid;
+ }
+ }
+
return 0;
}
@@ -279,7 +347,11 @@ void TVBrowseHelper::GetNextProgramDB(
{
uint chanid = infoMap["chanid"].toUInt();
if (!chanid)
- chanid = BrowseAllGetChanId(infoMap["channum"]);
+ {
+ VERBOSE(VB_IMPORTANT, LOC_ERR +
+ "GetNextProgramDB() requires a chanid");
+ return;
+ }
int chandir = -1;
switch (direction)
@@ -288,25 +360,15 @@ void TVBrowseHelper::GetNextProgramDB(
case BROWSE_DOWN: chandir = CHANNEL_DIRECTION_DOWN; break;
case BROWSE_FAVORITE: chandir = CHANNEL_DIRECTION_FAVORITE; break;
}
- if (direction != BROWSE_INVALID)
+ if (chandir != -1)
{
chanid = ChannelUtil::GetNextChannel(
- db_browse_all_channels, chanid, 0, chandir);
+ db_all_visible_channels, chanid, 0 /*mplexid_restriction*/,
+ chandir, true /*skip non visible*/, true /*skip same callsign*/);
}
- infoMap["chanid"] = QString::number(chanid);
-
- DBChanList::const_iterator it = db_browse_all_channels.begin();
- for (; it != db_browse_all_channels.end(); ++it)
- {
- if ((*it).chanid == chanid)
- {
- QString tmp = (*it).channum;
- tmp.detach();
- infoMap["channum"] = tmp;
- break;
- }
- }
+ infoMap["chanid"] = QString::number(chanid);
+ infoMap["channum"] = db_chanid_to_channum[chanid];
QDateTime nowtime = QDateTime::currentDateTime();
QDateTime latesttime = nowtime.addSecs(6*60*60);
@@ -354,6 +416,15 @@ void TVBrowseHelper::GetNextProgramDB(
infoMap["dbstarttime"] = prog->GetScheduledStartTime(ISODate);
}
+inline static QString toString(const InfoMap &infoMap, const QString sep="\n")
+{
+ QString str("");
+ InfoMap::const_iterator it = infoMap.begin();
+ for (; it != infoMap.end() ; ++it)
+ str += QString("[%1]:%2%3").arg(it.key()).arg(*it).arg(sep);
+ return str;
+}
+
void TVBrowseHelper::run()
{
QMutexLocker locker(&m_lock);
@@ -370,10 +441,29 @@ void TVBrowseHelper::run()
PlayerContext *ctx = m_ctx;
+ vector<uint> chanids;
if (BROWSE_SAME == bi.m_dir)
{
+ if (!bi.m_chanid)
+ {
+ vector<uint> chanids_extra;
+ uint sourceid = db_chanid_to_sourceid[m_chanid];
+ QMultiMap<QString,uint>::iterator it;
+ it = db_channum_to_chanids.lowerBound(bi.m_channum);
+ for ( ; (it != db_channum_to_chanids.end()) &&
+ (it.key() == bi.m_channum); it++)
+ {
+ if (db_chanid_to_sourceid[*it] == sourceid)
+ chanids.push_back(*it);
+ else
+ chanids_extra.push_back(*it);
+ }
+ chanids.insert(chanids.end(),
+ chanids_extra.begin(),
+ chanids_extra.end());
+ }
m_channum = bi.m_channum;
- m_chanid = bi.m_chanid;
+ m_chanid = (chanids.empty()) ? bi.m_chanid : chanids[0];
m_starttime = bi.m_starttime;
}
@@ -435,7 +525,7 @@ void TVBrowseHelper::run()
m_tv->GetPlayerReadLock(0,__FILE__,__LINE__);
bool still_there = false;
for (uint i = 0; i < m_tv->player.size() && !still_there; i++)
- still_there |= (ctx == m_tv->player[0]);
+ still_there |= (ctx == m_tv->player[i]);
if (still_there)
{
if (!db_browse_all_tuners)
@@ -444,11 +534,27 @@ void TVBrowseHelper::run()
}
else
{
- GetNextProgramDB(direction, infoMap);
- while (!m_tv->IsTunable(ctx, infoMap["chanid"].toUInt()) &&
- (infoMap["channum"] != m_channum))
+ if (!chanids.empty())
{
+ for (uint i = 0; i < chanids.size(); i++)
+ {
+ if (m_tv->IsTunable(ctx, chanids[i]))
+ {
+ infoMap["chanid"] = QString::number(chanids[i]);
+ GetNextProgramDB(direction, infoMap);
+ break;
+ }
+ }
+ }
+ else
+ {
+ uint orig_chanid = infoMap["chanid"].toUInt();
GetNextProgramDB(direction, infoMap);
+ while (!m_tv->IsTunable(ctx, infoMap["chanid"].toUInt()) &&
+ (infoMap["chanid"].toUInt() != orig_chanid))
+ {
+ GetNextProgramDB(direction, infoMap);
+ }
}
}
}
@@ -458,9 +564,6 @@ void TVBrowseHelper::run()
if (!m_ctx && !still_there)
continue;
- VERBOSE(VB_IMPORTANT, QString("browsechanid: %1 -> %2")
- .arg(m_chanid).arg(infoMap["chanid"].toUInt()));
-
m_channum = infoMap["channum"];
m_chanid = infoMap["chanid"].toUInt();
diff --git a/mythtv/libs/libmythtv/tvbrowsehelper.h b/mythtv/libs/libmythtv/tvbrowsehelper.h
index 0ab6b38..9e2b561 100644
--- a/mythtv/libs/libmythtv/tvbrowsehelper.h
+++ b/mythtv/libs/libmythtv/tvbrowsehelper.h
@@ -4,8 +4,10 @@
#define _TV_BROWSE_HELPER_H_
#include <QWaitCondition>
+#include <QMultiMap>
#include <QThread>
#include <QString>
+#include <QHash>
#include "dbchannelinfo.h" // for DBChanList
#include "programtypes.h" // for InfoMap
@@ -19,22 +21,43 @@ class BrowseInfo
{
public:
BrowseInfo(BrowseDirection dir) :
- m_dir(dir), m_chanid(0)
+ m_dir(dir), m_chanid(0), m_sourceid(0)
{
}
BrowseInfo(BrowseDirection dir,
const QString &channum,
uint chanid,
const QString &starttime) :
- m_dir(dir), m_channum(channum),
- m_chanid(0), m_starttime(starttime)
+ m_dir(dir), m_channum(channum),
+ m_chanid(chanid), m_starttime(starttime),
+ m_sourceid(0)
+ {
+ }
+ BrowseInfo(const QString &channum,
+ uint sourceid) :
+ m_dir(BROWSE_SAME), m_channum(channum),
+ m_chanid(0), m_sourceid(sourceid)
{
}
+ QString toString() const
+ {
+ return QString("%1;%2;%3;%4;%5")
+ .arg(BROWSE_SAME==m_dir?"SAME":
+ BROWSE_UP ==m_dir?"UP":
+ BROWSE_DOWN==m_dir?"DOWN":
+ QString::number(m_dir))
+ .arg(m_channum)
+ .arg(m_chanid)
+ .arg(m_starttime)
+ .arg(m_sourceid);
+ }
+
BrowseDirection m_dir;
QString m_channum;
uint m_chanid;
QString m_starttime;
+ uint m_sourceid;
};
@@ -82,15 +105,12 @@ class TVBrowseHelper : public QThread
BrowseDispInfo(ctx, bi);
}
- void BrowseChannel(PlayerContext *ctx, const QString &channum)
- {
- BrowseInfo bi(BROWSE_SAME, channum, 0, "");
- BrowseDispInfo(ctx, bi);
- }
+ void BrowseChannel(PlayerContext *ctx, const QString &channum);
BrowseInfo GetBrowsedInfo(void) const;
bool IsBrowsing(void) const;
- uint BrowseAllGetChanId(const QString &channum) const;
+ uint GetChanId(const QString &channum,
+ uint pref_cardid, uint pref_sourceid) const;
protected:
void GetNextProgram(BrowseDirection direction, InfoMap &infoMap) const;
@@ -99,12 +119,16 @@ class TVBrowseHelper : public QThread
virtual void run();
TV *m_tv;
- DBChanList db_browse_all_channels;
+ DBChanList db_all_channels;
+ DBChanList db_all_visible_channels;
QString db_time_format;
QString db_short_date_format;
uint db_browse_max_forward;
bool db_browse_all_tuners;
bool db_use_channel_groups;
+ QHash<uint,QString> db_chanid_to_channum;
+ QHash<uint,uint> db_chanid_to_sourceid;
+ QMultiMap<QString,uint> db_channum_to_chanids;
mutable QMutex m_lock; // protects variables below
PlayerContext *m_ctx;
diff --git a/mythtv/programs/mythfrontend/guidegrid.cpp b/mythtv/programs/mythfrontend/guidegrid.cpp
index 458ce40..e86ad5d 100644
--- a/mythtv/programs/mythfrontend/guidegrid.cpp
+++ b/mythtv/programs/mythfrontend/guidegrid.cpp
@@ -172,7 +172,8 @@ void GuideGrid::RunProgramGuide(uint chanid, const QString &channum,
changrpid = gCoreContext->GetNumSetting("ChannelGroupDefault", -1);
// check there are some channels setup
- DBChanList channels = ChannelUtil::GetChannels(0, true, "", changrpid);
+ DBChanList channels = ChannelUtil::GetChannels(
+ 0, true, "", (changrpid<0) ? 0 : changrpid);
if (!channels.size())
{
QString message;
@@ -832,7 +833,8 @@ void GuideGrid::fillChannelInfos(bool gotostartchannel)
m_channelInfoIdx.clear();
m_currentStartChannel = 0;
- DBChanList channels = ChannelUtil::GetChannels(0, true, "", m_changrpid);
+ DBChanList channels = ChannelUtil::GetChannels(
+ 0, true, "", (m_changrpid < 0) ? 0 : m_changrpid);
ChannelUtil::SortChannels(channels, m_channelOrdering, false);
typedef vector<uint> uint_list_t;