aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xbmc/pvr/PVRManager.cpp6
-rw-r--r--xbmc/pvr/channels/PVRChannelGroup.cpp30
-rw-r--r--xbmc/pvr/channels/PVRChannelGroup.h2
3 files changed, 13 insertions, 25 deletions
diff --git a/xbmc/pvr/PVRManager.cpp b/xbmc/pvr/PVRManager.cpp
index c60bb27c87..9781603134 100644
--- a/xbmc/pvr/PVRManager.cpp
+++ b/xbmc/pvr/PVRManager.cpp
@@ -1577,8 +1577,10 @@ void CPVRManager::UpdateLastWatched(CPVRChannel &channel)
CDateTime::GetCurrentDateTime().GetAsTime(tNow);
// update last watched timestamp for channel
- channel.SetLastWatched(tNow);
- channel.Persist();
+ // NOTE: method could be called with a fileitem copy as argument so we need to obtain the right channel instance
+ CPVRChannelPtr channelPtr = m_channelGroups->GetChannelById(channel.ChannelID());
+ channelPtr->SetLastWatched(tNow);
+ channelPtr->Persist();
// update last watched timestamp for group
CPVRChannelGroupPtr group = GetPlayingGroup(channel.IsRadio());
diff --git a/xbmc/pvr/channels/PVRChannelGroup.cpp b/xbmc/pvr/channels/PVRChannelGroup.cpp
index a10e2ece59..c021ef43e7 100644
--- a/xbmc/pvr/channels/PVRChannelGroup.cpp
+++ b/xbmc/pvr/channels/PVRChannelGroup.cpp
@@ -428,34 +428,20 @@ CPVRChannelPtr CPVRChannelGroup::GetByUniqueID(int iUniqueID) const
return empty;
}
-CFileItemPtr CPVRChannelGroup::GetLastPlayedChannel(unsigned int iCurrentChannel /* = -1 */) const
+CFileItemPtr CPVRChannelGroup::GetLastPlayedChannel(int iCurrentChannel /* = -1 */) const
{
CSingleLock lock(m_critSection);
- time_t tCurrentLastWatched(0), tMaxLastWatched(0);
- if (iCurrentChannel > 0)
- {
- CPVRChannelPtr channel = GetByChannelID(iCurrentChannel);
- if (channel.get())
- {
- CDateTime::GetCurrentDateTime().GetAsTime(tMaxLastWatched);
- channel->SetLastWatched(tMaxLastWatched);
- channel->Persist();
- }
- }
-
CPVRChannelPtr returnChannel;
- for (unsigned int iChannelPtr = 0; iChannelPtr < m_members.size(); iChannelPtr++)
+ for (std::vector<PVRChannelGroupMember>::const_iterator it = m_members.begin(); it != m_members.end(); ++it)
{
- PVRChannelGroupMember groupMember = m_members.at(iChannelPtr);
-
- if (g_PVRClients->IsConnectedClient(groupMember.channel->ClientID()) &&
- groupMember.channel->LastWatched() > 0 &&
- (tMaxLastWatched == 0 || groupMember.channel->LastWatched() < tMaxLastWatched) &&
- (tCurrentLastWatched == 0 || groupMember.channel->LastWatched() > tCurrentLastWatched))
+ CPVRChannelPtr channel = (*it).channel;
+ if (channel->ChannelID() != iCurrentChannel &&
+ g_PVRClients->IsConnectedClient(channel->ClientID()) &&
+ channel->LastWatched() > 0 &&
+ (!returnChannel || channel->LastWatched() > returnChannel->LastWatched()))
{
- returnChannel = groupMember.channel;
- tCurrentLastWatched = returnChannel->LastWatched();
+ returnChannel = channel;
}
}
diff --git a/xbmc/pvr/channels/PVRChannelGroup.h b/xbmc/pvr/channels/PVRChannelGroup.h
index da88c0579c..80b6d55ddc 100644
--- a/xbmc/pvr/channels/PVRChannelGroup.h
+++ b/xbmc/pvr/channels/PVRChannelGroup.h
@@ -267,7 +267,7 @@ namespace PVR
* @param iCurrentChannel The channelid of the current channel that is playing, or -1 if none
* @return The requested channel.
*/
- CFileItemPtr GetLastPlayedChannel(unsigned int iCurrentChannel = -1) const;
+ CFileItemPtr GetLastPlayedChannel(int iCurrentChannel = -1) const;
/*!
* @brief Get a channel given it's channel number.