Skip to content

Commit 10957ae

Browse files
committed
AudioSourceVFS: constructor w/o VFS
1 parent 9d44c57 commit 10957ae

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

src/AudioTools/Disk/AudioSourceVFS.h

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,30 @@ namespace fs = std::filesystem;
2121
*/
2222
class AudioSourceVFS : public AudioSource {
2323
public:
24-
/// Default constructor
24+
/// Default constructor with VFS
2525
AudioSourceVFS(VFS &vfs, const char *startFilePath = "/",
2626
const char *ext = "") {
2727
start_path = startFilePath;
2828
exension = ext;
29-
timeout_auto_next_value = 600000;
30-
p_vfs = &vfs;
29+
setVFS(vfs);
30+
}
31+
32+
/// Default constructor w/o VFS
33+
AudioSourceVFS(const char *startFilePath = "/",
34+
const char *ext = "") {
35+
start_path = startFilePath;
36+
exension = ext;
3137
}
3238

3339
virtual void begin() override {
3440
TRACED();
3541
idx_pos = 0;
36-
p_vfs->begin();
42+
if (p_vfs) p_vfs->begin();
3743
}
3844

39-
virtual void end() { p_vfs->end(); }
45+
virtual void end() {
46+
if (p_vfs) p_vfs->end();
47+
}
4048

4149
virtual Stream *nextStream(int offset = 1) override {
4250
LOGI("nextStream: %d", offset);
@@ -87,12 +95,17 @@ class AudioSourceVFS : public AudioSource {
8795
return count;
8896
}
8997

98+
/// Assign the VFS: to be used before calling begin
99+
void setVFS(VFS &vfs){
100+
p_vfs = &vfs;
101+
}
102+
90103
protected:
91104
VFSFile file;
92105
size_t idx_pos = 0;
93106
const char *file_name;
94107
const char *exension = "";
95-
const char *start_path = nullptr;
108+
const char *start_path = "/";
96109
const char *file_name_pattern = "*";
97110
fs::directory_entry entry;
98111
VFS *p_vfs = nullptr;

0 commit comments

Comments
 (0)