Safe bindings for oboe library
Oboe is a C++ library which makes it easy to build high-performance audio apps on Android. It was created primarily to allow developers to target a simplified API that works across multiple API levels back to API level 16 (Jelly Bean).
Crates structure
- oboe-sys raw unsafe bindings to library which generated using bindgen.
- oboe safe rust wrapper for library which intended to use for android applications
- oboe-demo simple usage example for library (incomplete)
Crate features
The oboe-sys already has pregenerated bindings and precompiled static libraries for the following Android targets:
- armv7
- aarch64
- i686
- x86_64
In case when you want to generate bindings and/or compile library youself you can use features below:
- java-interface which adds interface for some Android platform APIs
- generate-bindings which runs bindgen to generate bindings
- compile-library which runs cmake to compile oboe C++ library
Build issues
The clang-sys crate uses llvm-config for searching libclang library and preparing C/C++ compiler configuration. In order to get proper setup you should add llvm-config to your executables search path.
In case of using tools with libclang under the hood like bindgen you must be sure in proper your setup. Otherwise you get an errors related to missing headers or definitions.
To build applications you need recent version of cargo-apk, which supports latest Android SDK (28+) and NDK (20+). Don't forget to set ANDROID_SDK_ROOT environment variable with paths to installed SDK.
For building host crates which requires C-compiler you may also set HOST_CC environment variable with path to your C-compiler.
Usage example
Playing sine wave in asynchronous (callback-driven) mode:
use ;
// Structure for sound generator
// Default constructor for sound generator
// Audio output callback trait implementation
// ...
// Create playback stream
let mut sine = default
// select desired performance mode
.set_performance_mode
// select desired sharing mode
.set_sharing_mode
// select sound sample format
.
// select channels configuration
.
// set our generator as callback
.set_callback
// open the output stream
.open_stream
.unwrap;
// Start playback
sine.start.unwrap;
// ...