Capture: Stop a capture at the end of an input recording

This commit is contained in:
sonicfind 2021-03-12 14:00:33 -06:00 committed by lightningterror
parent 45c1579a15
commit 1e056ca3fa
4 changed files with 70 additions and 50 deletions

@ -1 +1 @@
Subproject commit d8e4c256e5941d9951c3f155b15258b5be714022
Subproject commit 42bfcb0ca002ebbad13657ac4d71ebad4cc6afa1

View File

@ -48,11 +48,11 @@ void InputRecordingControls::CheckPauseStatus()
switchToReplay = false;
}
if (!pauseEmulation &&
g_InputRecording.IsReplaying() &&
g_InputRecording.GetFrameCounter() >= g_InputRecording.GetInputRecordingData().GetTotalFrames())
if (IsFinishedReplaying() || g_InputRecording.GetFrameCounter() == INT_MAX)
{
if (!pauseEmulation)
pauseEmulation = true;
StopCapture();
}
}
g_InputRecording.LogAndRedraw();
@ -93,16 +93,15 @@ void InputRecordingControls::ResumeCoreThreadIfStarted()
void InputRecordingControls::FrameAdvance()
{
if (g_InputRecording.IsReplaying() &&
g_InputRecording.GetFrameCounter() >= g_InputRecording.GetInputRecordingData().GetTotalFrames())
if (!IsFinishedReplaying())
{
g_InputRecording.SetToRecordMode();
return;
}
frameAdvancing = true;
frame_advance_frame_counter = 0;
Resume();
}
else
g_InputRecording.SetToRecordMode();
}
void InputRecordingControls::setFrameAdvanceAmount(int amount)
{
@ -116,7 +115,7 @@ bool InputRecordingControls::IsFrameAdvancing()
bool InputRecordingControls::IsPaused()
{
return (emulationCurrentlyPaused && CoreThread.IsOpen() && CoreThread.IsPaused());
return emulationCurrentlyPaused && CoreThread.IsOpen() && CoreThread.IsPaused();
}
void InputRecordingControls::Pause()
@ -127,8 +126,8 @@ void InputRecordingControls::Pause()
void InputRecordingControls::PauseImmediately()
{
if (CoreThread.IsPaused())
return;
if (!CoreThread.IsPaused())
{
Pause();
if (CoreThread.IsOpen() && CoreThread.IsRunning())
{
@ -136,59 +135,56 @@ void InputRecordingControls::PauseImmediately()
CoreThread.PauseSelf();
}
}
}
void InputRecordingControls::Resume()
{
if (g_InputRecording.IsReplaying() &&
g_InputRecording.GetFrameCounter() >= g_InputRecording.GetInputRecordingData().GetTotalFrames())
if (!IsFinishedReplaying())
{
g_InputRecording.SetToRecordMode();
return;
}
pauseEmulation = false;
resumeEmulation = true;
}
else
g_InputRecording.SetToRecordMode();
}
void InputRecordingControls::ResumeImmediately()
{
if (!CoreThread.IsPaused())
return;
if (CoreThread.IsPaused())
{
Resume();
if (CoreThread.IsPaused() && CoreThread.IsRunning())
if (CoreThread.IsRunning())
{
emulationCurrentlyPaused = false;
CoreThread.Resume();
}
}
}
void InputRecordingControls::TogglePause()
{
if (pauseEmulation &&
g_InputRecording.IsReplaying() &&
g_InputRecording.GetFrameCounter() >= g_InputRecording.GetInputRecordingData().GetTotalFrames())
if (!pauseEmulation || !IsFinishedReplaying())
{
g_InputRecording.SetToRecordMode();
return;
}
resumeEmulation = pauseEmulation;
pauseEmulation = !pauseEmulation;
inputRec::log(pauseEmulation ? "Paused Emulation" : "Resumed Emulation");
}
else
g_InputRecording.SetToRecordMode();
}
void InputRecordingControls::RecordModeToggle()
{
if (IsPaused() ||
g_InputRecording.IsReplaying() ||
g_InputRecording.GetFrameCounter() < g_InputRecording.GetInputRecordingData().GetTotalFrames())
{
if (g_InputRecording.IsReplaying())
g_InputRecording.SetToRecordMode();
else if (g_InputRecording.IsRecording())
{
if (IsPaused() || g_InputRecording.GetFrameCounter() < g_InputRecording.GetInputRecordingData().GetTotalFrames())
g_InputRecording.SetToReplayMode();
}
else if (g_InputRecording.IsRecording())
else
switchToReplay = true;
}
}
void InputRecordingControls::Lock(u32 frame)
{
@ -201,4 +197,22 @@ void InputRecordingControls::Lock(u32 frame)
else
sMainFrame.StartInputRecording();
}
bool InputRecordingControls::IsFinishedReplaying() const
{
return g_InputRecording.IsReplaying() &&
g_InputRecording.GetFrameCounter() >= g_InputRecording.GetInputRecordingData().GetTotalFrames();
}
void InputRecordingControls::StopCapture() const
{
if (MainEmuFrame* mainFrame = GetMainFramePtr())
{
if (mainFrame->IsCapturing())
{
mainFrame->VideoCaptureToggle();
inputRec::log("Capture completed");
}
}
}
#endif

View File

@ -90,6 +90,10 @@ private:
bool frameLock = false;
// The frame value to use as the frame lock reset point
u32 frameLockTracker = 0;
bool IsFinishedReplaying() const;
// Calls mainEmuFrame's videoCaptureToggle to end a capture if active
void StopCapture() const;
};
extern InputRecordingControls g_InputRecordingControls;

View File

@ -124,6 +124,8 @@ public:
void AppendShortcutToMenuOption(wxMenuItem& item, wxString keyCodeStr);
void UpdateStatusBar();
void VideoCaptureToggle();
bool IsCapturing() const noexcept { return m_capturingVideo; }
#ifndef DISABLE_RECORDING
void initializeRecordingMenuItem(MenuIdentifiers menuId, wxString keyCodeStr, bool enable = true);
void enableRecordingMenuItem(MenuIdentifiers menuId, bool enable);