SPU2-X: added some safety checks to the savestate code to catch (and ignore) situations where PCSX2 tries to save or load states while the plugins are shut down.

(and fixed compile errors from prev rev -- woops)

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2988 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2010-05-12 14:18:40 +00:00
parent 23a7f7ad21
commit 30cf31b7bc
6 changed files with 21 additions and 21 deletions

View File

@ -495,7 +495,7 @@ public:
void OpenGsPanel();
void CloseGsPanel();
void OnGsFrameClosed();
void OnGsFrameClosed( wxWindowID id );
void OnMainFrameClosed( wxWindowID id );
// --------------------------------------------------------------------------

View File

@ -277,7 +277,7 @@ GSFrame::~GSFrame() throw()
void GSFrame::OnCloseWindow(wxCloseEvent& evt)
{
sApp.OnGsFrameClosed();
sApp.OnGsFrameClosed( GetId() );
evt.Skip(); // and close it.
}

View File

@ -314,8 +314,8 @@ EXPORT_C_(s32) SPU2init()
IsInitialized = true;
spu2regs = (short*)malloc(0x010000);
_spu2mem = (short*)malloc(0x200000);
spu2regs = (s16*)malloc(0x010000);
_spu2mem = (s16*)malloc(0x200000);
// adpcm decoder cache:
// the cache data size is determined by taking the number of adpcm blocks
@ -326,8 +326,7 @@ EXPORT_C_(s32) SPU2init()
pcm_cache_data = (PcmCacheEntry*)calloc( pcm_BlockCount, sizeof(PcmCacheEntry) );
if( (spu2regs == NULL) || (_spu2mem == NULL) ||
(pcm_cache_data == NULL) )
if( (spu2regs == NULL) || (_spu2mem == NULL) || (pcm_cache_data == NULL) )
{
SysMessage("SPU2: Error allocating Memory\n"); return -1;
}
@ -465,10 +464,6 @@ EXPORT_C_(void) SPU2shutdown()
safe_free(_spu2mem);
safe_free( pcm_cache_data );
spu2regs = NULL;
_spu2mem = NULL;
pcm_cache_data = NULL;
#ifdef SPU2_LOG
if(!AccessLog()) return;
FileLog("[%10d] SPU2shutdown\n",Cycles);
@ -481,11 +476,11 @@ EXPORT_C_(void) SPU2setClockPtr(u32 *ptr)
cyclePtr = ptr;
}
bool numpad_plus = false, numpad_plus_old = false;
static bool numpad_plus = false, numpad_plus_old = false;
#ifdef DEBUG_KEYS
u32 lastTicks;
bool lState[5];
static u32 lastTicks;
static bool lState[5];
#endif
EXPORT_C_(void) SPU2async(u32 cycles)

View File

@ -522,8 +522,8 @@ extern s16 InputPos;
// SPU Mixing Cycles ("Ticks mixed" counter)
extern u32 Cycles;
extern short* spu2regs;
extern short* _spu2mem;
extern s16* spu2regs;
extern s16* _spu2mem;
extern int PlayMode;
extern void SetIrqCall();

View File

@ -54,8 +54,11 @@ s32 __fastcall Savestate::FreezeIt( DataBlock& spud )
spud.spu2id = SAVE_ID;
spud.version = SAVE_VERSION;
memcpy(spud.unkregs, spu2regs, sizeof(spud.unkregs));
memcpy(spud.mem, _spu2mem, sizeof(spud.mem));
pxAssumeMsg( spu2regs && _spu2mem, "Looks like PCSX2 is trying to savestate while pluigns are shut down. That's a no-no! It shouldn't crash, but the savestate will probably be corrupted." );
if( spu2regs != NULL ) memcpy(spud.unkregs, spu2regs, sizeof(spud.unkregs));
if( _spu2mem != NULL ) memcpy(spud.mem, _spu2mem, sizeof(spud.mem));
memcpy(spud.Cores, Cores, sizeof(Cores));
memcpy(&spud.Spdif, &Spdif, sizeof(Spdif));
@ -101,9 +104,11 @@ s32 __fastcall Savestate::ThawIt( DataBlock& spud )
{
SndBuffer::ClearContents();
pxAssumeMsg( spu2regs && _spu2mem, "Looks like PCSX2 is trying to loadstate while pluigns are shut down. That's a no-no! It shouldn't crash, but the savestate will probably be corrupted." );
// base stuff
memcpy(spu2regs, spud.unkregs, sizeof(spud.unkregs));
memcpy(_spu2mem, spud.mem, sizeof(spud.mem));
if( spu2regs ) memcpy(spu2regs, spud.unkregs, sizeof(spud.unkregs));
if( _spu2mem ) memcpy(_spu2mem, spud.mem, sizeof(spud.mem));
memcpy(Cores, spud.Cores, sizeof(Cores));
memcpy(&Spdif, &spud.Spdif, sizeof(Spdif));

View File

@ -27,8 +27,8 @@
#include "PS2E-spu2.h" // needed until I figure out a nice solution for irqcallback dependencies.
short *spu2regs;
short *_spu2mem;
s16* spu2regs = NULL;
s16* _spu2mem = NULL;
V_CoreDebug DebugCores[2];
V_Core Cores[2];