summaryrefslogtreecommitdiff
path: root/src/cachemanager.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2015-04-23 15:53:48 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2015-04-23 15:53:48 +0200
commit4520f65a409db424d33f5e1edf4dd8eef3449139 (patch)
tree074bf756b4628c496a5cdf04a4043150742f3aeb /src/cachemanager.cc
parent672e34d2f2066dcffdd54b554fbe9b89d5b85470 (diff)
Fix size checks in initial copy from preloaded data. Re-enable close event.
Diffstat (limited to 'src/cachemanager.cc')
-rw-r--r--src/cachemanager.cc6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/cachemanager.cc b/src/cachemanager.cc
index e6c43cc..d7618c0 100644
--- a/src/cachemanager.cc
+++ b/src/cachemanager.cc
@@ -149,7 +149,7 @@ sample_t *CacheManager::open(AudioFile *file, size_t initial_samples_needed,
c.back = new sample_t[CHUNKSIZE];
size_t size = CHUNKSIZE;
- if(size > file->size) size = file->size;
+ if(size > (file->preloadedsize - c.pos)) size = (file->preloadedsize - c.pos);
memcpy(c.front, c.file->data + c.pos, size * sizeof(sample_t));
c.ready = false;
//c.pos += size;
@@ -162,7 +162,7 @@ sample_t *CacheManager::open(AudioFile *file, size_t initial_samples_needed,
}
// Only load next buffer if there are more data in the file to be loaded...
- if(initial_samples_needed < file->size) {
+ if(c.pos + CHUNKSIZE < file->size) {
cevent_t e =
createLoadNextEvent(c.file, c.channel, c.pos + CHUNKSIZE, c.back);
e.ready = &id2cache[id].ready;
@@ -212,8 +212,6 @@ sample_t *CacheManager::next(cacheid_t id, size_t &size)
void CacheManager::close(cacheid_t id)
{
-return;
-
if(id == CACHE_DUMMYID) return;
cevent_t e = createCloseEvent(id);