Skip to content
Browse files

Merge pull request #4541 from xhaggi/continue-last-channel-on-wakeup

[pvr] continue last played channel on wake up
  • Loading branch information...
2 parents a0b7ae4 + ed7d7de commit 502f150d11d54461bcffadac43540ed9f27adff0 @t-nelson t-nelson committed Apr 10, 2014
Showing with 28 additions and 12 deletions.
  1. +24 −11 xbmc/pvr/PVRManager.cpp
  2. +4 −1 xbmc/pvr/PVRManager.h
View
35 xbmc/pvr/PVRManager.cpp
@@ -42,6 +42,7 @@
#include "threads/Atomics.h"
#include "windows/GUIWindowPVRCommon.h"
#include "utils/JobManager.h"
+#include "interfaces/AnnouncementManager.h"
#include "PVRManager.h"
#include "PVRDatabase.h"
@@ -62,6 +63,7 @@ using namespace std;
using namespace MUSIC_INFO;
using namespace PVR;
using namespace EPG;
+using namespace ANNOUNCEMENT;
CPVRManager::CPVRManager(void) :
CThread("PVRManager"),
@@ -79,15 +81,26 @@ CPVRManager::CPVRManager(void) :
m_managerState(ManagerStateStopped),
m_bOpenPVRWindow(false)
{
+ CAnnouncementManager::AddAnnouncer(this);
ResetProperties();
}
CPVRManager::~CPVRManager(void)
{
+ CAnnouncementManager::RemoveAnnouncer(this);
Stop();
CLog::Log(LOGDEBUG,"PVRManager - destroyed");
}
+void CPVRManager::Announce(AnnouncementFlag flag, const char *sender, const char *message, const CVariant &data)
+{
+ if (!IsStarted() || (flag & (System)) == 0)
+ return;
+
+ if (strcmp(message, "OnWake") == 0)
+ ContinueLastChannel();
+}
+
CPVRManager &CPVRManager::Get(void)
{
static CPVRManager pvrManagerInstance;
@@ -437,9 +450,14 @@ void CPVRManager::Process(void)
while (IsStarted() && m_addons && m_addons->HasConnectedClients() && !bRestart)
{
/* continue last watched channel after first startup */
- if (m_bFirstStart && CSettings::Get().GetInt("pvrplayback.startlast") != START_LAST_CHANNEL_OFF)
+ if (m_bFirstStart)
+ {
+ {
+ CSingleLock lock(m_critSection);
+ m_bFirstStart = false;
+ }
ContinueLastChannel();
-
+ }
/* execute the next pending jobs if there are any */
try
{
@@ -638,22 +656,17 @@ bool CPVRManager::ChannelUpDown(unsigned int *iNewChannelNumber, bool bPreview,
bool CPVRManager::ContinueLastChannel(void)
{
- {
- CSingleLock lock(m_critSection);
- if (!m_bFirstStart)
- return true;
- m_bFirstStart = false;
- }
+ if (CSettings::Get().GetInt("pvrplayback.startlast") == START_LAST_CHANNEL_OFF)
+ return false;
- bool bReturn(false);
CFileItemPtr channel = m_channelGroups->GetLastPlayedChannel();
if (channel && channel->HasPVRChannelInfoTag())
{
CLog::Log(LOGNOTICE, "PVRManager - %s - continue playback on channel '%s'", __FUNCTION__, channel->GetPVRChannelInfoTag()->ChannelName().c_str());
- bReturn = StartPlayback(channel->GetPVRChannelInfoTag(), (CSettings::Get().GetInt("pvrplayback.startlast") == START_LAST_CHANNEL_MIN));
+ return StartPlayback(channel->GetPVRChannelInfoTag(), (CSettings::Get().GetInt("pvrplayback.startlast") == START_LAST_CHANNEL_MIN));
}
- return bReturn;
+ return false;
}
void CPVRManager::ResetDatabase(bool bResetEPGOnly /* = false */)
View
5 xbmc/pvr/PVRManager.h
@@ -27,6 +27,7 @@
#include "threads/Thread.h"
#include "utils/JobManager.h"
#include "utils/Observer.h"
+#include "interfaces/IAnnouncer.h"
class CGUIDialogProgressBarHandle;
class CStopWatch;
@@ -84,7 +85,7 @@ namespace PVR
typedef boost::shared_ptr<PVR::CPVRChannelGroup> CPVRChannelGroupPtr;
- class CPVRManager : public ISettingCallback, private CThread, public Observable
+ class CPVRManager : public ISettingCallback, private CThread, public Observable, public ANNOUNCEMENT::IAnnouncer
{
friend class CPVRClients;
@@ -100,6 +101,8 @@ namespace PVR
*/
virtual ~CPVRManager(void);
+ virtual void Announce(ANNOUNCEMENT::AnnouncementFlag flag, const char *sender, const char *message, const CVariant &data);
+
/*!
* @brief Get the instance of the PVRManager.
* @return The PVRManager instance.

0 comments on commit 502f150

Please sign in to comment.
Something went wrong with that request. Please try again.