Fixed rambuffer.

This commit is contained in:
Federico Ponchio 2004-10-21 12:19:52 +00:00
parent c03be7f134
commit 4e77db8161
2 changed files with 10 additions and 13 deletions

View File

@ -15,8 +15,7 @@ bool PatchServer::Create(const std::string &filename,
signature = sig;
chunk_size = csize;
if(ram_size == 0) ram_size = 128000000;
ram_size = rsize/chunk_size;
ram_size = rsize/chunk_size + 1;
ram_used = 0;
vbo_size = 0;
vbo_used = 0;
@ -26,7 +25,7 @@ bool PatchServer::Create(const std::string &filename,
ram_flushed = 0;
lru.clear();
return File::Create(filename);
return MFile::Create(filename);
}
bool PatchServer::Load(const std::string &filename, Signature sig,
@ -34,11 +33,9 @@ bool PatchServer::Load(const std::string &filename, Signature sig,
unsigned int rsize) {
signature = sig;
chunk_size = csize;
chunk_size = csize/chunk_size + 1;
if(ram_size == 0) ram_size = 128000000;
ram_size = rsize/chunk_size;
ram_size = rsize/chunk_size + 1;
ram_used = 0;
vbo_size = 0;
vbo_used = 0;
@ -48,12 +45,12 @@ bool PatchServer::Load(const std::string &filename, Signature sig,
ram_flushed = 0;
lru.clear();
return File::Load(filename, readonly);
return MFile::Load(filename, readonly);
}
void PatchServer::Close() {
FlushAll();
File::Close();
MFile::Close();
}
//TODO add error checking.

View File

@ -2,7 +2,7 @@
#define NXS_PATCH_SERVER_H
#include "patch.h"
#include "file.h"
#include "mfile.h"
#include <vector>
@ -15,7 +15,7 @@ struct PatchEntry {
unsigned int lru_pos;
};
class PatchServer: public File {
class PatchServer: public MFile {
public:
struct PTime {
@ -51,10 +51,10 @@ class PatchServer: public File {
PatchServer(): chunk_size(1024), ram_size(128000000), vbo_size(32000000) {}
bool Create(const std::string &filename, Signature signature,
unsigned int chunk_size, unsigned int ram_size = 0);
unsigned int chunk_size, unsigned int ram_size = 128000000);
bool Load(const std::string &filename, Signature sig,
unsigned int chunk_size, bool readonly,
unsigned int ram_size = 0);
unsigned int ram_size = 128000000);
void Close();