mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
Attempt to speed up drive reading by doing larger block reads - didn't help very much. we need to support async reads, I think.
Also delete some copypasta in DriveBlob - it already inherits those functions so it doesn't need them itself. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2368 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -25,7 +25,7 @@
|
||||
// allow random access. Or you may store them on an odd device, like raw on a DVD.
|
||||
|
||||
// Always read your BLOBs using an interface returned by CreateBlobReader(). It will
|
||||
// detect whether the file is a compressed blob, or just a big hunk of data, and
|
||||
// detect whether the file is a compressed blob, or just a big hunk of data, or a drive, and
|
||||
// automatically do the right thing.
|
||||
|
||||
#include "Common.h"
|
||||
@ -49,33 +49,41 @@ protected:
|
||||
|
||||
// Provides caching and split-operation-to-block-operations facilities.
|
||||
// Used for compressed blob reading and direct drive reading.
|
||||
// Currently only uses a single entry cache.
|
||||
// Multi-block reads are not cached.
|
||||
class SectorReader : public IBlobReader
|
||||
{
|
||||
private:
|
||||
virtual void GetBlock(u64 block_num, u8 *out) = 0;
|
||||
enum { CACHE_SIZE = 32 };
|
||||
int m_blocksize;
|
||||
u8* cache[CACHE_SIZE];
|
||||
u64 cache_tags[CACHE_SIZE];
|
||||
int cache_age[CACHE_SIZE];
|
||||
|
||||
protected:
|
||||
void SetSectorSize(int blocksize);
|
||||
virtual void GetBlock(u64 block_num, u8 *out) = 0;
|
||||
// This one is uncached. The default implementation is to simply call GetBlockData multiple times and memcpy.
|
||||
virtual bool ReadMultipleAlignedBlocks(u64 block_num, u64 num_blocks, u8 *out_ptr);
|
||||
|
||||
public:
|
||||
~SectorReader();
|
||||
virtual ~SectorReader();
|
||||
|
||||
// A pointer returned by GetBlockData is invalidated as soon as GetBlockData, Read, or ReadMultipleAlignedBlocks is called again.
|
||||
const u8 *GetBlockData(u64 block_num);
|
||||
bool Read(u64 offset, u64 size, u8* out_ptr);
|
||||
virtual bool Read(u64 offset, u64 size, u8 *out_ptr);
|
||||
friend class DriveReader;
|
||||
};
|
||||
|
||||
// Factory function - examines the path to choose the right type of IBlobReader, and returns one.
|
||||
IBlobReader* CreateBlobReader(const char* filename);
|
||||
IBlobReader* CreateBlobReader(const char *filename);
|
||||
|
||||
typedef void (*CompressCB)(const char* text, float percent, void* arg);
|
||||
typedef void (*CompressCB)(const char *text, float percent, void* arg);
|
||||
|
||||
bool CompressFileToBlob(const char* infile, const char* outfile, u32 sub_type = 0, int sector_size = 16384,
|
||||
CompressCB callback = 0, void* arg = 0);
|
||||
bool DecompressBlobToFile(const char* infile, const char* outfile,
|
||||
CompressCB callback = 0, void* arg = 0);
|
||||
bool CompressFileToBlob(const char *infile, const char *outfile, u32 sub_type = 0, int sector_size = 16384,
|
||||
CompressCB callback = 0, void *arg = 0);
|
||||
bool DecompressBlobToFile(const char *infile, const char *outfile,
|
||||
CompressCB callback = 0, void *arg = 0);
|
||||
|
||||
} // namespace
|
||||
|
||||
|
Reference in New Issue
Block a user