summaryrefslogtreecommitdiff
path: root/src/audiofile.h
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2017-03-22 20:19:45 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2017-03-23 20:17:53 +0100
commit6c5b062ba00388951b67dc1ea555dc6ad8af4ede (patch)
tree2ebc3884a6423d39c6729bd7e1e018e1f504d49a /src/audiofile.h
parenta6c134a82143acd32f80b2f9679f8fcf194a5402 (diff)
Use cache limit for preloading. Add re-load support through reload counter. Refactor AudioFile.
Diffstat (limited to 'src/audiofile.h')
-rw-r--r--src/audiofile.h22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/audiofile.h b/src/audiofile.h
index c310a55..07b40dd 100644
--- a/src/audiofile.h
+++ b/src/audiofile.h
@@ -29,27 +29,27 @@
#include <string>
#include <map>
#include <vector>
+#include <limits>
#include <sndfile.h>
#include "mutex.h"
#include "audio.h"
-#define ALL_SAMPLES -1
-
-class AudioFile {
+class AudioFile
+{
public:
- AudioFile(const std::string& filename, int filechannel);
+ AudioFile(const std::string& filename, std::size_t filechannel);
~AudioFile();
- void load(int num_samples = ALL_SAMPLES);
+ void load(std::size_t sample_limit = std::numeric_limits<std::size_t>::max());
void unload();
bool isLoaded() const;
- volatile size_t size{0}; // Full size of the file
- volatile size_t preloadedsize{0}; // Number of samples preloaded (in data)
- sample_t *data{nullptr};
+ volatile std::size_t size{0}; // Full size of the file
+ volatile std::size_t preloadedsize{0}; // Number of samples preloaded (in data)
+ sample_t* data{nullptr};
std::string filename;
@@ -57,9 +57,9 @@ public:
Mutex mutex;
- int filechannel;
+ std::size_t filechannel;
private:
- void *magic;
- volatile bool is_loaded;
+ void* magic{nullptr};
+ volatile bool is_loaded{false};
};