diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2015-04-25 10:55:06 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2016-01-20 13:24:29 +0100 |
commit | 08199d82515af562bbdd67042a842b6922720de5 (patch) | |
tree | 7dc4c13c43a1f8b29123479b621ccff342c5bfc9 | |
parent | 4b705e26482d2e436eaa967b73b65eb5e3c34edc (diff) |
Fix invariant about c.pos. It shows the position from which the next read call must be made.
-rw-r--r-- | src/cachemanager.cc | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/cachemanager.cc b/src/cachemanager.cc index d7618c0..61fdb3e 100644 --- a/src/cachemanager.cc +++ b/src/cachemanager.cc @@ -152,7 +152,7 @@ sample_t *CacheManager::open(AudioFile *file, size_t initial_samples_needed, 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; + c.pos += size; // Increase audio ref count @@ -162,9 +162,9 @@ 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(c.pos + CHUNKSIZE < file->size) { + if(c.pos < file->size) { cevent_t e = - createLoadNextEvent(c.file, c.channel, c.pos + CHUNKSIZE, c.back); + createLoadNextEvent(c.file, c.channel, c.pos, c.back); e.ready = &id2cache[id].ready; pushEvent(e); } @@ -188,7 +188,7 @@ sample_t *CacheManager::next(cacheid_t id, size_t &size) } if(!c.ready) { - printf("\nNOT READY!\n"); + printf("#%d: NOT READY!\n", id); // TODO: Count and show in UI? } // Swap buffers @@ -201,7 +201,7 @@ sample_t *CacheManager::next(cacheid_t id, size_t &size) c.pos += CHUNKSIZE; if(c.pos < c.file->size) { - cevent_t e = createLoadNextEvent(c.file, c.channel, c.pos + CHUNKSIZE, c.back); + cevent_t e = createLoadNextEvent(c.file, c.channel, c.pos, c.back); c.ready = false; e.ready = &c.ready; pushEvent(e); @@ -212,13 +212,12 @@ sample_t *CacheManager::next(cacheid_t id, size_t &size) void CacheManager::close(cacheid_t id) { - if(id == CACHE_DUMMYID) return; + if(id == CACHE_DUMMYID) { + return; + } cevent_t e = createCloseEvent(id); pushEvent(e); - - // Clean cache_t mapped to event - // Decrement audiofile ref count } void CacheManager::handleLoadNextEvent(cevent_t &e) |