summaryrefslogtreecommitdiff
path: root/src/cachemanager.cc
diff options
context:
space:
mode:
authorJonas Suhr Christensen <jsc@umbraculum.org>2015-04-10 20:35:43 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2016-01-20 13:22:08 +0100
commit0c474ca66e1d510cb3fbcfdce498afbf9e0c190d (patch)
tree734d289abb4517f63370ec782a3073b5d4706654 /src/cachemanager.cc
parent867c42996ec1ff3cd9eb9ec9347f049edceffea9 (diff)
Added CACHE_DUMMYID.
Diffstat (limited to 'src/cachemanager.cc')
-rw-r--r--src/cachemanager.cc18
1 files changed, 8 insertions, 10 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;
}