Skip to content

Commit

Permalink
Merge pull request #5376 from xhaggi/pvr-fix-internal-group-loading
Browse files Browse the repository at this point in the history
[pvr] fix internal group loading
  • Loading branch information
xhaggi committed Sep 21, 2014
2 parents 90e3fb2 + bd57173 commit fa8281b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion xbmc/pvr/PVRDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ int CPVRDatabase::Get(CPVRChannelGroupInternal &results)
"channels.iClientChannelNumber, channels.iClientSubChannelNumber, channels.sInputFormat, channels.sInputFormat, channels.sStreamURL, channels.iEncryptionSystem, map_channelgroups_channels.iChannelNumber, channels.idEpg "
"FROM map_channelgroups_channels "
"LEFT JOIN channels ON channels.idChannel = map_channelgroups_channels.idChannel "
"WHERE map_channelgroups_channels.idGroup = %u", results.IsRadio() ? XBMC_INTERNAL_GROUP_RADIO : XBMC_INTERNAL_GROUP_TV);
"WHERE map_channelgroups_channels.idGroup = %u", results.IsRadio() ? PVR_INTERNAL_GROUP_ID_RADIO : PVR_INTERNAL_GROUP_ID_TV);
if (ResultQuery(strQuery))
{
try
Expand Down
4 changes: 2 additions & 2 deletions xbmc/pvr/channels/PVRChannelGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ namespace EPG

namespace PVR
{
#define XBMC_INTERNAL_GROUP_RADIO 1
#define XBMC_INTERNAL_GROUP_TV 2
#define PVR_INTERNAL_GROUP_ID_RADIO 1
#define PVR_INTERNAL_GROUP_ID_TV 2

#define PVR_GROUP_TYPE_DEFAULT 0
#define PVR_GROUP_TYPE_INTERNAL 1
Expand Down
2 changes: 1 addition & 1 deletion xbmc/pvr/channels/PVRChannelGroupInternal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ using namespace PVR;
using namespace EPG;

CPVRChannelGroupInternal::CPVRChannelGroupInternal(bool bRadio) :
CPVRChannelGroup(bRadio, bRadio ? XBMC_INTERNAL_GROUP_RADIO : XBMC_INTERNAL_GROUP_TV, g_localizeStrings.Get(19287))
CPVRChannelGroup(bRadio, bRadio ? PVR_INTERNAL_GROUP_ID_RADIO : PVR_INTERNAL_GROUP_ID_TV, g_localizeStrings.Get(19287))
{
m_iHiddenChannels = 0;
m_iGroupType = PVR_GROUP_TYPE_INTERNAL;
Expand Down
31 changes: 16 additions & 15 deletions xbmc/pvr/channels/PVRChannelGroups.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,21 +216,12 @@ bool CPVRChannelGroups::UpdateGroupsEntries(const CPVRChannelGroups &groups)

bool CPVRChannelGroups::LoadUserDefinedChannelGroups(void)
{
CPVRDatabase *database = GetPVRDatabase();
if (!database)
return false;

bool bSyncWithBackends = CSettings::Get().GetBool("pvrmanager.syncchannelgroups");

CSingleLock lock(m_critSection);

// load the other groups from the database
int iSize = m_groups.size();
database->Get(*this);
CLog::Log(LOGDEBUG, "PVR - %s - %d user defined %s channel groups fetched from the database", __FUNCTION__, (int) (m_groups.size() - iSize), m_bRadio ? "radio" : "TV");

// load groups from the backends if the option is enabled
iSize = m_groups.size();
int iSize = m_groups.size();
if (bSyncWithBackends)
{
GetGroupsFromClients();
Expand Down Expand Up @@ -271,17 +262,27 @@ bool CPVRChannelGroups::LoadUserDefinedChannelGroups(void)

bool CPVRChannelGroups::Load(void)
{
CPVRDatabase *database = GetPVRDatabase();
if (!database)
return false;

CSingleLock lock(m_critSection);

// remove previous contents
Clear();

CLog::Log(LOGDEBUG, "PVR - %s - loading all %s channel groups", __FUNCTION__, m_bRadio ? "radio" : "TV");

// create and load the internal channel group
CPVRChannelGroupPtr internalChannels = CPVRChannelGroupPtr(new CPVRChannelGroupInternal(m_bRadio));
m_groups.push_back(internalChannels);
if (!internalChannels->Load())
// create the internal channel group
CPVRChannelGroupPtr internalGroup = CPVRChannelGroupPtr(new CPVRChannelGroupInternal(m_bRadio));
m_groups.push_back(internalGroup);

// load groups from the database
database->Get(*this);
CLog::Log(LOGDEBUG, "PVR - %s - %d %s groups fetched from the database", __FUNCTION__, m_groups.size(), m_bRadio ? "radio" : "TV");

// load channels of internal group
if (!internalGroup->Load())
{
CLog::Log(LOGERROR, "PVR - %s - failed to load channels", __FUNCTION__);
return false;
Expand All @@ -296,7 +297,7 @@ bool CPVRChannelGroups::Load(void)

// set the last played group as selected group at startup
CPVRChannelGroupPtr lastPlayedGroup = GetLastPlayedGroup();
SetSelectedGroup(lastPlayedGroup ? lastPlayedGroup : internalChannels);
SetSelectedGroup(lastPlayedGroup ? lastPlayedGroup : internalGroup);

CLog::Log(LOGDEBUG, "PVR - %s - %d %s channel groups loaded", __FUNCTION__, (int) m_groups.size(), m_bRadio ? "radio" : "TV");

Expand Down
2 changes: 1 addition & 1 deletion xbmc/pvr/windows/GUIWindowPVRBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ bool CGUIWindowPVRBase::Update(const std::string &strDirectory, bool updateFilte
void CGUIWindowPVRBase::UpdateButtons(void)
{
CGUIMediaWindow::UpdateButtons();
SET_CONTROL_LABEL(CONTROL_BTNCHANNELGROUPS, g_localizeStrings.Get(19141) + ": " + (m_group->GroupType() == PVR_GROUP_TYPE_INTERNAL ? g_localizeStrings.Get(19287) : m_group->GroupName()));
SET_CONTROL_LABEL(CONTROL_BTNCHANNELGROUPS, g_localizeStrings.Get(19141) + ": " + m_group->GroupName());
}

void CGUIWindowPVRBase::UpdateSelectedItemPath()
Expand Down

0 comments on commit fa8281b

Please sign in to comment.