File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -82,17 +82,19 @@ class AudioSourceSD : public AudioSource {
8282 }
8383
8484 virtual Stream *selectStream (int index) override {
85- LOGI (" selectStream: %d" , index);
86- idx_pos = index;
87- file_name = idx[index];
88- if (file_name==nullptr ) return nullptr ;
89- LOGI (" Using file %s" , file_name);
90- file = SD.open (file_name);
91- return file ? &file : nullptr ;
85+ LOGI (" selectStream SD: %d" , index);
86+ if (index > -1 ) { // avoid invalid position
87+ idx_pos = index;
88+ }
89+ return selectStream (idx[idx_pos]);
9290 }
9391
9492 virtual Stream *selectStream (const char *path) override {
9593 file.close ();
94+ if (path == nullptr ) {
95+ LOGE (" Filename is null" )
96+ return nullptr ;
97+ }
9698 file = SD.open (path);
9799 file_name = file.name ();
98100 LOGI (" -> selectStream: %s" , path);
You can’t perform that action at this time.
0 commit comments