summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2015-04-23 15:53:48 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2016-01-20 13:24:29 +0100
commit4b705e26482d2e436eaa967b73b65eb5e3c34edc (patch)
tree478b81dbd292beb828b759a4670a486867ccb4eb /src
parentb67e30cb862ab640e4a7ced48b1905b2421885b9 (diff)
Fix size checks in initial copy from preloaded data. Re-enable close event.
Diffstat (limited to 'src')
-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);