summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoretobi <git@e-tobi.net>2009-10-26 03:22:58 +0100
committeretobi <git@e-tobi.net>2009-10-26 03:24:21 +0100
commitc9e68daf1a46f96b8f0a80b1056e62c3f13bbd5b (patch)
treed7875149f6b8bf35f3facbc17fa19d7fbee4efaa
parentb7e63f01cd2b98d6f588a75ea7c85a080488dd85 (diff)
downloadvdr-plugin-osdteletext-c9e68daf1a46f96b8f0a80b1056e62c3f13bbd5b.tar.gz
vdr-plugin-osdteletext-c9e68daf1a46f96b8f0a80b1056e62c3f13bbd5b.tar.bz2
Got rid of static storage option field (References #177)
-rw-r--r--osdteletext.c10
-rw-r--r--txtrecv.c24
-rw-r--r--txtrecv.h16
3 files changed, 14 insertions, 36 deletions
diff --git a/osdteletext.c b/osdteletext.c
index 2f24611..62249d2 100644
--- a/osdteletext.c
+++ b/osdteletext.c
@@ -181,14 +181,8 @@ bool cPluginTeletextosd::Start(void)
// Start any background activities the plugin shall perform.
//Clean any files which might be remaining from the last session,
//perhaps due to a crash they have not been deleted.
- storage = Storage::CreateInstance(storageSystem);
- if(storage) {
- if (maxStorage>=0)
- storage->setMaxStorage(maxStorage);
- storage->init();
- } else {
- return false;
- }
+ storage = Storage::CreateInstance(storageSystem, maxStorage);
+
initTexts();
if (startReceiver)
txtStatus=new cTxtStatus(storeTopText, storage);
diff --git a/txtrecv.c b/txtrecv.c
index 59f5bd9..ac27c4c 100644
--- a/txtrecv.c
+++ b/txtrecv.c
@@ -100,8 +100,6 @@ int Storage::cleanSubDir(const char *dir) {
return bytesDeleted;
}
-int Storage::storageOption = -1;
-
Storage::Storage() {
byteCount=0;
failedFreeSpace=false;
@@ -110,25 +108,16 @@ Storage::Storage() {
Storage::~Storage() {
}
-Storage *Storage::CreateInstance(StorageSystem system) {
+Storage *Storage::CreateInstance(StorageSystem system, int storageLimit) {
switch (system) {
case StorageSystemLegacy:
- return new LegacyStorage();
+ return new LegacyStorage(storageLimit);
case StorageSystemPacked:
default:
- return new PackedStorage();
+ return new PackedStorage(storageLimit);
}
}
-void Storage::setMaxStorage(int maxMB) {
- storageOption=maxMB;
-}
-
-void Storage::init() {
- cleanUp();
- initMaxStorage(storageOption);
-}
-
void Storage::freeSpace() {
//there might be a situation where only the current directory is left and
//occupies the whole space. We cannot delete anything. Don't waste time scanning.
@@ -190,10 +179,10 @@ void Storage::prepareDirectory(tChannelID chan) {
#define TELETEXT_PAGESIZE 972
-LegacyStorage::LegacyStorage() {
- maxBytes=0;
+LegacyStorage::LegacyStorage(int maxMB) {
fsBlockSize=1;
pageBytes=TELETEXT_PAGESIZE;
+ initMaxStorage(maxMB);
}
LegacyStorage::~LegacyStorage() {
@@ -323,7 +312,8 @@ ssize_t LegacyStorage::write(const void *ptr, size_t size, StorageHandle stream)
-PackedStorage::PackedStorage() {
+PackedStorage::PackedStorage(int maxMB)
+ : LegacyStorage(maxMB) {
}
#define TOC_SIZE 8
//The file structure is simple:
diff --git a/txtrecv.h b/txtrecv.h
index 84189c4..78af3df 100644
--- a/txtrecv.h
+++ b/txtrecv.h
@@ -55,12 +55,10 @@ public:
virtual ~Storage();
enum StorageSystem { StorageSystemLegacy, StorageSystemPacked };
//must be called before the first call to instance()
- void setMaxStorage(int maxMB=-1);
- static Storage *CreateInstance(StorageSystem system);
+ static Storage *CreateInstance(StorageSystem system, int storageLimit);
//must be called before operation starts. Set all options (RootDir, maxStorage) before.
- void init();
virtual void cleanUp() = 0;
virtual void getFilename(char *buffer, int bufLength, PageID page);
@@ -72,8 +70,6 @@ public:
virtual ssize_t read(void *ptr, size_t size, StorageHandle stream) = 0;
virtual void close(StorageHandle stream) = 0;
protected:
- virtual void initMaxStorage(int maxMB=-1) = 0;
-
Storage();
int cleanSubDir(const char *dir);
int doCleanUp();
@@ -84,13 +80,14 @@ protected:
long byteCount;
cString currentDir;
private:
- static int storageOption;
bool failedFreeSpace;
};
class LegacyStorage : public Storage {
+private:
+ void initMaxStorage(int maxMB=-1);
public:
- LegacyStorage();
+ LegacyStorage(int maxMB);
virtual ~LegacyStorage();
virtual void cleanUp();
@@ -102,7 +99,6 @@ public:
virtual void close(StorageHandle stream)
{ ::close((int)stream); }
protected:
- virtual void initMaxStorage(int maxMB=-1);
void registerFile(PageID page);
virtual int actualFileSize(int netFileSize);
//int maxPages;
@@ -113,9 +109,7 @@ protected:
class PackedStorage : public LegacyStorage {
public:
- PackedStorage();
- //virtual void setMaxStorage(int maxMB=-1);
- //virtual void cleanUp();
+ PackedStorage(int maxMB);
virtual void getFilename(char *buffer, int bufLength, PageID page);
virtual StorageHandle openForWriting(PageID page);