diff options
author | André Nusser <andre.nusser@googlemail.com> | 2016-01-29 11:41:27 +0100 |
---|---|---|
committer | André Nusser <andre.nusser@googlemail.com> | 2016-01-29 11:41:27 +0100 |
commit | 8faba64d538753d09765f2fe003cc08bc5ff2712 (patch) | |
tree | 97b919714c6251b52ca89047e119e88c72386bc0 /src/audiocache.cc | |
parent | 35a301aa644d0be234f2920f447fe1a3b4a42b26 (diff) |
wip 1
Diffstat (limited to 'src/audiocache.cc')
-rw-r--r-- | src/audiocache.cc | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/audiocache.cc b/src/audiocache.cc index 237a3ff..e098fd0 100644 --- a/src/audiocache.cc +++ b/src/audiocache.cc @@ -62,10 +62,10 @@ void AudioCache::deinit() } // Invariant: initial_samples_needed < preloaded audio data -sample_t* AudioCache::open(AudioFile* file, size_t initial_samples_needed, +sample_t* AudioCache::open(const AudioFile& file, size_t initial_samples_needed, int channel, cacheid_t& id) { - if(!file->isValid()) + if(!file.isValid()) { // File preload not yet ready - skip this sample. id = CACHE_DUMMYID; @@ -87,7 +87,7 @@ sample_t* AudioCache::open(AudioFile* file, size_t initial_samples_needed, // Get the cache_t connected with the registered id. cache_t& c = id_manager.getCache(id); - c.afile = &event_handler.openFile(file->filename); + c.afile = &event_handler.openFile(file.filename); c.channel = channel; // Next call to 'next()' will read from this point. @@ -97,25 +97,25 @@ sample_t* AudioCache::open(AudioFile* file, size_t initial_samples_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; + size_t cropped_size = file.preloadedsize - c.localpos; cropped_size /= framesize; cropped_size *= framesize; cropped_size += initial_samples_needed; - if(file->preloadedsize == file->size) + if(file.preloadedsize == file.size) { // We have preloaded the entire file, so use it. - cropped_size = file->preloadedsize; + cropped_size = file.preloadedsize; } - c.preloaded_samples = file->data; + c.preloaded_samples = file.data; c.preloaded_samples_size = cropped_size; // 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... - if(c.pos < file->size) + if(c.pos < file.size) { if(c.back == nullptr) { |