feat(android): initialise Oboe runtime context

This commit is contained in:
Edison Jwa
2026-05-20 14:52:33 +09:00
parent c87b47f064
commit d6763787aa
4 changed files with 9 additions and 8 deletions
@@ -34,7 +34,7 @@
related in-call audio routing operations. -->
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<!-- SDD-trace: cpal-on-Android research report; supports SCO/BLE
<!-- SDD-trace: Android Oboe voice backend; supports SCO/BLE
headset routing on API 31+. Declared here so the platform
allows querying / connecting to bonded Bluetooth audio devices
for the voice session. -->
@@ -29,9 +29,9 @@ class MainActivity : FlutterActivity() {
companion object {
/**
* JNI entry point implemented in `chanora_bridge::android_init`.
* Initialises `ndk_context` with our Activity so cpal-on-Oboe can
* find Android audio services when `chanora_audio` starts the
* capture / playback streams.
* Initialises `ndk_context` with our Activity so the direct Oboe
* backend can find Android audio services when `chanora_audio`
* starts the capture / playback streams.
*
* Trace: SDD-105 (AndroidJniBootstrap). Signature must remain stable;
* the Rust side declares the matching `extern "system"` symbol.
+1 -1
View File
@@ -28,7 +28,7 @@ tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
# Android: route `tracing` output to logcat so a user can see protocol
# and audio diagnostics via `adb logcat -s chanora`. Also brings in the
# JNI bindings we need to initialise `ndk_context` for cpal-on-Oboe.
# JNI bindings we need to initialise `ndk_context` for the Android Oboe backend.
[target.'cfg(target_os = "android")'.dependencies]
tracing-android = "0.2"
log = "0.4"
+4 -3
View File
@@ -1,7 +1,7 @@
//! Android-specific JNI lifecycle helpers.
//!
//! On Android the Flutter engine starts our cdylib but does not push
//! anything into `ndk_context` (the global the cpal-on-Oboe backend
//! anything into `ndk_context` (the global the Android Oboe backend
//! reads to find Android audio services). Without that, the first
//! audio call hangs / fails.
//!
@@ -14,7 +14,8 @@
//! application Context. That JNI function pushes both the
//! `JavaVM*` and a `Context` global ref into `ndk_context`.
//!
//! After that, cpal can open the default input/output devices.
//! After that, the Android Oboe backend can open the default
//! input/output devices.
#![cfg(target_os = "android")]
@@ -46,7 +47,7 @@ pub extern "system" fn JNI_OnLoad(
}
/// Called by `MainActivity.onCreate` with the application Context.
/// Initialises the `ndk_context` so cpal's Oboe backend can locate
/// Initialises the `ndk_context` so the Oboe backend can locate
/// the Android audio services.
///
/// Symbol mangling note: Kotlin / JNI mangles the underscore in