Skip to content

Commit

Permalink
[pvr] fixed possible deadlock in CPVRChannel::UpdatePath()
Browse files Browse the repository at this point in the history
  • Loading branch information
opdenkamp committed Oct 27, 2012
1 parent af69d7f commit 0a53673
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
19 changes: 8 additions & 11 deletions xbmc/pvr/channels/PVRChannel.cpp
Expand Up @@ -27,7 +27,7 @@
#include "utils/StringUtils.h"
#include "threads/SingleLock.h"

#include "PVRChannelGroupsContainer.h"
#include "pvr/channels/PVRChannelGroupInternal.h"
#include "epg/EpgContainer.h"
#include "pvr/timers/PVRTimers.h"
#include "pvr/PVRDatabase.h"
Expand Down Expand Up @@ -492,20 +492,17 @@ bool CPVRChannel::SetStreamURL(const CStdString &strStreamURL)
return false;
}

void CPVRChannel::UpdatePath(unsigned int iNewChannelNumber)
void CPVRChannel::UpdatePath(CPVRChannelGroupInternal* group, unsigned int iNewChannelGroupPosition)
{
if (!group) return;

CStdString strFileNameAndPath;
CSingleLock lock(m_critSection);
CPVRChannelGroupPtr group = g_PVRChannelGroups->GetGroupAll(m_bIsRadio);

if (group)
strFileNameAndPath.Format("pvr://channels/%s/%s/%i.pvr", (m_bIsRadio ? "radio" : "tv"), group->GroupName().c_str(), iNewChannelGroupPosition);
if (m_strFileNameAndPath != strFileNameAndPath)
{
strFileNameAndPath.Format("pvr://channels/%s/%s/%i.pvr", (m_bIsRadio ? "radio" : "tv"), group->GroupName().c_str(), iNewChannelNumber);
if (m_strFileNameAndPath != strFileNameAndPath)
{
m_strFileNameAndPath = strFileNameAndPath;
SetChanged();
}
m_strFileNameAndPath = strFileNameAndPath;
SetChanged();
}
}

Expand Down
4 changes: 3 additions & 1 deletion xbmc/pvr/channels/PVRChannel.h
Expand Up @@ -324,8 +324,10 @@ namespace PVR

/*!
* @brief Update the path after the channel number in the internal group changed.
* @param group The internal group that contains this channel
* @param iNewChannelGroupPosition The new channel number in the group
*/
void UpdatePath(unsigned int iNewChannelNumber);
void UpdatePath(CPVRChannelGroupInternal* group, unsigned int iNewChannelGroupPosition);

/*!
* @brief Return true if this channel is encrypted.
Expand Down
4 changes: 2 additions & 2 deletions xbmc/pvr/channels/PVRChannelGroupInternal.cpp
Expand Up @@ -82,7 +82,7 @@ void CPVRChannelGroupInternal::UpdateChannelPaths(void)
for (unsigned int iChannelPtr = 0; iChannelPtr < m_members.size(); iChannelPtr++)
{
PVRChannelGroupMember member = m_members.at(iChannelPtr);
member.channel->UpdatePath(iChannelPtr);
member.channel->UpdatePath(this, iChannelPtr);
}
}

Expand Down Expand Up @@ -260,7 +260,7 @@ bool CPVRChannelGroupInternal::Renumber(void)
if (m_members.at(iChannelPtr).channel->IsHidden())
m_iHiddenChannels++;
else
m_members.at(iChannelPtr).channel->UpdatePath(iChannelPtr);
m_members.at(iChannelPtr).channel->UpdatePath(this, iChannelPtr);
}

return bReturn;
Expand Down

0 comments on commit 0a53673

Please sign in to comment.