From d2923a32d3682e161c26491da4d1fa55f82570b5 Mon Sep 17 00:00:00 2001 From: Damjan Adamic Date: Sun, 17 Apr 2016 18:37:24 +0200 Subject: [PATCH] Fixed bug in Disk Cache: reads bigger than cache block size were not handled properly --- radio/src/disk_cache.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/radio/src/disk_cache.cpp b/radio/src/disk_cache.cpp index d2e5d9123..4933a2d9f 100644 --- a/radio/src/disk_cache.cpp +++ b/radio/src/disk_cache.cpp @@ -96,6 +96,12 @@ DRESULT DiskCache::read(BYTE drv, BYTE* buff, DWORD sector, UINT count) // return __disk_read(drv, buff, sector, count); // } + // if read is bigger than cache block, then read it directly without using cache + if (count > DISK_CACHE_BLOCK_SECTORS) { + TRACE_DISK_CACHE("\t\t big read(%u, %u)", this, (uint32_t)sector, (uint32_t)count); + return __disk_read(drv, buff, sector, count); + } + for(int n=0; n < DISK_CACHE_BLOCKS_NUM; ++n) { if (blocks[n].read(buff, sector, count)) { ++stats.noHits;