lots of cleanup. fixes destructor crash. also solves #50

This commit is contained in:
R2DLiu 2020-08-23 17:25:54 -04:00
commit 836162a76a
4 changed files with 12 additions and 26 deletions

View file

@ -46,12 +46,12 @@ option(USE_DISCORD_PRESENCE "Enables Discord Rich Presence, show the current gam
option(ENABLE_ANALYTICS "Enables opt-in Analytics collection" OFF)
# Enable Playback build for Slippi for watching replays
option(SLIPPI_PLAYBACK "Enable Playback changes" OFF)
option(SLIPPI_PLAYBACK "Enable Playback changes" ON)
option(ENCODE_FRAMEDUMPS "Encode framedumps in AVI format" ON)
option(ENABLE_GPROF "Enable gprof profiling (must be using Debug build)" OFF)
option(FASTLOG "Enable all logs" OFF)
option(FASTLOG "Enable all logs" OFF)
option(GDBSTUB "Enable gdb stub for remote debugging." OFF)
option(OPROFILING "Enable profiling" OFF)

View file

@ -604,6 +604,10 @@ void CEXISlippi::prepareGameInfo(u8* payload)
Slippi::GameSettings* settings = m_current_game->GetSettings();
// Unlikely but reset the overclocking in case we quit during a hard ffw in a previous play
SConfig::GetInstance().m_OCEnable = g_playbackStatus->origOCEnable;
SConfig::GetInstance().m_OCFactor = g_playbackStatus->origOCFactor;
// Start in Fast Forward if this is mirrored
auto replayCommSettings = g_replayComm->getSettings();
if (!g_playbackStatus->isHardFFW)

View file

@ -86,19 +86,8 @@ void SlippiPlaybackStatus::prepareSlippiPlayback(s32& frameIndex)
// TODO: figure out why sometimes playback frame increments past targetFrameNum
if (inSlippiPlayback && frameIndex >= targetFrameNum)
{
if (targetFrameNum < currentPlaybackFrame)
{
// Since playback logic only goes up in currentPlaybackFrame now due to handling rollback
// playback, we need to rewind the currentPlaybackFrame here instead such that the playback
// cursor will show up in the correct place
currentPlaybackFrame = targetFrameNum;
}
if (currentPlaybackFrame > targetFrameNum)
{
INFO_LOG(SLIPPI, "Reached frame %d. Target was %d. Unblocking", currentPlaybackFrame,
targetFrameNum);
}
INFO_LOG(SLIPPI, "Reached frame %d. Target was %d. Unblocking", frameIndex,
targetFrameNum);
cv_waitingForTargetFrame.notify_one();
}
}
@ -195,12 +184,12 @@ void SlippiPlaybackStatus::seekToFrame()
s32 closestStateFrame = targetFrameNum - emod(targetFrameNum - Slippi::PLAYBACK_FIRST_SAVE, FRAME_INTERVAL);
bool isLoadingStateOptimal = targetFrameNum < currentPlaybackFrame || closestStateFrame > currentPlaybackFrame;
if (isLoadingStateOptimal)
{
if (closestStateFrame <= Slippi::PLAYBACK_FIRST_SAVE)
{
State::LoadFromBuffer(iState);
INFO_LOG(SLIPPI, "loaded a state");
}
else
{
@ -240,13 +229,9 @@ void SlippiPlaybackStatus::seekToFrame()
Core::SetState(Core::State::Paused);
setHardFFW(false);
}
else {
// In the case where we don't need to fastforward, we're already at the frame we want!
// Update currentPlaybackFrame accordingly
g_playbackStatus->currentPlaybackFrame = targetFrameNum;
}
// We've reached the frame we want. Reset targetFrameNum and release mutex so another seek can be performed
g_playbackStatus->currentPlaybackFrame = targetFrameNum;
targetFrameNum = INT_MAX;
Core::SetState(prevState);
seekMtx.unlock();
@ -319,9 +304,6 @@ void SlippiPlaybackStatus::updateWatchSettingsStartEnd()
SlippiPlaybackStatus::~SlippiPlaybackStatus()
{
SConfig::GetInstance().m_OCFactor = origOCFactor;
SConfig::GetInstance().m_OCEnable = origOCEnable;
// Kill threads to prevent cleanup crash
resetPlayback();
}

View file

@ -282,9 +282,9 @@ bool SliderCustomBehavior(const ImRect& bb, ImGuiID id, int* v, int v_min, int v
isHeld = isHeld && isDown;
// If no longer held, slider was let go. Trigger mark edited
if (!isHeld) {
INFO_LOG(SLIPPI, "Seeking to frame %d!", *v);
value_changed = true;
g_playbackStatus->targetFrameNum = *v;
INFO_LOG(SLIPPI, "Seeking to frame %d!", g_playbackStatus->targetFrameNum);
}
}
else
@ -424,7 +424,7 @@ void DrawSlippiPlaybackControls()
ImGui::PushItemWidth(ImGui::GetWindowWidth());
ImGui::SetCursorPos(ImVec2(0.0f, ImGui::GetWindowHeight() - 44));
if (SliderCustom("", ImVec4(1.0f, 0.0f, 0.0f, 1.0f), &frame, Slippi::PLAYBACK_FIRST_SAVE, g_playbackStatus->lastFrame, 1.0, "%d")) {
INFO_LOG(SLIPPI, "seek");
INFO_LOG(SLIPPI, "seeking to %d", g_playbackStatus->targetFrameNum);
Host_PlaybackSeek();
}
ImGui::SetCursorPos(ImVec2(0.0f, ImGui::GetWindowHeight() - 30));