3 #include "AudioTools/CoreAudio/BaseStream.h"
4 #include "AudioTools/CoreAudio/AudioBasic/StrView.h"
9 # define READTYPE uint8_t
27 FileLoopT(FileType
file,
int count = -1,
int rewindPos = -1) {
40 current_file.readBytes(tmp, 4);
45 current_file.seek(start_pos);
47 size_open = total_size;
75 return total_size == -1 ? current_file.size() : total_size;
87 int available()
override {
89 if (total_size!=-1)
return size_open;
91 return isLoopActive() ? DEFAULT_BUFFER_SIZE : current_file.available();
94 size_t readBytes(uint8_t *data,
size_t len)
override {
95 LOGD(
"FileLoopT::readBytes %d at %d", (
int)len, (
int)current_file.position());
102 copy_len = min((
int)len, size_open);
106 int result1 = current_file.readBytes((READTYPE *)data, copy_len);
108 int open = copy_len - result1;
110 if (start_pos < 0) start_pos = 0;
111 LOGI(
"seek %d", start_pos);
113 current_file.seek(start_pos);
115 if (callback!=
nullptr){
118 result1 = current_file.readBytes((READTYPE*)data + result1, open);
123 int result = result1 + result2;
139 size_t write(
const uint8_t* data,
size_t len) {
return current_file.write(data, len);}
146 void (*callback)(FileLoopT &loop) =
nullptr;
147 FileType current_file;