Permalink
Browse files

Merge pull request #745 from arnova/filestate

changed: Save (video) file state on shutdown
  • Loading branch information...
2 parents 94330dc + 1805b9b commit 6147e6a889db5076e4cfad3d23105f861f2439bf @arnova arnova committed May 1, 2012
Showing with 22 additions and 6 deletions.
  1. +20 −5 xbmc/Application.cpp
  2. +1 −1 xbmc/Application.h
  3. +1 −0 xbmc/powermanagement/PowerManager.cpp
View
@@ -3326,6 +3326,8 @@ void CApplication::Stop(int exitCode)
CVariant vExitCode(exitCode);
CAnnouncementManager::Announce(System, "xbmc", "OnQuit", vExitCode);
+ SaveFileState(true);
+
// cancel any jobs from the jobmanager
CJobManager::GetInstance().CancelJobs();
@@ -4234,14 +4236,27 @@ bool CApplication::IsFullScreen()
g_windowManager.GetActiveWindow() == WINDOW_SLIDESHOW;
}
-void CApplication::SaveFileState()
+void CApplication::SaveFileState(bool bForeground /* = false */)
{
if (!g_settings.GetCurrentProfile().canWriteDatabases())
return;
- CJob* job = new CSaveFileStateJob(*m_progressTrackingItem,
- m_progressTrackingVideoResumeBookmark,
- m_progressTrackingPlayCountUpdate);
- CJobManager::GetInstance().AddJob(job, NULL);
+
+ if (bForeground)
+ {
+ CSaveFileStateJob job(*m_progressTrackingItem,
+ m_progressTrackingVideoResumeBookmark,
+ m_progressTrackingPlayCountUpdate);
+
+ // Run job in the foreground to make sure it finishes
+ job.DoWork();
+ }
+ else
+ {
+ CJob* job = new CSaveFileStateJob(*m_progressTrackingItem,
+ m_progressTrackingVideoResumeBookmark,
+ m_progressTrackingPlayCountUpdate);
+ CJobManager::GetInstance().AddJob(job, NULL);
+ }
}
void CApplication::UpdateFileState()
View
@@ -151,7 +151,7 @@ class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMs
bool PlayMediaSync(const CFileItem& item, int iPlaylist = PLAYLIST_MUSIC);
bool ProcessAndStartPlaylist(const CStdString& strPlayList, PLAYLIST::CPlayList& playlist, int iPlaylist, int track=0);
bool PlayFile(const CFileItem& item, bool bRestart = false);
- void SaveFileState();
+ void SaveFileState(bool bForeground = false);
void UpdateFileState();
void StopPlaying();
void Restart(bool bSamePosition = true);
@@ -193,6 +193,7 @@ void CPowerManager::OnSleep()
CBuiltins::Execute("LIRC.Stop");
#endif
+ g_application.SaveFileState(true);
g_application.StopPlaying();
g_application.StopShutdownTimer();
g_application.StopScreenSaverTimer();

0 comments on commit 6147e6a

Please sign in to comment.