anthumchris / fetch-stream-audio

Low Latency web audio playback examples for decoding audio streams in chunks with Fetch & Streams APIs

Home Page:https://fetch-stream-audio.anthum.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reduce AudioBuffer Memory Usage

anthumchris opened this issue · comments

@teropa made a great recommendation to add backpressure to the decoder. This would prevent excessive memory use by limiting the number of unplayed, decoded AudioBuffers. One suggestion is to control the amount of decoded audio based on time (seconds), because DecodedAudioPlaybackBuffer grows audio buffers in size exponentially, creating lots of small buffers at first to provide low latency playback and then growing the sizes to create fewer, larger AudioBuffers, which reduces CPU and audio glitches.