Move the callback constant strings to PMEM
This commit is contained in:
1 parent
634d0b8d02
commit
d923ebef36
8 files changed
+27
-26
No files matched your search
@@ -27,7 +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");
|
||||
if (!buffer) Serial.printf_P(PSTR("Unable to allocate AudioFileSourceBuffer::buffer[]\n"));
|
||||
writePtr = 0;
|
||||
readPtr = 0;
|
||||
src = source;
|
||||
@@ -79,7 +79,7 @@ uint32_t AudioFileSourceBuffer::read(void *data, uint32_t len)
|
||||
uint32_t bytes = 0;
|
||||
if (!filled) {
|
||||
// Fill up completely before returning any data at all
|
||||
cb.st(STATUS_FILLING, "Refilling buffer");
|
||||
cb.st(STATUS_FILLING, PSTR("Refilling buffer"));
|
||||
length = src->read(buffer, buffSize);
|
||||
writePtr = length % buffSize;
|
||||
filled = true;
|
||||
@@ -116,7 +116,7 @@ uint32_t AudioFileSourceBuffer::read(void *data, uint32_t len)
|
||||
writePtr = 0;
|
||||
length = 0;
|
||||
filled = false;
|
||||
cb.st(STATUS_UNDERFLOW, "Buffer underflow");
|
||||
cb.st(STATUS_UNDERFLOW, PSTR("Buffer underflow"));
|
||||
}
|
||||
|
||||
fill();
|
||||
|
||||
@@ -42,7 +42,7 @@ bool AudioFileSourceHTTPStream::open(const char *url)
|
||||
int code = http.GET();
|
||||
if (code != HTTP_CODE_OK) {
|
||||
http.end();
|
||||
cb.st(STATUS_HTTPFAIL, "Can't open HTTP request");
|
||||
cb.st(STATUS_HTTPFAIL, PSTR("Can't open HTTP request"));
|
||||
return false;
|
||||
}
|
||||
size = http.getSize();
|
||||
@@ -70,20 +70,20 @@ uint32_t AudioFileSourceHTTPStream::readInternal(void *data, uint32_t len, bool
|
||||
{
|
||||
retry:
|
||||
if (!http.connected()) {
|
||||
cb.st(STATUS_DISCONNECTED, "Stream disconnected");
|
||||
cb.st(STATUS_DISCONNECTED, PSTR("Stream disconnected"));
|
||||
http.end();
|
||||
for (int i = 0; i < reconnectTries; i++) {
|
||||
char buff[32];
|
||||
sprintf(buff, "Attempting to reconnect, try %d", i);
|
||||
sprintf_P(buff, PSTR("Attempting to reconnect, try %d"), i);
|
||||
cb.st(STATUS_RECONNECTING, buff);
|
||||
delay(reconnectDelayMs);
|
||||
if (open(saveURL)) {
|
||||
cb.st(STATUS_RECONNECTED, "Stream reconnected");
|
||||
cb.st(STATUS_RECONNECTED, PSTR("Stream reconnected"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!http.connected()) {
|
||||
cb.st(STATUS_DISCONNECTED, "Unable to reconnect");
|
||||
cb.st(STATUS_DISCONNECTED, PSTR("Unable to reconnect"));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -101,7 +101,7 @@ retry:
|
||||
|
||||
size_t avail = stream->available();
|
||||
if (!nonBlock && !avail) {
|
||||
cb.st(STATUS_NODATA, "No stream data available");
|
||||
cb.st(STATUS_NODATA, PSTR("No stream data available"));
|
||||
http.end();
|
||||
goto retry;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ bool AudioFileSourceICYStream::open(const char *url)
|
||||
int code = http.GET();
|
||||
if (code != HTTP_CODE_OK) {
|
||||
http.end();
|
||||
cb.st(STATUS_HTTPFAIL, "Can't open HTTP request");
|
||||
cb.st(STATUS_HTTPFAIL, PSTR("Can't open HTTP request"));
|
||||
return false;
|
||||
}
|
||||
if (http.hasHeader(hdr[0])) {
|
||||
@@ -123,20 +123,20 @@ uint32_t AudioFileSourceICYStream::readInternal(void *data, uint32_t len, bool n
|
||||
{
|
||||
retry:
|
||||
if (!http.connected()) {
|
||||
cb.st(STATUS_DISCONNECTED, "Stream disconnected");
|
||||
cb.st(STATUS_DISCONNECTED, PSTR("Stream disconnected"));
|
||||
http.end();
|
||||
for (int i = 0; i < reconnectTries; i++) {
|
||||
char buff[32];
|
||||
sprintf(buff, "Attempting to reconnect, try %d", i);
|
||||
sprintf_P(buff, PSTR("Attempting to reconnect, try %d"), i);
|
||||
cb.st(STATUS_RECONNECTING, buff);
|
||||
delay(reconnectDelayMs);
|
||||
if (open(saveURL)) {
|
||||
cb.st(STATUS_RECONNECTED, "Stream reconnected");
|
||||
cb.st(STATUS_RECONNECTED, PSTR("Stream reconnected"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!http.connected()) {
|
||||
cb.st(STATUS_DISCONNECTED, "Unable to reconnect");
|
||||
cb.st(STATUS_DISCONNECTED, PSTR("Unable to reconnect"));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -154,7 +154,7 @@ retry:
|
||||
|
||||
size_t avail = stream->available();
|
||||
if (!nonBlock && !avail) {
|
||||
cb.st(STATUS_NODATA, "No stream data available");
|
||||
cb.st(STATUS_NODATA, PSTR("No stream data available"));
|
||||
http.end();
|
||||
goto retry;
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ bool AudioGeneratorAAC::loop()
|
||||
if (ret) {
|
||||
// Error, skip the frame...
|
||||
char buff[48];
|
||||
sprintf(buff, "AAC decode error %d", ret);
|
||||
sprintf_P(buff, PSTR("AAC decode error %d"), ret);
|
||||
cb.st(ret, buff);
|
||||
} else {
|
||||
lastFrameEnd = buffValid - bytesLeft;
|
||||
|
||||
@@ -73,7 +73,7 @@ enum mad_flow AudioGeneratorMP3::ErrorToFlow()
|
||||
if ((lastReadPos==0) && (stream.error==MAD_ERROR_LOSTSYNC)) return MAD_FLOW_CONTINUE;
|
||||
|
||||
strcpy_P(err, mad_stream_errorstr(&stream));
|
||||
snprintf(errLine, sizeof(errLine), "Decoding error '%s' at byte offset %d",
|
||||
snprintf_P(errLine, sizeof(errLine), PSTR("Decoding error '%s' at byte offset %d"),
|
||||
err, (stream.this_frame - buff) + lastReadPos);
|
||||
yield(); // Something bad happened anyway, ensure WiFi gets some time, too
|
||||
cb.st(stream.error, errLine);
|
||||
|
||||
@@ -82,8 +82,9 @@ int UnpackADTSHeader(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset
|
||||
GetBits(&bsi, *bitOffset);
|
||||
|
||||
/* verify that first 12 bits of header are syncword */
|
||||
if (GetBits(&bsi, 12) != 0x0fff) { printf("no ffff\n");
|
||||
return ERR_AAC_INVALID_ADTS_HEADER; }
|
||||
if (GetBits(&bsi, 12) != 0x0fff) {
|
||||
return ERR_AAC_INVALID_ADTS_HEADER;
|
||||
}
|
||||
|
||||
/* fixed fields - should not change from frame to frame */
|
||||
fhADTS->id = GetBits(&bsi, 1);
|
||||
|
||||
+3
-3
@@ -20,7 +20,7 @@ extern int stackfree();
|
||||
/* #undef EXPERIMENTAL */
|
||||
|
||||
/* Define to 1 if you have the <assert.h> header file. */
|
||||
#define HAVE_ASSERT_H 1
|
||||
//#define HAVE_ASSERT_H 1
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#undef HAVE_DLFCN_H
|
||||
@@ -85,7 +85,7 @@ extern int stackfree();
|
||||
#undef HAVE_WAITPID
|
||||
|
||||
/* Define to disable debugging assertions. */
|
||||
/* #undef NDEBUG */
|
||||
#define NDEBUG 1
|
||||
|
||||
/* Define to optimize for accuracy over speed. */
|
||||
/* #undef OPT_ACCURACY */
|
||||
@@ -98,7 +98,7 @@ extern int stackfree();
|
||||
|
||||
/* Define to influence a strict interpretation of the ISO/IEC standards, even
|
||||
if this is in opposition with best accepted practices. */
|
||||
/* #undef OPT_STRICT */
|
||||
#undef OPT_STRICT
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "libmad"
|
||||
|
||||
Reference in new issue
Block a user