Enable static allocated buffers, no dynamic malloc

Because we are allocating objects totaling over 80% of the ESP8266 memory
space, we are very sensitive to memory fragmentation.  While we can control
our own allocs, the IP and SDK can allocate any size, at any time, which
can cause us to not be able to find the large contiguous memory areas we need
for the codes.

Work around this by preallocating, before anything else, buffer memory and
never freeing it.  Pass this memory into the codec and it will allocate from
this block and be guaranteed to always succeed.

This may fix the last of the hangs on the webradio/http streaming, which only
seemed to happen after a stop/start cycle.
This commit is contained in:
Earle F. Philhower, III committed 2018-01-21 13:02:05 -08:00
1 parent d04beb1105
commit 8ffebe6496
23 files changed
+306 -138

No files matched your search

+4 -4
View File
@@ -24,12 +24,12 @@ AudioFileSourceHTTPStream::AudioFileSourceHTTPStream()
{
pos = 0;
reconnectTries = 0;
saveURL = NULL;
saveURL[0] = 0;
}
AudioFileSourceHTTPStream::AudioFileSourceHTTPStream(const char *url)
{
saveURL = NULL;
saveURL[0] = 0;
reconnectTries = 0;
open(url);
}
@@ -46,8 +46,8 @@ bool AudioFileSourceHTTPStream::open(const char *url)
return false;
}
size = http.getSize();
free(saveURL); saveURL = NULL;
saveURL = strdup(url);
strncpy(saveURL, url, sizeof(saveURL));
saveURL[sizeof(saveURL)-1] = 0;
return true;
}