Store AAC/MP3 flag in EEPROM for WebRadio
This commit is contained in:
1 parent
9f42358f31
commit
634d0b8d02
3 files changed
+10
-6
No files matched your search
@@ -52,6 +52,7 @@ bool isAAC = false;
|
||||
|
||||
typedef struct {
|
||||
char url[64];
|
||||
bool isAAC;
|
||||
int16_t checksum;
|
||||
} Settings;
|
||||
|
||||
@@ -282,6 +283,7 @@ void setup()
|
||||
|
||||
if (s.checksum == sum) {
|
||||
strcpy(url, s.url);
|
||||
isAAC = s.isAAC;
|
||||
Serial.printf_P(PSTR("Resuming stream from EEPROM: %s"), url);
|
||||
newUrl = true;
|
||||
}
|
||||
@@ -298,6 +300,7 @@ void StartNewURL()
|
||||
// Store in "EEPROM" to restart automatically
|
||||
Settings s;
|
||||
strcpy(s.url, url);
|
||||
s.isAAC = isAAC;
|
||||
s.checksum = 0x1234;
|
||||
for (size_t i=0; i<sizeof(url); i++) s.checksum += url[i];
|
||||
uint8_t *ptr = reinterpret_cast<uint8_t *>(&s);
|
||||
@@ -310,7 +313,7 @@ void StartNewURL()
|
||||
|
||||
file = new AudioFileSourceICYStream(url);
|
||||
file->RegisterMetadataCB(MDCallback, NULL);
|
||||
buff = new AudioFileSourceBuffer(file, 1500);
|
||||
buff = new AudioFileSourceBuffer(file, 4096);
|
||||
buff->RegisterStatusCB(StatusCallback, NULL);
|
||||
out = new AudioOutputI2SDAC();
|
||||
decoder = isAAC ? (AudioGenerator*) new AudioGeneratorAAC() : (AudioGenerator*) new AudioGeneratorMP3();
|
||||
@@ -335,7 +338,6 @@ void loop()
|
||||
{
|
||||
static int lastms = 0;
|
||||
static int retryms = 0;
|
||||
|
||||
if (millis()-lastms > 1000) {
|
||||
lastms = millis();
|
||||
Serial.printf_P(PSTR("Running for %d seconds...Free mem=%d\n"), lastms/1000, ESP.getFreeHeap());
|
||||
@@ -345,7 +347,7 @@ void loop()
|
||||
retryms = 0;
|
||||
newUrl = true;
|
||||
}
|
||||
|
||||
|
||||
if (newUrl) {
|
||||
StartNewURL();
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ AudioFileSourceBuffer::AudioFileSourceBuffer(AudioFileSource *source, int buffSi
|
||||
{
|
||||
buffSize = buffSizeBytes;
|
||||
buffer = (uint8_t*)malloc(sizeof(uint8_t) * buffSize);
|
||||
if (!buffer) Serial.printf_P("Unable to allocate AudioFileSourceBuffer::buffer[]\n");
|
||||
writePtr = 0;
|
||||
readPtr = 0;
|
||||
src = source;
|
||||
|
||||
@@ -241,7 +241,8 @@ extern "C" {
|
||||
#include <cont.h>
|
||||
extern cont_t g_cont;
|
||||
|
||||
void stack(const char *s, const char *t, int i) {
|
||||
void stack(const char *s, const char *t, int i)
|
||||
{
|
||||
(void) t;
|
||||
(void) i;
|
||||
register uint32_t *sp asm("a1");
|
||||
@@ -259,8 +260,8 @@ extern "C" {
|
||||
Serial.printf_P(PSTR("out of heap!\n"));
|
||||
}
|
||||
Serial.flush();
|
||||
laststack=freestack;
|
||||
lastheap=freeheap;
|
||||
laststack = freestack;
|
||||
lastheap = freeheap;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user