even with 0646c9a

This commit is contained in:
R2DLiu 2020-08-22 10:43:34 -04:00
commit 9a4d2799d4
4 changed files with 36 additions and 15 deletions

View file

@ -1180,12 +1180,12 @@ void CEXISlippi::prepareFrameData(u8* payload)
{
if (frameIndex < watchSettings.startFrame)
{
g_playbackStatus->isHardFFW = true;
g_playbackStatus->setHardFFW(true);
}
else if (frameIndex == watchSettings.startFrame)
{
// TODO: This might disable fast forward on first frame when we dont want to?
g_playbackStatus->isHardFFW = false;
g_playbackStatus->setHardFFW(false);
}
}
@ -1193,7 +1193,8 @@ void CEXISlippi::prepareFrameData(u8* payload)
if (commSettings.rollbackDisplayMethod == "normal")
{
auto nextFrame = m_current_game->GetFrameAt(frameSeqIdx);
g_playbackStatus->isHardFFW = nextFrame && nextFrame->frame <= g_playbackStatus->currentPlaybackFrame;
bool shouldHardFFW = nextFrame && nextFrame->frame <= g_playbackStatus->currentPlaybackFrame;
g_playbackStatus->setHardFFW(shouldHardFFW);
if (nextFrame)
{
@ -1224,7 +1225,7 @@ void CEXISlippi::prepareFrameData(u8* payload)
// last frame instead of the frame previous to fast forwarding.
// Not sure if this fully works with partial frames
g_playbackStatus->isSoftFFW = false;
g_playbackStatus->isHardFFW = false;
g_playbackStatus->setHardFFW(false);
}
bool shouldFFW = g_playbackStatus->shouldFFWFrame(frameIndex);
@ -1240,7 +1241,7 @@ void CEXISlippi::prepareFrameData(u8* payload)
// Disable fast forward here too... this shouldn't be necessary but better
// safe than sorry I guess
g_playbackStatus->isSoftFFW = false;
g_playbackStatus->isHardFFW = false;
g_playbackStatus->setHardFFW(false);
if (requestResultCode == FRAME_RESP_TERMINATE)
{

View file

@ -175,7 +175,7 @@ void SlippiPlaybackStatus::SavestateThread()
INFO_LOG(SLIPPI, "Exiting savestate thread");
}
void SlippiPlaybackStatus::SeekToFrame()
void SlippiPlaybackStatus::seekToFrame()
{
if (seekMtx.try_lock()) {
if (targetFrameNum < Slippi::PLAYBACK_FIRST_SAVE)
@ -235,15 +235,11 @@ void SlippiPlaybackStatus::SeekToFrame()
// Fastforward until we get to the frame we want
if (targetFrameNum != closestStateFrame && targetFrameNum != lastFrame)
{
isHardFFW = true;
SConfig::GetInstance().m_OCEnable = true;
SConfig::GetInstance().m_OCFactor = 4.0f;
setHardFFW(true);
Core::SetState(Core::State::Running);
cv_waitingForTargetFrame.wait(ffwLock);
Core::SetState(Core::State::Paused);
SConfig::GetInstance().m_OCFactor = 1.0f;
SConfig::GetInstance().m_OCEnable = false;
isHardFFW = false;
setHardFFW(false);
}
targetFrameNum = INT_MAX;
@ -254,6 +250,23 @@ void SlippiPlaybackStatus::SeekToFrame()
}
}
// Set isHardFFW and update OC settings to speed up the FFW
void SlippiPlaybackStatus::setHardFFW(bool enable) {
if (enable)
{
SConfig::GetInstance().m_OCEnable = true;
SConfig::GetInstance().m_OCFactor = 4.0f;
}
else
{
SConfig::GetInstance().m_OCFactor = origOCFactor;
SConfig::GetInstance().m_OCEnable = origOCEnable;
}
isHardFFW = enable;
}
void SlippiPlaybackStatus::loadState(s32 closestStateFrame)
{
if (closestStateFrame == Slippi::PLAYBACK_FIRST_SAVE)
@ -301,6 +314,9 @@ void SlippiPlaybackStatus::updateWatchSettingsStartEnd()
SlippiPlaybackStatus::~SlippiPlaybackStatus()
{
SConfig::GetInstance().m_OCFactor = origOCFactor;
SConfig::GetInstance().m_OCEnable = origOCEnable;
// Kill threads to prevent cleanup crash
resetPlayback();
}

View file

@ -14,7 +14,7 @@ class SlippiPlaybackStatus
{
public:
SlippiPlaybackStatus();
virtual ~SlippiPlaybackStatus();
~SlippiPlaybackStatus();
bool shouldJumpBack = false;
bool shouldJumpForward = false;
@ -22,6 +22,9 @@ public:
volatile bool shouldRunThreads = false;
bool isHardFFW = false;
bool isSoftFFW = false;
bool origOCEnable;
float origOCFactor;
s32 lastFFWFrame = INT_MIN;
s32 currentPlaybackFrame = INT_MIN;
s32 targetFrameNum = INT_MAX;
@ -33,7 +36,8 @@ public:
void resetPlayback(void);
bool shouldFFWFrame(s32 frameIndex) const;
void prepareSlippiPlayback(s32& frameIndex);
void SeekToFrame();
void setHardFFW(bool enable);
void seekToFrame();
private:
void SavestateThread(void);

View file

@ -359,5 +359,5 @@ void RenderWidget::Exit()
void RenderWidget::PlaybackSeek()
{
g_playbackStatus->SeekToFrame();
g_playbackStatus->seekToFrame();
}