4#include "AudioLogger.h"
5#include "AudioTools/Disk/AudioSource.h"
6#include "AudioTools/Disk/SDIndex.h"
34 AudioSourceIdxSD(
const char *startFilePath =
"/",
const char *ext =
".mp3",
int chipSelect = PIN_CS,
bool setupIndex=
true) {
35 start_path = startFilePath;
37 setup_index = setupIndex;
34 AudioSourceIdxSD(
const char *startFilePath =
"/",
const char *ext =
".mp3",
int chipSelect = PIN_CS,
bool setupIndex=
true) {
…}
42#ifdef USE_SD_SUPPORTS_SPI
44 AudioSourceIdxSD(
const char *startFilePath,
const char *ext,
int chipSelect, SPIClass &spiInstance,
bool setupIndex=
true) {
45 start_path = startFilePath;
47 setup_index = setupIndex;
57 LOGW(
"SD.begin cs=%d failed", cs);
62 idx.begin(start_path, extension, file_name_pattern, setup_index);
72 LOGI(
"nextStream: %d", offset);
77 LOGI(
"selectStream: %d",
index);
79 file_name = idx[
index];
80 if (file_name==
nullptr)
return nullptr;
81 LOGI(
"Using file %s", file_name);
82 file = SD.open(file_name);
83 return file ? &file :
nullptr;
89 file_name = file.name();
90 LOGI(
"-> selectStream: %s", path);
91 return file ? &file :
nullptr;
102 const char *
toStr() {
return file_name; }
108 virtual void setPath(
const char *p) { start_path = p; }
111 long size() {
return idx.size();}
114#if defined(USE_SD_NO_NS)
117 SDIndex<fs::SDFS,fs::File> idx{SD};
121 const char *file_name;
122 const char *extension =
nullptr;
123 const char *start_path =
nullptr;
124 const char *file_name_pattern =
"*";
125 bool setup_index =
true;
126 bool is_sd_setup =
false;
127 SPIClass *p_spi =
nullptr;
131#ifdef USE_SD_SUPPORTS_SPI
132 return SD.begin(cs, *p_spi);