mirror of https://github.com/PCSX2/pcsx2.git
Fixed: Savestate bug when saving caused erratic freezeups.
Fixed: More savestate slowness, and less savestate memory hogging. SPU2-X: Fixed crash bug on using savestates while suspended. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1994 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
e8e61a5cf8
commit
28473c1436
|
@ -151,16 +151,15 @@ public:
|
|||
m_ptr = _virtual_realloc( newsize );
|
||||
if( m_ptr == NULL )
|
||||
{
|
||||
|
||||
throw Exception::OutOfMemory(
|
||||
wxsFormat( // english (for diagnostic)
|
||||
L"Out-of-memory on SafeArray block re-allocation.\n"
|
||||
L"Old size: %d bytes, New size: %d bytes.",
|
||||
m_size, newsize
|
||||
),
|
||||
// internationalized!
|
||||
wxsFormat( _("Out of memory, trying to allocate %d bytes."), newsize )
|
||||
);
|
||||
throw Exception::OutOfMemory(
|
||||
wxsFormat( // english (for diagnostic)
|
||||
L"Out-of-memory on SafeArray block re-allocation.\n"
|
||||
L"Old size: %d bytes, New size: %d bytes.",
|
||||
m_size, newsize
|
||||
),
|
||||
// internationalized!
|
||||
wxsFormat( _("Out of memory, trying to allocate %d bytes."), newsize )
|
||||
);
|
||||
}
|
||||
m_size = newsize;
|
||||
}
|
||||
|
|
|
@ -104,6 +104,7 @@ protected:
|
|||
void OnStart()
|
||||
{
|
||||
_parent::OnStart();
|
||||
|
||||
sys_resume_lock = true;
|
||||
CoreThread.Pause();
|
||||
}
|
||||
|
@ -203,7 +204,7 @@ protected:
|
|||
int thisBlockSize = std::min( BlockSize, state_buffer.GetSizeInBytes() - curidx );
|
||||
if( gzwrite( m_gzfp, state_buffer.GetPtr(curidx), thisBlockSize ) < thisBlockSize )
|
||||
throw Exception::BadStream( m_filename );
|
||||
curidx += BlockSize;
|
||||
curidx += thisBlockSize;
|
||||
Yield( 1 );
|
||||
} while( curidx < state_buffer.GetSizeInBytes() );
|
||||
}
|
||||
|
@ -259,11 +260,13 @@ protected:
|
|||
{
|
||||
// fixme: should start initially with the file size, and then grow from there.
|
||||
|
||||
static const int BlockSize = 327680;
|
||||
static const int BlockSize = 0x100000;
|
||||
state_buffer.MakeRoomFor( 0x800000 ); // start with an 8 meg buffer to avoid frequent reallocation.
|
||||
|
||||
int curidx = 0;
|
||||
do
|
||||
{
|
||||
state_buffer.ExactAlloc( curidx+BlockSize );
|
||||
state_buffer.MakeRoomFor( curidx+BlockSize );
|
||||
gzread( m_gzfp, state_buffer.GetPtr(curidx), BlockSize );
|
||||
curidx += BlockSize;
|
||||
TestCancel();
|
||||
|
@ -313,6 +316,11 @@ void OnFinished_Resume( const wxCommandEvent& evt )
|
|||
CoreThread.Resume();
|
||||
}
|
||||
|
||||
void OnFinished_Dispose( const wxCommandEvent& evt )
|
||||
{
|
||||
state_buffer.Dispose();
|
||||
}
|
||||
|
||||
static wxString zip_dest_filename;
|
||||
|
||||
void OnFinished_ZipToDisk( const wxCommandEvent& evt )
|
||||
|
@ -326,7 +334,7 @@ void OnFinished_ZipToDisk( const wxCommandEvent& evt )
|
|||
}
|
||||
|
||||
// Phase 2: Record to disk!!
|
||||
(new StateThread_ZipToDisk( NULL, zip_dest_filename ))->Start();
|
||||
(new StateThread_ZipToDisk( OnFinished_Dispose, zip_dest_filename ))->Start();
|
||||
|
||||
CoreThread.Resume();
|
||||
}
|
||||
|
|
|
@ -352,8 +352,6 @@ void SaveStateBase::FreezeAll()
|
|||
memSavingState::memSavingState( SafeArray<u8>& save_to ) :
|
||||
SaveStateBase( save_to )
|
||||
{
|
||||
save_to.ChunkSize = ReallocThreshold;
|
||||
save_to.MakeRoomFor( MemoryBaseAllocSize );
|
||||
}
|
||||
|
||||
// Saving of state data
|
||||
|
@ -365,6 +363,15 @@ void memSavingState::FreezeMem( void* data, int size )
|
|||
memcpy_fast( dest, data, size );
|
||||
}
|
||||
|
||||
void memSavingState::FreezeAll()
|
||||
{
|
||||
// 90% of all savestates fit in under 45 megs (and require more than 43 megs, so migght as well...)
|
||||
m_memory.ChunkSize = ReallocThreshold;
|
||||
m_memory.MakeRoomFor( MemoryBaseAllocSize );
|
||||
|
||||
_parent::FreezeAll();
|
||||
}
|
||||
|
||||
memLoadingState::memLoadingState( const SafeArray<u8>& load_from ) :
|
||||
SaveStateBase( const_cast<SafeArray<u8>&>(load_from) )
|
||||
{
|
||||
|
|
|
@ -85,7 +85,7 @@ public:
|
|||
// Loads or saves the entire emulation state.
|
||||
// Note: The Cpu state must be reset, and plugins *open*, prior to Defrosting
|
||||
// (loading) a state!
|
||||
void FreezeAll();
|
||||
virtual void FreezeAll();
|
||||
|
||||
// Loads or saves an arbitrary data type. Usable on atomic types, structs, and arrays.
|
||||
// For dynamically allocated pointers use FreezeMem instead.
|
||||
|
@ -168,9 +168,11 @@ protected:
|
|||
|
||||
class memSavingState : public SaveStateBase
|
||||
{
|
||||
typedef SaveStateBase _parent;
|
||||
|
||||
protected:
|
||||
static const int ReallocThreshold = 0x200000; // 256k reallocation block size.
|
||||
static const int MemoryBaseAllocSize = 0x02a00000; // 42 meg base alloc
|
||||
static const int MemoryBaseAllocSize = 0x02b00000; // 45 meg base alloc
|
||||
|
||||
public:
|
||||
virtual ~memSavingState() { }
|
||||
|
@ -178,6 +180,8 @@ public:
|
|||
|
||||
// Saving of state data to a memory buffer
|
||||
void FreezeMem( void* data, int size );
|
||||
void FreezeAll();
|
||||
|
||||
bool IsSaving() const { return true; }
|
||||
};
|
||||
|
||||
|
|
|
@ -431,8 +431,8 @@ void SysCoreThread::OnResumeInThread( bool isSuspended )
|
|||
{
|
||||
if( isSuspended && g_plugins != NULL )
|
||||
{
|
||||
CpuInitializeMess();
|
||||
g_plugins->Open();
|
||||
CpuInitializeMess();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -220,11 +220,14 @@ u64 FileMemoryCard::GetCRC( uint port, uint slot )
|
|||
|
||||
if( !Seek( mcfp, 0 ) ) return 0;
|
||||
|
||||
// Process the file in 4k chunks. Speeds things up significantly.
|
||||
u64 retval = 0;
|
||||
for( uint i=MC2_SIZE/sizeof(u64); i; --i )
|
||||
u64 buffer[0x1000];
|
||||
for( uint i=MC2_SIZE/sizeof(buffer); i; --i )
|
||||
{
|
||||
u64 temp; mcfp.Read( &temp, sizeof(temp) );
|
||||
retval ^= temp;
|
||||
mcfp.Read( &buffer, sizeof(buffer) );
|
||||
for( uint t=0; t<ArraySize(buffer); ++t )
|
||||
retval ^= buffer[t];
|
||||
}
|
||||
|
||||
return retval;
|
||||
|
|
|
@ -612,6 +612,6 @@ Global
|
|||
{677B7D11-D5E1-40B3-88B1-9A4DF83D2213} = {2D6F0A62-A247-4CCF-947F-FCD54BE16103}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
AMDCaProjectFile = E:\devpcsx2\nommx\CodeAnalyst\pcsx2_suite_2008.caw
|
||||
AMDCaProjectFile = E:\devpcsx2\trunk2\CodeAnalyst\pcsx2_suite_2008.caw
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
@ -324,6 +324,8 @@ void SndBuffer::soundtouchInit()
|
|||
// reset timestretch management vars, and delay updates a bit:
|
||||
void SndBuffer::soundtouchClearContents()
|
||||
{
|
||||
if( pSoundTouch == NULL ) return;
|
||||
|
||||
pSoundTouch->clear();
|
||||
pSoundTouch->setTempo(1);
|
||||
|
||||
|
|
Loading…
Reference in New Issue