Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

epg: fix possible deadlock in CEpgInfoTag::Icon() and some other EPG …

…table related calls from CEpgInfoTag. closes #549
  • Loading branch information...
commit 74cc9dd66a8adc68206f9910df0fe32be4353dbe 1 parent 3a20345
@opdenkamp authored
View
10 xbmc/epg/Epg.cpp
@@ -332,7 +332,8 @@ void CEpg::AddEntry(const CEpgInfoTag &tag)
newTag = itr->second;
else
{
- newTag = new CEpgInfoTag(m_iEpgID, m_iPVRChannelNumber, m_iPVRChannelId, m_strName);
+ CPVRChannel *channel = Channel();
+ newTag = new CEpgInfoTag(this, m_iPVRChannelNumber, m_iPVRChannelId, m_strName, channel ? channel->IconPath() : StringUtils::EmptyString);
m_tags.insert(make_pair(tag.StartAsUTC(), newTag));
}
}
@@ -340,7 +341,7 @@ void CEpg::AddEntry(const CEpgInfoTag &tag)
if (newTag)
{
newTag->Update(tag);
- newTag->m_iEpgId = m_iEpgID;
+ newTag->m_epg = this;
newTag->m_iPVRChannelNumber = m_iPVRChannelNumber;
newTag->m_iPVRChannelID = m_iPVRChannelId;
newTag->m_strTableName = m_strName;
@@ -363,14 +364,15 @@ bool CEpg::UpdateEntry(const CEpgInfoTag &tag, bool bUpdateDatabase /* = false *
else
{
/* create a new tag if no tag with this ID exists */
- infoTag = new CEpgInfoTag(m_iEpgID, m_iPVRChannelNumber, m_iPVRChannelId, m_strName);
+ CPVRChannel *channel = Channel();
+ infoTag = new CEpgInfoTag(this, m_iPVRChannelNumber, m_iPVRChannelId, m_strName, channel ? channel->IconPath() : StringUtils::EmptyString);
infoTag->SetUniqueBroadcastID(tag.UniqueBroadcastID());
m_tags.insert(make_pair(tag.StartAsUTC(), infoTag));
bNewTag = true;
}
infoTag->Update(tag, bNewTag);
- infoTag->m_iEpgId = m_iEpgID;
+ infoTag->m_epg = this;
infoTag->m_iPVRChannelNumber = m_iPVRChannelNumber;
infoTag->m_iPVRChannelID = m_iPVRChannelId;
infoTag->m_strTableName = m_strName;
View
30 xbmc/epg/EpgInfoTag.cpp
@@ -35,7 +35,7 @@ using namespace std;
using namespace EPG;
using namespace PVR;
-CEpgInfoTag::CEpgInfoTag(int iEpgId /* = -1 */, int iPVRChannelNumber /* = -1 */, int iPVRChannelID /* = -1 */, const CStdString &strTableName /* = StringUtils::EmptyString */) :
+CEpgInfoTag::CEpgInfoTag(CEpg *epg /* = NULL */, int iPVRChannelNumber /* = -1 */, int iPVRChannelID /* = -1 */, const CStdString &strTableName /* = StringUtils::EmptyString */, const CStdString &strIconPath /* = StringUtils::EmptyString */) :
m_bNotify(false),
m_bChanged(false),
m_iBroadcastId(-1),
@@ -52,10 +52,10 @@ CEpgInfoTag::CEpgInfoTag(int iEpgId /* = -1 */, int iPVRChannelNumber /* = -1 */
m_strPlot(""),
m_strGenre(""),
m_strEpisodeName(""),
- m_strIconPath(""),
+ m_strIconPath(strIconPath),
m_strFileNameAndPath(""),
m_iTimerId(-1),
- m_iEpgId(iEpgId),
+ m_epg(epg),
m_iPVRChannelNumber(iPVRChannelNumber),
m_iPVRChannelID(iPVRChannelID),
m_strTableName(strTableName)
@@ -82,7 +82,7 @@ CEpgInfoTag::CEpgInfoTag(const EPG_TAG &data) :
m_strIconPath(""),
m_strFileNameAndPath(""),
m_iTimerId(-1),
- m_iEpgId(-1),
+ m_epg(NULL),
m_iPVRChannelNumber(-1),
m_iPVRChannelID(-1)
{
@@ -112,7 +112,7 @@ CEpgInfoTag::CEpgInfoTag(const CEpgInfoTag &tag) :
m_endTime(tag.m_endTime),
m_firstAired(tag.m_firstAired),
m_iTimerId(tag.m_iTimerId),
- m_iEpgId(tag.m_iEpgId),
+ m_epg(tag.m_epg),
m_iPVRChannelNumber(tag.m_iPVRChannelNumber),
m_iPVRChannelID(tag.m_iPVRChannelID),
m_strTableName(tag.m_strTableName)
@@ -191,7 +191,7 @@ CEpgInfoTag &CEpgInfoTag::operator =(const CEpgInfoTag &other)
m_firstAired = other.m_firstAired;
m_iTimerId = other.m_iTimerId;
m_timerStart = other.m_timerStart;
- m_iEpgId = other.m_iEpgId;
+ m_epg = other.m_epg;
m_iPVRChannelNumber = other.m_iPVRChannelNumber;
m_iPVRChannelID = other.m_iPVRChannelID;
m_strTableName = other.m_strTableName;
@@ -248,13 +248,11 @@ float CEpgInfoTag::ProgressPercentage(void) const
const CEpgInfoTag *CEpgInfoTag::GetNextEvent(void) const
{
- CSingleLock lock(m_critSection);
return GetTable()->GetNextEvent(*this);
}
const CEpgInfoTag *CEpgInfoTag::GetPreviousEvent(void) const
{
- CSingleLock lock(m_critSection);
return GetTable()->GetPreviousEvent(*this);
}
@@ -724,12 +722,9 @@ void CEpgInfoTag::SetIcon(const CStdString &strIconPath)
CStdString CEpgInfoTag::Icon(void) const
{
CStdString retVal;
- CEpg *epg = g_EpgContainer.GetById(m_iEpgId);
CSingleLock lock(m_critSection);
retVal = m_strIconPath;
- if (retVal.IsEmpty() && epg && epg->HasPVRChannel())
- retVal = epg->Channel()->IconPath();
return retVal;
}
@@ -874,7 +869,7 @@ bool CEpgInfoTag::Update(const CEpgInfoTag &tag, bool bUpdateBroadcastId /* = tr
m_iSeriesNumber != tag.m_iSeriesNumber ||
m_strEpisodeName != tag.m_strEpisodeName ||
m_iUniqueBroadcastID != tag.m_iUniqueBroadcastID ||
- m_iEpgId != tag.m_iEpgId ||
+ EpgID() != tag.EpgID() ||
m_iPVRChannelID != tag.m_iPVRChannelID ||
m_iPVRChannelNumber != tag.m_iPVRChannelNumber ||
m_strTableName != tag.m_strTableName ||
@@ -895,7 +890,7 @@ bool CEpgInfoTag::Update(const CEpgInfoTag &tag, bool bUpdateBroadcastId /* = tr
m_endTime = tag.m_endTime;
m_iGenreType = tag.m_iGenreType;
m_iGenreSubType = tag.m_iGenreSubType;
- m_iEpgId = tag.m_iEpgId;
+ m_epg = tag.m_epg;
m_iPVRChannelID = tag.m_iPVRChannelID;
m_iPVRChannelNumber = tag.m_iPVRChannelNumber;
m_strTableName = tag.m_strTableName;
@@ -962,7 +957,7 @@ void CEpgInfoTag::UpdatePath(void)
CStdString path;
{
CSingleLock lock(m_critSection);
- path.Format("pvr://guide/%04i/%s.epg", m_iEpgId, m_startTime.GetAsDBDateTime().c_str());
+ path.Format("pvr://guide/%04i/%s.epg", EpgID(), m_startTime.GetAsDBDateTime().c_str());
}
SetPath(path);
@@ -970,5 +965,10 @@ void CEpgInfoTag::UpdatePath(void)
const CEpg *CEpgInfoTag::GetTable() const
{
- return g_EpgContainer.GetById(m_iEpgId);
+ return m_epg;
+}
+
+const int CEpgInfoTag::EpgID(void) const
+{
+ return m_epg ? m_epg->EpgID() : -1;
}
View
6 xbmc/epg/EpgInfoTag.h
@@ -46,7 +46,7 @@ namespace EPG
/*!
* @brief Create a new empty event without a unique ID.
*/
- CEpgInfoTag(int iEpgId = -1, int iPVRChannelNumber = -1, int iPVRChannelID = -1, const CStdString &strTableName = StringUtils::EmptyString);
+ CEpgInfoTag(CEpg *epg = NULL, int iPVRChannelNumber = -1, int iPVRChannelID = -1, const CStdString &strTableName = StringUtils::EmptyString, const CStdString &strIconPath = StringUtils::EmptyString);
/*!
* @brief Create a new EPG infotag with 'data' as content.
@@ -114,7 +114,7 @@ namespace EPG
*/
virtual const CEpg *GetTable() const;
- virtual const int EpgID(void) const { return m_iEpgId; }
+ virtual const int EpgID(void) const;
/*!
* @brief Change the unique broadcast ID of this event.
@@ -459,7 +459,7 @@ namespace EPG
CDateTime m_timerStart; /*!< the start time of the timer (if any) */
int m_iTimerId; /*!< the id of the timer (if any) */
- int m_iEpgId; /*!< the ID of the schedule that this event belongs to */
+ CEpg * m_epg; /*!< the schedule that this event belongs to */
int m_iPVRChannelNumber; /*!< the channel number in the "all channels" group */
int m_iPVRChannelID; /*!< the ID of the PVR channel */
View
7 xbmc/pvr/channels/PVRChannel.cpp
@@ -174,13 +174,14 @@ bool CPVRChannel::Delete(void)
CEpg *CPVRChannel::GetEPG(void) const
{
- CEpg *epg(NULL);
+ int iEpgId(-1);
{
CSingleLock lock(m_critSection);
if (!m_bIsHidden && m_bEPGEnabled && m_iEpgId > 0)
- epg = g_EpgContainer.GetById(m_iEpgId);
+ iEpgId = m_iEpgId;
}
- return epg;
+
+ return iEpgId > 0 ? g_EpgContainer.GetById(iEpgId) : NULL;
}
bool CPVRChannel::UpdateFromClient(const CPVRChannel &channel)
View
8 xbmc/pvr/timers/PVRTimerInfoTag.cpp
@@ -382,7 +382,7 @@ void CPVRTimerInfoTag::UpdateEpgEvent(bool bClear /* = false */)
if (epgTag)
{
- m_iEpgId = epgTag->m_iEpgId;
+ m_iEpgId = epgTag->EpgID();
m_epgStart = epgTag->StartAsUTC();
m_strGenre = epgTag->Genre();
m_iGenreType = epgTag->GenreType();
@@ -425,10 +425,10 @@ void CPVRTimerInfoTag::SetEpgInfoTag(CEpgInfoTag *tag)
CSingleLock lock(m_critSection);
if (tag)
{
- if (m_iEpgId != tag->m_iEpgId || m_epgStart != tag->StartAsUTC())
+ if (m_iEpgId != tag->EpgID() || m_epgStart != tag->StartAsUTC())
{
CLog::Log(LOGINFO, "cPVRTimerInfoTag: timer %s set to epg event %s", m_strTitle.c_str(), tag->Title().c_str());
- m_iEpgId = tag->m_iEpgId;
+ m_iEpgId = tag->EpgID();
m_epgStart = tag->StartAsUTC();
}
}
@@ -541,7 +541,7 @@ CPVRTimerInfoTag *CPVRTimerInfoTag::CreateFromEpg(const CEpgInfoTag &tag)
newTag->m_strSummary = tag.Plot();
}
- newTag->m_iEpgId = tag.m_iEpgId;
+ newTag->m_iEpgId = tag.EpgID();
newTag->m_epgStart = tag.StartAsUTC();
/* unused only for reference */
View
4 xbmc/pvr/timers/PVRTimers.cpp
@@ -673,10 +673,10 @@ CPVRTimerInfoTag *CPVRTimers::GetMatch(const CEpgInfoTag *Epg)
{
CPVRTimerInfoTag *timer = it->second->at(iTimerPtr);
- if (!Epg || !Epg->GetTable() || !Epg->GetTable()->Channel())
+ const CPVRChannel *channel = Epg ? Epg->ChannelTag() : NULL;
+ if (!channel)
continue;
- const CPVRChannel *channel = Epg->GetTable()->Channel();
if (timer->ChannelNumber() != channel->ChannelNumber()
|| timer->m_bIsRadio != channel->IsRadio())
continue;
Please sign in to comment.
Something went wrong with that request. Please try again.