minimp3-rs
minimp3-rs copied to clipboard
Support re-use of a single preallocated pcm buffer
This adds the following structures and methods:
-
Pcm
which is a user provided collection allocated to the size ofMAX_SAMPLES_PER_FRAME
that dereferences to its stored pcm data&[i16]
. -
FrameInfo
which just contains the frame header parts of the frame, excluding the data. -
next_frame_with_pcm
which allows for decoding the frame data in-place a previously allocatedPcm
structure. -
next_frame_with_pcm_future
async version ofnext_frame_into
.
This allows a caller to preallocate and re-use a single pcm buffer so it doesn't have to be allocated on each call to next_frame
to avoid its allocation overhead.
The naming is preliminary, suggestions are welcome!
Thanks. I was not a fan of allocating on every single frame either. I'll take a look :smiley: