diff --git a/xbmc/epg/Epg.cpp b/xbmc/epg/Epg.cpp index 2888a6cc379cc..f2524ab213f60 100644 --- a/xbmc/epg/Epg.cpp +++ b/xbmc/epg/Epg.cpp @@ -686,6 +686,7 @@ const CDateTime &CEpg::GetLastDate(void) const bool CEpg::Update(const CEpg &epg, bool bUpdateDb /* = false */) { bool bReturn = true; + CSingleLock lock(m_critSection); m_strName = epg.m_strName; m_strScraperName = epg.m_strScraperName; diff --git a/xbmc/pvr/channels/PVRChannelGroup.cpp b/xbmc/pvr/channels/PVRChannelGroup.cpp index 0abd0ba483f72..06964a8de6ea3 100644 --- a/xbmc/pvr/channels/PVRChannelGroup.cpp +++ b/xbmc/pvr/channels/PVRChannelGroup.cpp @@ -297,6 +297,24 @@ const CPVRChannel *CPVRChannelGroup::GetByChannelID(int iChannelID) const return channel; } +const CPVRChannel *CPVRChannelGroup::GetByChannelEpgID(int iEpgID) const +{ + CPVRChannel *channel = NULL; + CSingleLock lock(m_critSection); + + for (unsigned int ptr = 0; ptr < size(); ptr++) + { + PVRChannelGroupMember groupMember = at(ptr); + if (groupMember.channel->EpgID() == iEpgID) + { + channel = groupMember.channel; + break; + } + } + + return channel; +} + const CPVRChannel *CPVRChannelGroup::GetByUniqueID(int iUniqueID) const { CPVRChannel *channel = NULL; diff --git a/xbmc/pvr/channels/PVRChannelGroup.h b/xbmc/pvr/channels/PVRChannelGroup.h index 37182b98442b6..160e5f776d8b8 100644 --- a/xbmc/pvr/channels/PVRChannelGroup.h +++ b/xbmc/pvr/channels/PVRChannelGroup.h @@ -298,6 +298,13 @@ namespace PVR */ virtual const CPVRChannel *GetByChannelID(int iChannelID) const; + /*! + * @brief Get a channel given it's EPG ID. + * @param iEpgID The channel EPG ID. + * @return The channel or NULL if it wasn't found. + */ + virtual const CPVRChannel *GetByChannelEpgID(int iEpgID) const; + /*! * @brief Get a channel given it's unique ID. * @param iUniqueID The unique ID. diff --git a/xbmc/pvr/channels/PVRChannelGroupsContainer.cpp b/xbmc/pvr/channels/PVRChannelGroupsContainer.cpp index 259e3a475a7ab..b537b10f30a11 100644 --- a/xbmc/pvr/channels/PVRChannelGroupsContainer.cpp +++ b/xbmc/pvr/channels/PVRChannelGroupsContainer.cpp @@ -134,6 +134,16 @@ const CPVRChannel *CPVRChannelGroupsContainer::GetChannelById(int iChannelId) co return channel; } +const CPVRChannel *CPVRChannelGroupsContainer::GetChannelByEpgId(int iEpgId) const +{ + const CPVRChannel *channel = m_groupsTV->GetGroupAll()->GetByChannelEpgID(iEpgId); + + if (!channel) + channel = m_groupsRadio->GetGroupAll()->GetByChannelEpgID(iEpgId); + + return channel; +} + bool CPVRChannelGroupsContainer::GetGroupsDirectory(const CStdString &strBase, CFileItemList *results, bool bRadio) { const CPVRChannelGroups *channelGroups = Get(bRadio); diff --git a/xbmc/pvr/channels/PVRChannelGroupsContainer.h b/xbmc/pvr/channels/PVRChannelGroupsContainer.h index eeb7a3b969e56..13f60960632b7 100644 --- a/xbmc/pvr/channels/PVRChannelGroupsContainer.h +++ b/xbmc/pvr/channels/PVRChannelGroupsContainer.h @@ -131,6 +131,13 @@ namespace PVR */ const CPVRChannel *GetChannelById(int iChannelId) const; + /*! + * @brief Get a channel given it's EPG ID. + * @param iEpgId The EPG ID of the channel. + * @return The channel or NULL if it wasn't found. + */ + const CPVRChannel *GetChannelByEpgId(int iEpgId) const; + /*! * @brief Get the groups list for a directory. * @param strBase The directory path. diff --git a/xbmc/pvr/epg/PVREpgContainer.cpp b/xbmc/pvr/epg/PVREpgContainer.cpp index 0f19c2128688d..2ba7519e3d2d7 100644 --- a/xbmc/pvr/epg/PVREpgContainer.cpp +++ b/xbmc/pvr/epg/PVREpgContainer.cpp @@ -79,7 +79,7 @@ bool PVR::CPVREpgContainer::AutoCreateTablesHook(void) CEpg* PVR::CPVREpgContainer::CreateEpg(int iEpgId) { - CPVRChannel *channel = (CPVRChannel *) g_PVRChannelGroups->GetChannelById(iEpgId); + CPVRChannel *channel = (CPVRChannel *) g_PVRChannelGroups->GetChannelByEpgId(iEpgId); if (channel) { return new CPVREpg(channel, false);