gsdump: use correct plugin lifetime callbacks

This commit is contained in:
Gauvain 'GovanifY' Roussel-Tarbouriech 2021-03-06 12:43:39 +01:00 committed by Kojin
parent 9bfc82cfc7
commit 6840041ee6
4 changed files with 33 additions and 28 deletions

View File

@ -166,12 +166,8 @@ typedef void(CALLBACK *_GSosdLog)(const char *utf8, u32 color);
typedef void(CALLBACK *_GSosdMonitor)(const char *key, const char *value, u32 color); typedef void(CALLBACK *_GSosdMonitor)(const char *key, const char *value, u32 color);
typedef s32(CALLBACK *_GSopen)(void *pDsp, const char *Title, int multithread); typedef s32(CALLBACK *_GSopen)(void *pDsp, const char *Title, int multithread);
typedef s32(CALLBACK *_GSopen2)(void *pDsp, u32 flags); typedef s32(CALLBACK *_GSopen2)(void *pDsp, u32 flags);
typedef void(CALLBACK* _GSReplay)(char* lpszCmdLine, int renderer);
typedef void(CALLBACK *_GSvsync)(int field); typedef void(CALLBACK *_GSvsync)(int field);
typedef s32(CALLBACK* _GSinit)();
typedef s32(CALLBACK* _GSfreeze)(int mode, freezeData* data); typedef s32(CALLBACK* _GSfreeze)(int mode, freezeData* data);
typedef void(CALLBACK* _GSclose)();
typedef void(CALLBACK* _GSshutdown)();
typedef void(CALLBACK *_GSgifTransfer)(const u32 *pMem, u32 size); typedef void(CALLBACK *_GSgifTransfer)(const u32 *pMem, u32 size);
typedef void(CALLBACK *_GSgifTransfer1)(u32 *pMem, u32 addr); typedef void(CALLBACK *_GSgifTransfer1)(u32 *pMem, u32 addr);
typedef void(CALLBACK *_GSgifTransfer2)(u32 *pMem, u32 size); typedef void(CALLBACK *_GSgifTransfer2)(u32 *pMem, u32 size);
@ -207,11 +203,7 @@ extern _GSosdLog GSosdLog;
extern _GSosdMonitor GSosdMonitor; extern _GSosdMonitor GSosdMonitor;
extern _GSopen GSopen; extern _GSopen GSopen;
extern _GSopen2 GSopen2; extern _GSopen2 GSopen2;
extern _GSReplay GSReplay;
extern _GSinit GSinit;
extern _GSfreeze GSfreeze; extern _GSfreeze GSfreeze;
extern _GSclose GSclose;
extern _GSshutdown GSshutdown;
extern _GSvsync GSvsync; extern _GSvsync GSvsync;
extern _GSgifTransfer GSgifTransfer; extern _GSgifTransfer GSgifTransfer;
extern _GSgifTransfer1 GSgifTransfer1; extern _GSgifTransfer1 GSgifTransfer1;

View File

@ -157,11 +157,7 @@ _GSosdLog GSosdLog;
_GSosdMonitor GSosdMonitor; _GSosdMonitor GSosdMonitor;
_GSopen GSopen; _GSopen GSopen;
_GSopen2 GSopen2; _GSopen2 GSopen2;
_GSReplay GSReplay;
_GSinit GSinit;
_GSfreeze GSfreeze; _GSfreeze GSfreeze;
_GSclose GSclose;
_GSshutdown GSshutdown;
_GSgifTransfer GSgifTransfer; _GSgifTransfer GSgifTransfer;
_GSgifTransfer1 GSgifTransfer1; _GSgifTransfer1 GSgifTransfer1;
_GSgifTransfer2 GSgifTransfer2; _GSgifTransfer2 GSgifTransfer2;
@ -320,7 +316,6 @@ static const LegacyApi_OptMethod s_MethMessOpt_GS[] =
{ "GSosdLog", (vMeth**)&GSosdLog }, { "GSosdLog", (vMeth**)&GSosdLog },
{ "GSosdMonitor", (vMeth**)&GSosdMonitor }, { "GSosdMonitor", (vMeth**)&GSosdMonitor },
{ "GSopen2", (vMeth**)&GSopen2 }, { "GSopen2", (vMeth**)&GSopen2 },
{ "GSReplay", (vMeth**)&GSReplay },
{ "GSreset", (vMeth**)&GSreset }, { "GSreset", (vMeth**)&GSreset },
{ "GSsetupRecording", (vMeth**)&GSsetupRecording }, { "GSsetupRecording", (vMeth**)&GSsetupRecording },
{ "GSendRecording", (vMeth**)&GSendRecording }, { "GSendRecording", (vMeth**)&GSendRecording },

View File

