Commit Graph
9 Commits
Author SHA1 Message Date
david gauchard 2fb8d887b1 Fixes when seeking in an MP3 file (#303)
* separate malloc structures

* add desync() for user when randomly seeking in the input file
fix corner cases leading to exceptions when seeking

* additional test when trying to crash-shake everything
with a rotary encoder seeking into the currently played file

* use private instead of static

* remove temporary debug code
2020-09-06 11:41:45 -07:00
Earle F. Philhower, III b7cb0ee8e2 Redo the last packet handling of the MP3 decoder (#266)
Keep track of how many values are actually good in the buffer (before it
was always guaranteed to be the full size) and when EOF is detected,
only shift out valid, good bytes, and return STOP when the unused bytes
are 0 or unchanged from the last pass.

Fixes #265
2020-05-11 02:09:05 -07:00
geoffday67 1fde10daa0 Wait after reading MP3 file for final frames (#263) 2020-04-26 10:07:13 -07:00
Earle F. Philhower, III 8ffebe6496 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.
2018-01-21 13:02:05 -08:00
Earle F. Philhower, III f16cd2b269 Only mad_*_finish after a successful mad_*_start
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.
2018-01-20 18:32:21 -08:00
Earle F. Philhower, III 1690289714 Rationalize the MP3 generation loop
Remove the inInnerDecode flag in the main generation loop and make the
render path more readable in the MP3 decoder object.
2017-12-08 07:16:01 -08:00
Earle F. Philhower, III 9c120a777a Add callbacks for metadata and status reports
All objects can have a metadata and/or status report callback once created.
They will call the source program with the parsed ID3 tag, ICY StreamTitle,
or text and numeric error ID of any interesting event.  It is up to the end
application to figure out what to do with this.  Normally, you'd just print
it to the LCD or Serial port.  But it is possible to detect, say, a buffer
overflow and then switch to a lower bitrate stream for example.
2017-12-06 21:11:23 -08:00
Earle F. Philhower, III 2dac08ef4e Fix mono MP3 decoding causing choppy output
Fixes issue #5 about choppy audio on low bitrate, mono MP3s.

The number of 32-sample elements to generate per MP3 data frame was
set to 36 as that was what I saw on all my source files.  However, on
mono files only half the number of samples are to be generated and
you'd end up with the synthesizer bands running out of energy and
have periods of 0-samples between proper data.

Now simply check each decoded frame for the proper NSMAX value and
only generate that many.  Tested on force.mp3 in the issue referenced.
2017-10-21 21:15:59 -07:00
Earle F. Philhower, III 2cf8fcef2a Bring in files from original projects
The library was originally part of several separate projects.  Make the
needed structure and bring those files in, including some READMEs.
2017-08-12 09:01:42 -07:00