summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2015-04-25 10:55:06 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2015-04-25 10:55:06 +0200
commit18a5a05fd7a521a93a84cde9b3087a949856a0b9 (patch)
treec09a2479d872a56ced32608d036fa0604b1ec2ec
parent4520f65a409db424d33f5e1edf4dd8eef3449139 (diff)
Fix invariant about c.pos. It shows the position from which the next read call must be made.
-rw-r--r--src/cachemanager.cc17
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)