@ -61,6 +61,7 @@ Dialogs::GSDumpDialog::GSDumpDialog(wxWindow* parent)
, m_step(new wxButton(this, ID_RUN_START, _("Step"))) , m_step(new wxButton(this, ID_RUN_START, _("Step")))
, m_selection(new wxButton(this, ID_RUN_START, _("Run to Selection"))) , m_selection(new wxButton(this, ID_RUN_START, _("Run to Selection")))
, m_vsync(new wxButton(this, ID_RUN_START, _("Go to next VSync"))) , m_vsync(new wxButton(this, ID_RUN_START, _("Go to next VSync")))
, m_thread(std::make_unique<GSThread>(this))
{ {
//TODO: figure out how to fix sliders so the destructor doesn't segfault //TODO: figure out how to fix sliders so the destructor doesn't segfault
wxFlexGridSizer& general(*new wxFlexGridSizer(2, StdPadding, StdPadding)); wxFlexGridSizer& general(*new wxFlexGridSizer(2, StdPadding, StdPadding));
@ -183,7 +184,8 @@ void Dialogs::GSDumpDialog::RunDump(wxCommandEvent& event)
m_step->Enable(); m_step->Enable();
m_selection->Enable(); m_selection->Enable();
m_vsync->Enable(); m_vsync->Enable();
m_thread = std::make_unique<GSThread>(this); GetCorePlugins().Shutdown();
m_thread->Start();
return; return;
} }
@ -613,15 +615,12 @@ void Dialogs::GSDumpDialog::CheckDebug(wxCommandEvent& event)
Dialogs::GSDumpDialog::GSThread::GSThread(GSDumpDialog* dlg) Dialogs::GSDumpDialog::GSThread::GSThread(GSDumpDialog* dlg)
: pxThread("GSDump") : pxThread("GSDump")
, m_root_window(dlg)
{ {
m_root_window = dlg;
// we start the thread
Start();
} }
Dialogs::GSDumpDialog::GSThread::~GSThread() Dialogs::GSDumpDialog::GSThread::~GSThread()
{ {
// destroy the thread
try try
{ {
pxThread::Cancel(); pxThread::Cancel();
@ -629,12 +628,28 @@ Dialogs::GSDumpDialog::GSThread::~GSThread()
DESTRUCTOR_CATCHALL DESTRUCTOR_CATCHALL
} }
void Dialogs::GSDumpDialog::GSThread::OnStop()
{
m_root_window->m_debug_mode->Disable();
m_root_window->m_start->Disable();
m_root_window->m_step->Disable();
m_root_window->m_selection->Disable();
m_root_window->m_vsync->Disable();
m_root_window->m_gif_list->DeleteAllItems();
m_root_window->m_gif_packet->DeleteAllItems();
m_root_window->m_gif_list->Refresh();
m_root_window->m_button_events.clear();
}
void Dialogs::GSDumpDialog::GSThread::ExecuteTaskInThread() void Dialogs::GSDumpDialog::GSThread::ExecuteTaskInThread()
{ {
pxInputStream dump_file(*m_root_window->m_selected_dump, new wxFFileInputStream(*m_root_window->m_selected_dump)); pxInputStream dump_file(*m_root_window->m_selected_dump, new wxFFileInputStream(*m_root_window->m_selected_dump));
if (!dump_file.IsOk()) if (!dump_file.IsOk())
{
OnStop();
return; return;
}
char freeze_data[sizeof(int) * 2]; char freeze_data[sizeof(int) * 2];
u32 crc = 0, ss = 0; u32 crc = 0, ss = 0;
@ -702,21 +717,21 @@ void Dialogs::GSDumpDialog::GSThread::ExecuteTaskInThread()
if (m_root_window->m_debug_mode->GetValue()) if (m_root_window->m_debug_mode->GetValue())
m_root_window->GenPacketList(m_root_window->m_dump_packets); m_root_window->GenPacketList(m_root_window->m_dump_packets);
return; GetCorePlugins().Init();
GSinit();
GSsetBaseMem((void*)regs); GSsetBaseMem((void*)regs);
if (GSopen2((void*)pDsp, renderer_override) != 0) if (GSopen2((void*)pDsp, renderer_override) != 0)
{
OnStop();
return; return;
}
GSsetGameCRC((int)crc, 0); GSsetGameCRC((int)crc, 0);
//OnStop();
return;
if (GSfreeze(0, &fd) == -1) if (GSfreeze(0, &fd) == -1)
{ m_running = false;
//DumpTooOld = true;
//Running = false;
}
GSvsync(1); GSvsync(1);
GSreset(); GSreset();
GSsetBaseMem((void*)regs); GSsetBaseMem((void*)regs);
@ -726,7 +741,7 @@ void Dialogs::GSDumpDialog::GSThread::ExecuteTaskInThread()
int RunTo = 0; int RunTo = 0;
size_t debug_idx = 0; size_t debug_idx = 0;
while (0 != 1) while (m_running)
{ {
if (m_root_window->m_debug_mode->GetValue()) if (m_root_window->m_debug_mode->GetValue())
{ {
@ -785,6 +800,7 @@ void Dialogs::GSDumpDialog::GSThread::ExecuteTaskInThread()
} }
} }
GSclose(); GetCorePlugins().Shutdown();
GSshutdown(); OnStop();
return;
} }

View File

@ -299,7 +299,9 @@ namespace Dialogs
// parent thread // parent thread
typedef pxThread _parent; typedef pxThread _parent;
void ExecuteTaskInThread(); void ExecuteTaskInThread();
void OnStop();
GSDumpDialog* m_root_window; GSDumpDialog* m_root_window;
bool m_running = true;
public: public:
GSThread(GSDumpDialog* dlg); GSThread(GSDumpDialog* dlg);