NES: HD Packs - Fixed crash when starting/stopping hd pack recorder

This commit is contained in:
Sour 2023-06-30 16:01:24 +09:00
parent 600d4bf5b2
commit a3aedd2f2a
3 changed files with 14 additions and 0 deletions

View file

@ -659,6 +659,8 @@ void NesConsole::StartRecordingHdPack(HdPackBuilderOptions options)
{
auto lock = _emu->AcquireLock();
_emu->GetVideoDecoder()->WaitForAsyncFrameDecode();
std::stringstream saveState;
_emu->Serialize(saveState, false, 0);
@ -679,6 +681,8 @@ void NesConsole::StopRecordingHdPack()
{
if(_hdPackBuilder) {
auto lock = _emu->AcquireLock();
_emu->GetVideoDecoder()->WaitForAsyncFrameDecode();
std::stringstream saveState;
_emu->Serialize(saveState, false, 0);

View file

@ -168,6 +168,14 @@ uint32_t VideoDecoder::GetFrameCount()
return _frameCount;
}
void VideoDecoder::WaitForAsyncFrameDecode()
{
while(_frameChanged) {
//Spin until decode is done
std::this_thread::sleep_for(std::chrono::duration<int, std::milli>(15));
}
}
void VideoDecoder::UpdateFrame(RenderedFrame frame, bool sync, bool forRewind)
{
if(_emu->IsRunAheadFrame()) {

View file

@ -62,6 +62,8 @@ public:
void UpdateFrame(RenderedFrame frame, bool sync, bool forRewind);
void WaitForAsyncFrameDecode();
bool IsRunning();
void StartThread();
void StopThread();