(Almost) Lockless Stream Buffering

Sharing (and saving) bytestreams effectively.

Recently, I’ve been working on retooling the audio processing code for serenity, a Discord bot library. Adding features like looping, seeking, and shared resources between calls is made difficult when all input data arrives over pipes from ffmpeg and similar decoders. Due to this, I’ve designed a thread-safe shared stream buffer intended to lock only on accessing and storing new data.