Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ env:
CARGO_TERM_COLOR: always

# Self-hosted jobs run on the netcup server's `audiobridge` runner, which already has the
# toolchains (Rust + targets, JDK 17, Android SDK/NDK r23, cargo-ndk 3.x, cargo-xwin + LLVM).
# toolchains (Rust + targets, JDK 17, Android SDK/NDK r30, cargo-ndk 4.x, cargo-xwin + LLVM).
# Fork PRs are never executed there. CARGO_BUILD_JOBS=2 leaves half of its 4 cores free.
jobs:
rust:
Expand All @@ -31,7 +31,7 @@ jobs:
- name: Clippy (host)
run: cargo clippy -p audiobridge-core -p audiobridge-android --all-targets -- -D warnings
- name: Clippy (android arm64)
run: cargo ndk -t arm64-v8a clippy -p audiobridge-android --all-targets -- -D warnings
run: cargo ndk -t arm64-v8a --platform 26 clippy -p audiobridge-android --all-targets -- -D warnings
- name: Core tests
# the real-network integration tests are timing-sensitive; they are run locally
run: cargo test -p audiobridge-core --lib --test rt_alloc
Expand Down
8 changes: 4 additions & 4 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ cargo test -p audiobridge-android # host-only pure modules (sta
cargo clippy -p <crate> --all-targets -- -D warnings
cargo build -p audiobridge-desktop --release # target\release\AudioBridge.exe
powershell -File scripts\install-desktop.ps1 [-SkipBuild] [-NoFirewall]
cargo ndk -t arm64-v8a -o android/app/src/main/jniLibs build --release -p audiobridge-android
cargo ndk -t arm64-v8a clippy -p audiobridge-android --all-targets -- -D warnings # Android clippy needs cargo-ndk (cc needs NDK clang)
cargo ndk -t arm64-v8a --platform 26 build --release -p audiobridge-android # target/aarch64-linux-android/release/libaudiobridge.so (no -o: cargo-ndk 4 would also copy iroh's cdylibs)
cargo ndk -t arm64-v8a --platform 26 clippy -p audiobridge-android --all-targets -- -D warnings # Android clippy needs cargo-ndk (cc needs NDK clang)
```
- Debug-only isolation: `AUDIOBRIDGE_DEV_DIR=<absolute temp directory>` gives a separate identity, logs and instance mutex/events; seed `settings.json` with `"autostart": false` before testing beside the installed app. Release builds ignore this variable.
- **APK:** run Gradle from inside `android/` (PowerShell: `Set-Location android; .\gradlew.bat :app:assembleDebug`). It runs `buildRustLib` (cargo-ndk) automatically; add `-PskipRust` to reuse the `.so` already in `jniLibs`. Also: `:app:testDebugUnitTest`, `:app:lintDebug`.
Expand Down Expand Up @@ -117,8 +117,8 @@ cargo ndk -t arm64-v8a clippy -p audiobridge-android --all-targets -- -D warning
- **Rust:** stable rustc ≥ 1.92 (eframe 0.35). Developed on 1.94.1; there is no `rust-toolchain` file. Don't bump eframe without checking its MSRV.
- **Opus:** vendored native libopus (`crates/opus-sys`, float build, `USE_ALLOCA`) built with `cc`. Keep stack temporaries (`USE_ALLOCA`/`VAR_ARRAYS`): decoding runs inside `PlayoutHandle::fill`, so it must not heap-allocate. Don't switch back to `unsafe-libopus` (its c2rust VLAs allocate on every decode).
- **Android:**
- NDK r23 (`23.1.7779620`) via cargo-ndk.
- `[package.metadata.ndk] platform = 26`, because AAudio starts at API 26.
- NDK r30 (`30.0.16248370`) via cargo-ndk 4.x.
- Always pass `--platform 26` to cargo-ndk, because AAudio starts at API 26 (cargo-ndk 4 ignores `[package.metadata.ndk]` and defaults to API 21, which fails with `-laaudio`).
- Use raw `ndk-sys` AAudio; API-28 setters are looked up with `dlsym`. Never enable the `ndk` crate's `api-level-28` feature: the library would fail to load on API 26/27.
- Input preset `VoiceRecognition`, never `VoiceCommunication`, which forces Bluetooth SCO/HFP and ruins A2DP.
- **Android build:** AGP 8.10.1, Kotlin 2.2.0, Gradle 8.11.1 wrapper, JDK 17 target. Compose versions are pinned explicitly (no BOM). `FAIL_ON_PROJECT_REPOS` means repositories are declared only in `settings.gradle.kts`.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ See [AGENTS.md](AGENTS.md) for the detailed developer guide.
```powershell
cargo test -p audiobridge-core
cargo build -p audiobridge-desktop --release # target\release\AudioBridge.exe
cd android; .\gradlew.bat :app:assembleDebug # needs Android SDK, NDK r23 and cargo-ndk
cd android; .\gradlew.bat :app:assembleDebug # needs Android SDK, NDK r30 and cargo-ndk 4.x
```

Rust ≥ 1.92. Opus is vendored and built with `cc`, so you don't need cmake.
Expand Down
2 changes: 1 addition & 1 deletion README.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ AudioBridge передаёт весь звук компьютера на Android
```powershell
cargo test -p audiobridge-core
cargo build -p audiobridge-desktop --release # target\release\AudioBridge.exe
cd android; .\gradlew.bat :app:assembleDebug # нужны Android SDK, NDK r23 и cargo-ndk
cd android; .\gradlew.bat :app:assembleDebug # нужны Android SDK, NDK r30 и cargo-ndk 4.x
```

Подробное описание архитектуры — в [AGENTS.md](AGENTS.md). Pull request'ы приветствуются, см. [CONTRIBUTING.md](CONTRIBUTING.md).
Expand Down
12 changes: 11 additions & 1 deletion android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ dependencies {
// Skip with -PskipRust (e.g. when the Rust toolchain is unavailable and a prebuilt .so is already present).
val repoRoot: File = rootProject.projectDir.parentFile
val jniLibsDir: File = project.file("src/main/jniLibs")
val rustTargetDir: File = System.getenv("CARGO_TARGET_DIR")?.let { repoRoot.resolve(it) } ?: repoRoot.resolve("target")
val skipRust: Boolean = providers.gradleProperty("skipRust").isPresent

val buildRustLib by tasks.registering(Exec::class) {
Expand All @@ -77,7 +78,8 @@ val buildRustLib by tasks.registering(Exec::class) {
commandLine(
"cargo", "ndk",
"-t", "arm64-v8a",
"-o", jniLibsDir.absolutePath,
// AAudio (libaaudio.so) exists from API 26 (= minSdk); cargo-ndk defaults to API 21.
"--platform", "26",
"build", "--release",
"-p", "audiobridge-android",
)
Expand All @@ -87,6 +89,14 @@ val buildRustLib by tasks.registering(Exec::class) {
// cargo tracks its own incremental state; always let it decide what to rebuild.
outputs.upToDateWhen { false }
onlyIf { !skipRust }
// Not `cargo ndk -o`: cargo-ndk 4 copies every cdylib artifact, including iroh's own cdylibs.
val builtLib = rustTargetDir.resolve("aarch64-linux-android/release/libaudiobridge.so")
val abiDir = jniLibsDir.resolve("arm64-v8a")
doLast {
abiDir.mkdirs()
abiDir.listFiles()?.filter { it.name != builtLib.name }?.forEach { it.delete() }
builtLib.copyTo(abiDir.resolve(builtLib.name), overwrite = true)
}
}

tasks.configureEach {
Expand Down
5 changes: 0 additions & 5 deletions crates/android-native/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,3 @@ android_logger = "0.15"
tracing = { version = "0.1", features = ["log"] }
# iroh's DNS resolver reads the system DNS config through ndk-context; JNI init installs the app context.
ndk-context = "0.1"

[package.metadata.ndk]
# AAudio (libaaudio.so) exists from API 26; cargo-ndk would otherwise link against API 21 stubs.
platform = 26
targets = ["arm64-v8a"]
Loading