File tree Expand file tree Collapse file tree 2 files changed +20
-9
lines changed Expand file tree Collapse file tree 2 files changed +20
-9
lines changed Original file line number Diff line number Diff line change 135
135
136
136
#ifdef ESP32
137
137
#include "esp32-hal-log.h"
138
- #define USE_A2DP
138
+ // optional libraries
139
+ //#define USE_A2DP
140
+ //#define USE_ESP8266_AUDIO
141
+
139
142
#define USE_PWM
140
143
#define USE_URL_ARDUINO
141
144
#define USE_I2S
142
145
#define USE_AUDIO_SERVER
143
146
#define USE_URLSTREAM_TASK
144
- //#define USE_ESP8266_AUDIO
145
147
146
148
#define PWM_FREQENCY 30000
147
149
#define PWM_START_PIN 12
159
161
160
162
#define I2S_AUTO_CLEAR true
161
163
162
-
163
164
// URLStream
164
165
#define URL_STREAM_CORE 0
165
166
#define URL_STREAM_PRIORITY 2
Original file line number Diff line number Diff line change @@ -181,24 +181,32 @@ namespace audio_tools {
181
181
LOGD (LOG_METHOD);
182
182
LOGI (" SD chipSelect: %d" , chipSelect);
183
183
LOGI (" SD speedMHz: %d" , speedMHz);
184
- if (!sd.begin (SdSpiConfig (chipSelect, DEDICATED_SPI, SD_SCK_MHZ (speedMHz)))) {
185
- LOGE (" SD.begin failed" );
186
- }
184
+ p_cfg = new SdSpiConfig (chipSelect, DEDICATED_SPI, SD_SCK_MHZ (speedMHz));
185
+ owns_cfg = true ;
187
186
start_path = startFilePath;
188
187
exension = ext;
189
188
}
190
189
191
190
// / Costructor with SdSpiConfig
192
191
AudioSourceSdFat (const char * startFilePath, const char * ext, SdSpiConfig &config) {
193
192
LOGD (LOG_METHOD);
194
- if (!sd.begin (config)) {
195
- LOGE (" SD.begin failed" );
196
- }
193
+ p_cfg = &config;
194
+ owns_cfg = false ;
197
195
start_path = startFilePath;
198
196
exension = ext;
199
197
}
198
+
199
+ virtual ~AudioSourceSdFat (){
200
+ if (p_cfg!=nullptr && owns_cfg){
201
+ delete p_cfg;
202
+ }
203
+ }
204
+
200
205
virtual void begin () override {
201
206
LOGD (LOG_METHOD);
207
+ if (!sd.begin (*p_cfg)) {
208
+ LOGE (" SD.begin failed!" );
209
+ }
202
210
idx_pos = 0 ;
203
211
}
204
212
@@ -245,6 +253,8 @@ namespace audio_tools {
245
253
246
254
protected:
247
255
AudioFile file;
256
+ SdSpiConfig *p_cfg = nullptr ;
257
+ bool owns_cfg=false ;
248
258
AudioFs sd;
249
259
size_t idx_pos = 0 ;
250
260
char file_name[MAX_FILE_LEN];
You can’t perform that action at this time.
0 commit comments