From 94b6e63ef94e55fd026eec97bb50a7b50b19f2f3 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 12 Apr 2015 08:25:39 +0200 Subject: Fix bad buffer pointers. --- src/cachemanager.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/cachemanager.cc b/src/cachemanager.cc index 9288ed1..0f84f8c 100644 --- a/src/cachemanager.cc +++ b/src/cachemanager.cc @@ -116,7 +116,7 @@ sample_t *CacheManager::open(AudioFile *file, size_t initial_samples_needed, int localcache[id] = c.front; if(initial_samples_needed < file->size) { - event_t e = createLoadNextEvent(id, c.pos, &c.back); + event_t e = createLoadNextEvent(id, c.pos, &id2cache[id].back); pushEvent(e); } @@ -144,12 +144,13 @@ void CacheManager::close(cacheid_t id) CacheManager::cache_t CacheManager::getNextCache(cacheid_t id) { MutexAutolock l(m_caches); - cache_t c = id2cache[id]; + cache_t &c = id2cache[id]; - sample_t *tmp = id2cache[id].front; - id2cache[id].front = c.back; - id2cache[id].back = tmp; - id2cache[id].pos += CHUNKSIZE; + sample_t *tmp = c.front; + c.front = c.back; + c.back = tmp; + + c.pos += CHUNKSIZE; return c; } @@ -173,7 +174,7 @@ sample_t *CacheManager::next(cacheid_t id, size_t &size) localcache[id] = c.front; if(c.pos < c.file->size) { - event_t e = createLoadNextEvent(id, c.pos + CHUNKSIZE, &c.back); + event_t e = createLoadNextEvent(id, c.pos + CHUNKSIZE, &id2cache[id].back); pushEvent(e); } -- cgit v1.2.3