mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-18 10:45:46 -04:00
MemoryCard: Batch sector writes together 5 seconds at a time
Reduces disk writes for SSDs (assuming the OS didn't just cache all the writes), and limits OSD spam. Fixes #146.
This commit is contained in:
@ -7,6 +7,7 @@
|
||||
#include <string_view>
|
||||
|
||||
class System;
|
||||
class TimingEvent;
|
||||
|
||||
class MemoryCard final
|
||||
{
|
||||
@ -33,6 +34,13 @@ public:
|
||||
void Format();
|
||||
|
||||
private:
|
||||
enum : u32
|
||||
{
|
||||
// save in three seconds, that should be long enough for everything to finish writing
|
||||
SAVE_DELAY_IN_SECONDS = 5,
|
||||
SAVE_DELAY_IN_SYSCLK_TICKS = MASTER_CLOCK * SAVE_DELAY_IN_SECONDS,
|
||||
};
|
||||
|
||||
union FLAG
|
||||
{
|
||||
u8 bits;
|
||||
@ -76,9 +84,11 @@ private:
|
||||
u8* GetSectorPtr(u32 sector);
|
||||
|
||||
bool LoadFromFile();
|
||||
bool SaveToFile();
|
||||
bool SaveIfChanged(bool display_osd_message);
|
||||
void QueueFileSave();
|
||||
|
||||
System* m_system;
|
||||
std::unique_ptr<TimingEvent> m_save_event;
|
||||
|
||||
State m_state = State::Idle;
|
||||
u16 m_address = 0;
|
||||
|
Reference in New Issue
Block a user