@@ -21,22 +21,30 @@ namespace fs = std::filesystem;
21
21
*/
22
22
class AudioSourceVFS : public AudioSource {
23
23
public:
24
- // / Default constructor
24
+ // / Default constructor with VFS
25
25
AudioSourceVFS (VFS &vfs, const char *startFilePath = " /" ,
26
26
const char *ext = " " ) {
27
27
start_path = startFilePath;
28
28
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;
31
37
}
32
38
33
39
virtual void begin () override {
34
40
TRACED ();
35
41
idx_pos = 0 ;
36
- p_vfs->begin ();
42
+ if (p_vfs) p_vfs->begin ();
37
43
}
38
44
39
- virtual void end () { p_vfs->end (); }
45
+ virtual void end () {
46
+ if (p_vfs) p_vfs->end ();
47
+ }
40
48
41
49
virtual Stream *nextStream (int offset = 1 ) override {
42
50
LOGI (" nextStream: %d" , offset);
@@ -87,12 +95,17 @@ class AudioSourceVFS : public AudioSource {
87
95
return count;
88
96
}
89
97
98
+ // / Assign the VFS: to be used before calling begin
99
+ void setVFS (VFS &vfs){
100
+ p_vfs = &vfs;
101
+ }
102
+
90
103
protected:
91
104
VFSFile file;
92
105
size_t idx_pos = 0 ;
93
106
const char *file_name;
94
107
const char *exension = " " ;
95
- const char *start_path = nullptr ;
108
+ const char *start_path = " / " ;
96
109
const char *file_name_pattern = " *" ;
97
110
fs::directory_entry entry;
98
111
VFS *p_vfs = nullptr ;
0 commit comments