Skip to main content

Crate rockbox_codecs

Crate rockbox_codecs 

Source
Expand description

Audio decoding with Rockbox’s codecs as a reusable library.

The actual decoders are the Rockbox firmware codecs (lib/rbcodec/codecs/ plus their vendored decoder libraries — libmad, libtremor, libffmpegFLAC, libfaad, …), compiled by build.rs and driven through Rockbox’s codec_api by a small C shim modeled on the upstream warble test player.

let mut dec = rockbox_codecs::Decoder::open("song.flac").unwrap();
println!("{} — {}", dec.metadata().artist, dec.metadata().title);
while let Some(chunk) = dec.next_chunk() {
    // chunk.pcm: interleaved stereo i16 at chunk.sample_rate Hz
}

All 29 codecs of Rockbox’s static-link set are feature-gated (flac, mpa, vorbis, alac, aac, opus, wma, ape, …) so you only compile the decoders you need.

§Concurrency

Rockbox codecs share one global codec_api instance, so one decode session runs at a time: Decoder::open blocks until any other live Decoder is dropped. Within a session, decoding runs on a dedicated thread and PCM is pulled through a bounded channel.

Structs§

Chunk
One buffer of decoded audio: interleaved stereo i16 frames.
Decoder
A running decode session for one audio file.
Metadata
Parsed metadata for one audio file.

Enums§

Error
Errors returned by Decoder::open.