Skip to content
This repository has been archived by the owner on Apr 15, 2023. It is now read-only.

Commit

Permalink
Merge pull request #103
Browse files Browse the repository at this point in the history
  • Loading branch information
opdenkamp committed May 17, 2011
2 parents 0a21c46 + 0f862bb commit d4b1ef8
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 22 deletions.
22 changes: 11 additions & 11 deletions xbmc/Application.cpp
Expand Up @@ -3623,10 +3623,7 @@ bool CApplication::PlayFile(const CFileItem& item, bool bRestart)

OutputDebugString("new file set audiostream:0\n");
// Switch to default options
// PVR channel settings are stored later
// default settings would overwrite changed settings for pvr channels
if (!item.IsPVR())
g_settings.m_currentVideoSettings = g_settings.m_defaultVideoSettings;
g_settings.m_currentVideoSettings = g_settings.m_defaultVideoSettings;
// see if we have saved options in the database

m_iPlaySpeed = 1;
Expand Down Expand Up @@ -4158,12 +4155,15 @@ bool CApplication::IsPlayingFullScreenVideo() const

void CApplication::SaveFileState()
{
if (!g_settings.GetCurrentProfile().canWriteDatabases())
return;
CJob* job = new CSaveFileStateJob(*m_progressTrackingItem,
m_progressTrackingVideoResumeBookmark,
m_progressTrackingPlayCountUpdate);
CJobManager::GetInstance().AddJob(job, NULL);
if (!m_progressTrackingItem->IsPVRChannel())
{
if (!g_settings.GetCurrentProfile().canWriteDatabases())
return;
CJob* job = new CSaveFileStateJob(*m_progressTrackingItem,
m_progressTrackingVideoResumeBookmark,
m_progressTrackingPlayCountUpdate);
CJobManager::GetInstance().AddJob(job, NULL);
}
}

void CApplication::UpdateFileState()
Expand Down Expand Up @@ -5426,7 +5426,7 @@ bool CApplication::ProcessAndStartPlaylist(const CStdString& strPlayList, CPlayL
void CApplication::SaveCurrentFileSettings()
{
// don't store settings for PVR in video database
if (m_itemCurrentFile->IsVideo() && !m_itemCurrentFile->IsPVR())
if (m_itemCurrentFile->IsVideo() && !m_itemCurrentFile->IsPVRChannel())
{
// save video settings
if (g_settings.m_currentVideoSettings != g_settings.m_defaultVideoSettings)
Expand Down
27 changes: 23 additions & 4 deletions xbmc/pvr/PVRManager.cpp
Expand Up @@ -553,6 +553,8 @@ bool CPVRManager::StartRecordingOnPlayingChannel(bool bOnOff)

void CPVRManager::SaveCurrentChannelSettings(void)
{
CSingleLock lock(m_critSection);

CPVRChannel channel;
if (!m_addons->GetPlayingChannel(&channel))
return;
Expand Down Expand Up @@ -714,6 +716,12 @@ bool CPVRChannelGroupsUpdateJob::DoWork(void)
return g_PVRChannelGroups->Update(false);
}

bool CPVRChannelSettingsSaveJob::DoWork(void)
{
g_PVRManager.SaveCurrentChannelSettings();
return true;
}

bool CPVRManager::OpenLiveStream(const CPVRChannel &tag)
{
bool bReturn = false;
Expand Down Expand Up @@ -766,9 +774,6 @@ void CPVRManager::CloseStream(void)
time_t tNow;
CDateTime::GetCurrentDateTime().GetAsTime(tNow);
channel.SetLastWatched(tNow, true);

/* Store current settings inside Database */
SaveCurrentChannelSettings();
}
}

Expand Down Expand Up @@ -879,7 +884,6 @@ bool CPVRManager::PerformChannelSwitch(const CPVRChannel &channel, bool bPreview
CLog::Log(LOGDEBUG, "PVRManager - %s - switching to channel '%s'",
__FUNCTION__, channel.ChannelName().c_str());

SaveCurrentChannelSettings();
if (m_currentFile)
{
delete m_currentFile;
Expand Down Expand Up @@ -1068,6 +1072,21 @@ void CPVRManager::TriggerChannelGroupsUpdate(void)
SetEvent(m_triggerEvent);
}

void CPVRManager::TriggerSaveChannelSettings(void)
{
CSingleLock lock(m_critSectionTriggers);
if (!m_bLoaded)
return;

if (IsJobPending("pvr-save-channelsettings"))
return;

m_pendingUpdates.push_back(new CPVRChannelSettingsSaveJob());

lock.Leave();
SetEvent(m_triggerEvent);
}

void CPVRManager::ExecutePendingJobs(void)
{
CSingleLock lock(m_critSectionTriggers);
Expand Down
25 changes: 20 additions & 5 deletions xbmc/pvr/PVRManager.h
Expand Up @@ -283,6 +283,11 @@ namespace PVR
*/
void TriggerChannelGroupsUpdate(void);

/*!
* @brief Let the background thread save the current video settings.
*/
void TriggerSaveChannelSettings(void);

/*!
* @brief Update the channel that is currently active.
* @param item The new channel.
Expand Down Expand Up @@ -391,6 +396,11 @@ namespace PVR
*/
bool IsSelectedGroup(const CPVRChannelGroup &group) const;

/*!
* @brief Persist the current channel settings in the database.
*/
void SaveCurrentChannelSettings(void);

protected:
/*!
* @brief PVR update and control thread.
Expand Down Expand Up @@ -481,11 +491,6 @@ namespace PVR
*/
bool StartUpdateThreads(void);

/*!
* @brief Persist the current channel settings in the database.
*/
void SaveCurrentChannelSettings(void);

/*!
* @brief Load the settings for the current channel from the database.
*/
Expand Down Expand Up @@ -575,4 +580,14 @@ namespace PVR

virtual bool DoWork();
};

class CPVRChannelSettingsSaveJob : public CJob
{
public:
CPVRChannelSettingsSaveJob(void) {}
virtual ~CPVRChannelSettingsSaveJob() {}
virtual const char *GetType() const { return "pvr-save-channelsettings"; }

virtual bool DoWork();
};
}
3 changes: 1 addition & 2 deletions xbmc/utils/SaveFileStateJob.h
Expand Up @@ -30,8 +30,7 @@ bool CSaveFileStateJob::DoWork()

if (progressTrackingFile != "")
{
// do not store PVR settings in video database
if (m_item.IsVideo() && !m_item.IsPVR())
if (m_item.IsVideo())
{
CLog::Log(LOGDEBUG, "%s - Saving file state for video item %s", __FUNCTION__, progressTrackingFile.c_str());

Expand Down
4 changes: 4 additions & 0 deletions xbmc/video/dialogs/GUIDialogVideoSettings.cpp
Expand Up @@ -33,8 +33,10 @@
#include "dialogs/GUIDialogYesNo.h"
#include "settings/Settings.h"
#include "addons/Skin.h"
#include "pvr/PVRManager.h"

using namespace std;
using namespace PVR;

CGUIDialogVideoSettings::CGUIDialogVideoSettings(void)
: CGUIDialogSettings(WINDOW_DIALOG_VIDEO_OSD_SETTINGS, "VideoOSDSettings.xml")
Expand Down Expand Up @@ -213,6 +215,8 @@ void CGUIDialogVideoSettings::OnSettingChanged(SettingInfo &setting)
g_settings.Save();
}
}

g_PVRManager.TriggerSaveChannelSettings();
}

CStdString CGUIDialogVideoSettings::FormatInteger(float value, float minimum)
Expand Down

0 comments on commit d4b1ef8

Please sign in to comment.