summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cachemanager.cc18
-rw-r--r--src/cachemanager.h4
2 files changed, 11 insertions, 11 deletions
diff --git a/src/cachemanager.cc b/src/cachemanager.cc
index 2c0315d..e72ee37 100644
--- a/src/cachemanager.cc
+++ b/src/cachemanager.cc
@@ -65,10 +65,9 @@ void CacheManager::deinit()
// Invariant: initial_samples_needed < preloaded audio data
sample_t *CacheManager::open(AudioFile *file, size_t initial_samples_needed, int channel, cacheid_t &id)
{
- // What if no free ids is available?
m_ids.lock();
if(availableids.empty()) {
- id = CACHEMANAGER_NOID;
+ id = CACHE_DUMMYID;
}
else {
id = availableids.front();
@@ -76,8 +75,11 @@ sample_t *CacheManager::open(AudioFile *file, size_t initial_samples_needed, int
}
m_ids.unlock();
- if(id != CACHEMANAGER_NOID &&
- initial_samples_needed < file->size) {
+ if(id == CACHE_DUMMYID) {
+ return nodata;
+ }
+
+ if(initial_samples_needed < file->size) {
cache_t c;
c.file = file;
c.channel = channel;
@@ -92,16 +94,12 @@ sample_t *CacheManager::open(AudioFile *file, size_t initial_samples_needed, int
pushEvent(e);
}
- if(id == CACHEMANAGER_NOID) {
- return nodata;
- }
-
return file->data;
}
void CacheManager::close(cacheid_t id)
{
- if(CACHEMANAGER_NOID) return;
+ if(CACHE_DUMMYID) return;
{
event_t e = createEvent(id, CLEAN);
@@ -121,7 +119,7 @@ sample_t *CacheManager::next(cacheid_t id, size_t &size)
{
size = CHUNKSIZE;
- if(id == CACHEMANAGER_NOID) {
+ if(id == CACHE_DUMMYID) {
return nodata;
}
diff --git a/src/cachemanager.h b/src/cachemanager.h
index 4b5c64d..19749a7 100644
--- a/src/cachemanager.h
+++ b/src/cachemanager.h
@@ -38,7 +38,9 @@
#include "audiotypes.h"
#include "audiofile.h"
-#define CACHEMANAGER_NOID -1
+#define CACHE_DUMMYID -2
+#define CACHE_NOID -1
+
class AudioFile;
typedef int cacheid_t;