librockbox_ffi at runtime and bind every function to a MethodHandle
downcall.
librockbox_ffi
for every OS/arch — it extracts the matching one at load time, so consumers
need no Rust toolchain. ROCKBOX_FFI_LIB overrides; a repo checkout falls back
to target/release.
FFM’s restricted native calls need
--enable-native-access=ALL-UNNAMED on
the launch command (the project’s Gradle tasks wire this in).Quick start
Player setters follow Kotlin idiom — they return
Unit, so they do not
chain. Construct with Player(Config().apply { volume = 0.8f }) and call
each setter on its own line.Decode a file to PCM
Decoder streams a file through the Rockbox codec engine, yielding
interleaved-stereo S16LE chunks one at a time — no output device required.
API surface
Enums
EqPreset— 21 built-in presets:FLAT,ACOUSTIC,BASS_BOOST,BASS_REDUCER,CLASSICAL,DANCE,DEEP,ELECTRONIC,HIP_HOP,JAZZ,LATIN,LOUDNESS,LOUNGE,PIANO,POP,RNB,ROCK,SMALL_SPEAKERS,TREBLE_BOOST,TREBLE_REDUCER,VOCAL_BOOST.RepeatMode—OFF,ONE,ALL.CrossfeedMode—OFF,MEIER,CUSTOM.ChannelMode—STEREO,MONO,CUSTOM,MONO_LEFT,MONO_RIGHT,KARAOKE,SWAP.CrossfadeMode—OFF,AUTO_SKIP,MANUAL_SKIP,SHUFFLE,SHUFFLE_OR_MANUAL,ALWAYS;MixMode—CROSSFADE,MIX.InsertPosition—PREPEND,INSERT,INSERT_NEXT,INSERT_LAST,INSERT_SHUFFLED,INSERT_LAST_SHUFFLED,REPLACE,INDEX.ReplayGainMode(player) —OFF,TRACK,ALBUM;DspReplayGainMode(Dsp) —TRACK,ALBUM,SHUFFLE,OFF.
Notes
- Rich values (metadata, player status) come back as
Map<String, Any?>, parsed from the ABI’s JSON withorg.json. - Sample buffers are
ShortArrayof interleaved-stereo signed 16-bit samples. - Native memory is freed automatically — handles are
AutoCloseable(use { }), and everychar*/int16*the ABI returns is freed inside the binding.