Hans-J. Ubben found a bug where the pinout wasn't being set properly on
ESP32s because the builtInDAC member was not set before calling SetPinout.
Fix per his suggestion.
The ID3 reader was incorrectly skipping extended headers and was
cutting off the last 10 bytes of the last ID3 entry. Correct per
http://id3.org specs.
Fixes#41
With the multiple I2S modes on the ESP32, it makes sense to use a
cleaner class hierarchy for the I2S tools. Make I2SNoDAC into a
subclass of I2S (renamed from I2SDAC) and remove about 80% of the
code which was identical exept for the per-sample bitstream synthesis.
To avoid allocations in the application, preallocate all decoder and
buffer memory in and then never free it. Use the new pre-alloc'd
constructors to generate the playback objects.
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.
Check for NULL input data buffers and set values to NULL after freeing()
local variables to avoid memory corruption on use-after-freee.
Add lots of error injection in the host testing to help find bugs on
the PC where they're easier to debug.
Check for NULL input data buffers and set values to NULL after freeing()
local variables to avoid memory corruption on use-after-freee.
Add lots of error injection in the host testing to help find bugs on
the PC where they're easier to debug.
When the input file(stream) doesn't open, you could end up calling
mp3::stop() which would try and mad_finish structures that were
not yet initialized. Now carry a flag when these are set, and only
_finish when it's set.
Valgrind found another uninitialized use. BitsPerSample was not being
called by the LIBMAD decoder, so it was possible to start out in a bad
state. Now always set it to 16, the decoder native output size.
Channels are initialized to 2, but this setting is always reset on
a per-frame basis anyway.
We removed the MP2-layer I and II decoders to save space, but an occasional
bad frame can come in that, by random chance, specifies one of this type.
Was calling NULL because of that. Now, just skip the frame and no crash.
Enable automatic building of all examples and SAM(speech) on a
commit by using Travis-CI. Build against ESP8266 and ESP32.
Minor tweaks to examples and codebase to allow successful compilation
on ESP32 compiler.
The original I2S setup had the wrong # of bits being sent to the DAC
as well as wrong timeouts specified on the write_sample wrappers.
Fix those, allowing things like WebRadio.ino to work.
The examples were setting a hostname for the WiFi connection, but this is
done via a different call on the ESP32 vs. the ESP8266. To avoid #ifdef
explosion, simply remove the call as it's unneeded anyway.
Thanks to @reaper7 for reporting this in pull #33.
AAC-SBR allows for lower bitrates to have higher quality audio output,
and is used by many web radio stations. It was disables on the ESP8266
due to RAM limitations (about 50KB too little), but the ESP32 has no
such problem. Enable it automatically during compile.
The DATA chunk has a size field that was ignored. When there was additional
metadata after the chunk, however, it would try and play it leading to
clicks. Store and only read that amount of data now.
Emil Plalan found and fixed a bug where the buffer refill would loop
forever (until WDT) when there was no more data to read. For web streams
this wasn't detected, since there isn't really an EOF. However, single
files streamed from a web server would have this problem.
Because the mp3 player is a long living object and needs to allocate
large contiguous chunks on each frame, it is safer to allocate the
large xr[] and tmp[] arrays at the beginning. Add them to the frame
structure which lives the entire time the mp3 object is alive. No
heap allocations are now used by the mp3 player.
Move the imdct_s[] array to progmem, but do a memcpy_P() to stack
as the macros may cause a 16-bit access after optimization. It's only
36 words long and each data is read, anyway, so this doesn't increase
the CPU work significantly.
As seen in issue #21, the MP3 decoder would barf on a single lost sync
error, even though it was not actually a fatel error.
Rewrote the logic to include another Input() on DNF failure, and only die
when Input() actually fails. Seems to fix the problem in issue #21 and also
did not break the WebRadio.
The web interface has a hardcoded 64 char URL limit, even though the
actual url[] array was increased to 96 chars. Use sizeof(url) in the
handler instead of a hardcoded number to enable use of all space.
Addresses issue #21 , again.
The MD and STATUS callbacks can be passed PROGMEM strings, so be sure to
use proper strcpy_p()s to move them to RAM before printing to avoid crashes.
Found during debug of issue #21 .
DecodeNextFrame had a leftover while(1) in the inner loop without any
additional Input() calls, which could lead to an infinite loop on an
error condition. Remove that unneeded loop. Addresses some of the
stuff found in issue #21
Add handing of ID3V2.2.x (tested) and (I think) V2.3.x, and fix the
unsync handling.
Issue 23 found a problem where ID3V2.2 headers, which are very different
from v2.3 and v2.4, caused crashes. Fixing that showed another bug where
the unsyunc flag was not honored and all data was assumed to be unsync'd
causing improper reads of ID3 tags in some circumstances.