2 * Copyright (C) 2017-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
9 #include "RetroPlayerAutoSave.h"
12 #include "games/GameSettings.h"
13 #include "utils/log.h"
16 using namespace RETRO
;
17 using namespace std::chrono_literals
;
21 constexpr auto AUTOSAVE_DURATION_SECS
= 10s
; // Auto-save every 10 seconds
24 CRetroPlayerAutoSave::CRetroPlayerAutoSave(IAutoSaveCallback
& callback
,
25 GAME::CGameSettings
& settings
)
26 : CThread("CRetroPlayerAutoSave"), m_callback(callback
), m_settings(settings
)
28 CLog::Log(LOGDEBUG
, "RetroPlayer[SAVE]: Initializing autosave");
33 CRetroPlayerAutoSave::~CRetroPlayerAutoSave()
35 CLog::Log(LOGDEBUG
, "RetroPlayer[SAVE]: Deinitializing autosave");
40 void CRetroPlayerAutoSave::Process()
42 CLog::Log(LOGDEBUG
, "RetroPlayer[SAVE]: Autosave thread started");
46 CThread::Sleep(AUTOSAVE_DURATION_SECS
);
51 if (!m_settings
.AutosaveEnabled())
54 if (m_callback
.IsAutoSaveEnabled())
56 std::string savePath
= m_callback
.CreateAutosave();
57 if (!savePath
.empty())
58 CLog::Log(LOGDEBUG
, "RetroPlayer[SAVE]: Saved state to {}", CURL::GetRedacted(savePath
));
62 CLog::Log(LOGDEBUG
, "RetroPlayer[SAVE]: Autosave thread ended");