summaryrefslogtreecommitdiff
path: root/src/audiocache.cc
diff options
context:
space:
mode:
authorAndré Nusser <andre.nusser@googlemail.com>2016-01-29 12:54:02 +0100
committerAndré Nusser <andre.nusser@googlemail.com>2016-01-29 12:54:02 +0100
commit1b32041bb54e1c9310853c9942498ec223d8106a (patch)
tree64fb06c0a3fefd119cccd17483cb6c1355c3de23 /src/audiocache.cc
parent8faba64d538753d09765f2fe003cc08bc5ff2712 (diff)
wip 2
Diffstat (limited to 'src/audiocache.cc')
-rw-r--r--src/audiocache.cc15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/audiocache.cc b/src/audiocache.cc
index e098fd0..2ca0616 100644
--- a/src/audiocache.cc
+++ b/src/audiocache.cc
@@ -96,17 +96,20 @@ sample_t* AudioCache::open(const AudioFile& file, size_t initial_samples_needed,
c.front = nullptr; // This is allocated when needed.
c.back = nullptr; // This is allocated when needed.
- // cropped_size is the preload chunk size cropped to sample length.
- size_t cropped_size = file.preloadedsize - c.localpos;
- cropped_size /= framesize;
- cropped_size *= framesize;
- cropped_size += initial_samples_needed;
+ size_t cropped_size;
if(file.preloadedsize == file.size)
{
// We have preloaded the entire file, so use it.
cropped_size = file.preloadedsize;
}
+ else
+ {
+ // cropped_size is the preload chunk size cropped to sample length.
+ cropped_size = file.preloadedsize - c.localpos;
+ cropped_size -= cropped_size % framesize;
+ cropped_size += initial_samples_needed;
+ }
c.preloaded_samples = file.data;
c.preloaded_samples_size = cropped_size;
@@ -114,7 +117,7 @@ sample_t* AudioCache::open(const AudioFile& file, size_t initial_samples_needed,
// Next read from disk will read from this point.
c.pos = cropped_size;//c.preloaded_samples_size;
- // Only load next buffer if there are more data in the file to be loaded...
+ // Only load next buffer if there is more data in the file to be loaded...
if(c.pos < file.size)
{
if(c.back == nullptr)