Commit Graph

9 Commits

Author SHA1 Message Date
Ben Combee 131b94540e audiomp3: reset decoded_samples when file resets
In testing, I saw that the decoded_samples value kept increasing when I
stopped and restarted playback, as I'd missed setting it back to zero
during the reset operation.
2022-01-02 15:19:25 -06:00
Ben Combee 98b0029a29 audiomp3: add decoded_samples property
In my testing, there is no way to accurately know how far into a MP3 file
you're currently playing. You can use monotonic time, but that can have
drift versus the audio playback system, which may not be running at exactly
the expected sample rate.

To allow syncing animation with timestamps in a MP3 file, this presents a
new property, decoded_samples, that records the number of audio samples
sent out of the decoder. While this may not be a completely accurate time,
due to mixer delays, it's much better position that the monotonic clock
difference.

Implementation is keeping track of this value in the mp3file structure and
adding to it whenever data is sent out of the decoder. The property
implementation was a copy/paste from current properties in the audiomp3
files.
2022-01-01 23:28:43 -06:00
Jeff Epler 621953c960
Additional missing-prototypes fixes
I think this correctly enables missing-prototypes in atmel-samd
and raspberrypi ports.
2021-11-10 10:55:53 -06:00
Jeff Epler d67acb8a64 MP3Decoder: Fix playback stopping issue
Closes: #5164
2021-08-17 10:03:47 -05:00
Dan Halbert 33bbb8b1f4 RP2040 PWMAudioOut: Release DMA channels after play has finished. 2021-07-01 17:36:29 -04:00
microDev a52eb88031
run code formatting script 2021-03-15 19:27:36 +05:30
Jeff Epler bdab6c12d4 MP3Decoder: take advantage of background callback
Before this, the mp3 file would be read into the in-memory buffer
only when new samples were actually needed.  This meant that the time
to read mp3 content always counted against the ~22ms audio buffer length.

Now, when there's at least 1 full disk block of free space in the input
buffer, we can request that the buffer be filled _after_ returning from
audiomp3_mp3file_get_buffer and actually filling the DMA pointers.  In
this way, the time taken for reading MP3 data from flash/SD is less
likely to cause an underrun of audio DMA.

The existing calls to fill the inbuf remain, but in most cases during
streaming these become no-ops because the buffer will be over half full.
2020-07-15 09:26:47 -05:00
Jeff Epler dd6010a17e Fix more build problems 2020-01-06 13:35:43 -06:00
Jeff Epler dc729718eb audiomp3: rename to MP3Decoder 2020-01-06 07:51:41 -06:00