Commit Graph
15 Commits
Author SHA1 Message Date
Christian Ferbar 074dfd47b0 Allow playing wav files via HTTPStream (#224)
* ReadWAVInfo(): print error message if seek() fails

* AudioFileSourceHTTPStream::seek() print error message - not implemented

* AudioFileSourceBuffer::seek if SEEK_CUR and seek_len < writePtr keep the buffer (fix for HTTPStream)

* Update AudioFileSourceBuffer.cpp
2019-11-24 08:52:50 -07:00
david gauchard 4fed6a230f install and use a global audioLogger instead of Serial (#198)
* use of global audioLogger-> instead of Serial.

* default to silence

* initialize logger in examples
2019-07-24 10:02:21 -07:00
Earle F. Philhower, III 2d8a97767c Update to remove warnings, fix new 8266 core rev
Remove build warnings and use the faster pgm_read_*_aligned macros to
update to the latest ESP8266 Arduino core.
2019-04-12 15:45:34 -07:00
h3ndrik 05a78dce2a Make stream reads orders of magnitude faster (fixes #38) (#44)
Fix by @h3ndrik 
* Use correct read for stream data on the ESP32 (fixes #38)
* Adjust types for read()
2018-01-31 19:18:35 -08: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 d04beb1105 More paranoid input checks, random error injection
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.
2018-01-20 21:08:13 -08:00
Earle F. Philhower, III d923ebef36 Move the callback constant strings to PMEM 2017-12-15 12:03:05 -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 432f892d70 Add retry logic to HTTP Streams
On a 0-byte read or a disconnect, optionally automatically reconnect
up to a user specified number of tries with a delay between each attempt.
2017-11-22 07:20:42 -08:00
Earle F. Philhower, III 4b2bbe7ad5 Preliminary ICY HTTP stream support
Add a subclass of the HTTPStream that can extract the ICY metadata.
Needs to implement a callback function or parse it internally and expose
a class variable to let the UI see the current stream information.
2017-11-21 11:55:23 -08:00
Earle F. Philhower, III 9c3f579c96 Add buffering to MP3 streaming
The buffer class seems to work very well to avoid hiccups while
streaming from the web, so add it by default to the example to
make it easier for users to cut-n-paste and make it work.
2017-11-20 12:15:32 -08:00
Earle F. Philhower, III c669a329c4 Add double-buffer input file source
AudioFileSourceBuffer allows system RAM to be used to buffer an
input file (normally just a HTTP Stream) to help avoid hiccups.
This could also be subclassed to use an external SRAM, at some
soint.
2017-11-14 07:08:45 -08:00
Earle F. Philhower, III c5da8c3062 Add timeout and HTTP size to streamer EOF checks
HTTPStreamer assumed the server would drop the connection when no more
data was available to be transferred from the source file.
For individual files, though, the web server will send the expected length
in the headers and leave the connection open (i.e. to recycle the connection
and accelerate web browsing).  In this case, the streamer would effectively
hang waiting for more data than was being transmitted.

Now check the read data against the expected data, and also add a 0.5s
timeout no matter what to the reading.

Tested on streaming and served files, seems to work fine.
2017-10-22 10:04:19 -07:00
Earle F. Philhower, III 0a453a077a Warning and static removal
Clean up compiler warnings and make static variables in class functions
into class variables where they belong.
2017-08-15 20:58:16 -07:00
Earle F. Philhower, III 64ceb33a31 Add a HTTP streamer music "file" reader class
Implements a simple and stupid HTTP stream reader to allow for ShoutCast
and other MP3 radio streaming to happen.  Presently seems to stutter on
128K, 44.1KHz streams, but may be better on lower bitrates.
2017-08-14 19:47:22 -07:00