Skip to content

Commit b32afbf

Browse files
committed
Merge branch 'master' into master
2 parents 135eb4c + c5a163e commit b32afbf

File tree

26 files changed

+1111
-491
lines changed

26 files changed

+1111
-491
lines changed

.github/workflows/cpal.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Run clippy
2525
run: cargo clippy --all --all-features
2626
- name: Run clippy for Android target
27-
run: cargo clippy --all --features asio --features oboe/fetch-prebuilt --target armv7-linux-androideabi
27+
run: cargo clippy --all --features asio --target armv7-linux-androideabi
2828

2929
rustfmt-check:
3030
runs-on: ubuntu-latest
@@ -207,15 +207,16 @@ jobs:
207207
with:
208208
target: armv7-linux-androideabi
209209
- name: Check android
210-
run: cargo check --example android --target armv7-linux-androideabi --features oboe/fetch-prebuilt --verbose
210+
working-directory: examples/android
211+
run: cargo check --target armv7-linux-androideabi --verbose
211212
- name: Check beep
212-
run: cargo check --example beep --target armv7-linux-androideabi --features oboe/fetch-prebuilt --verbose
213+
run: cargo check --example beep --target armv7-linux-androideabi --verbose
213214
- name: Check enumerate
214-
run: cargo check --example enumerate --target armv7-linux-androideabi --features oboe/fetch-prebuilt --verbose
215+
run: cargo check --example enumerate --target armv7-linux-androideabi --verbose
215216
- name: Check feedback
216-
run: cargo check --example feedback --target armv7-linux-androideabi --features oboe/fetch-prebuilt --verbose
217+
run: cargo check --example feedback --target armv7-linux-androideabi --verbose
217218
- name: Check record_wav
218-
run: cargo check --example record_wav --target armv7-linux-androideabi --features oboe/fetch-prebuilt --verbose
219+
run: cargo check --example record_wav --target armv7-linux-androideabi --verbose
219220

220221
android-apk-build:
221222
runs-on: ubuntu-latest
@@ -227,11 +228,12 @@ jobs:
227228
targets: armv7-linux-androideabi,aarch64-linux-android,i686-linux-android,x86_64-linux-android
228229
- name: Set Up Android tools
229230
run: |
230-
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_SDK_ROOT --install "platforms;android-30"
231+
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_SDK_ROOT --install "build-tools;30.0.2" "platforms;android-30"
231232
- name: Install Cargo APK
232233
run: cargo install cargo-apk
233234
- name: Build APK
234-
run: cargo apk build --example android
235+
working-directory: examples/android
236+
run: cargo apk build
235237

236238
ios-build:
237239
runs-on: macOS-latest

Cargo.toml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ rust-version = "1.70"
1111

1212
[features]
1313
asio = ["asio-sys", "num-traits"] # Only available on Windows. See README for setup instructions.
14-
oboe-shared-stdcxx = ["oboe/shared-stdcxx"] # Only available on Android. See README for what it does.
1514
jack = ["dep:jack"]
1615
pipewire = ["dep:pipewire-client", "dep:tokio"]
1716

@@ -24,9 +23,6 @@ hound = "3.5"
2423
ringbuf = "0.4.1"
2524
clap = { version = "4.0", features = ["derive"] }
2625

27-
[target.'cfg(target_os = "android")'.dev-dependencies]
28-
ndk-glue = "0.7"
29-
3026
[target.'cfg(target_os = "windows")'.dependencies]
3127
windows = { version = "0.54.0", features = [
3228
"Win32_Media_Audio",
@@ -73,15 +69,11 @@ js-sys = { version = "0.3.35" }
7369
web-sys = { version = "0.3.35", features = [ "AudioContext", "AudioContextOptions", "AudioBuffer", "AudioBufferSourceNode", "AudioNode", "AudioDestinationNode", "Window", "AudioContextState"] }
7470

7571
[target.'cfg(target_os = "android")'.dependencies]
76-
oboe = { version = "0.6", features = [ "java-interface" ] }
77-
ndk = { version = "0.8", default-features = false }
72+
ndk = { version = "0.9", default-features = false, features = ["audio", "api-level-26"]}
7873
ndk-context = "0.1"
7974
jni = "0.21"
80-
81-
[[example]]
82-
name = "android"
83-
path = "examples/android.rs"
84-
crate-type = ["cdylib"]
75+
num-derive = "0.4"
76+
num-traits = "0.2"
8577

8678
[[example]]
8779
name = "beep"

README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Currently, supported hosts include:
2020
- Windows (via WASAPI by default, see ASIO instructions below)
2121
- macOS (via CoreAudio)
2222
- iOS (via CoreAudio)
23-
- Android (via Oboe)
23+
- Android (via AAudio)
2424
- Emscripten
2525

2626
Note that on Linux, the ALSA development files are required. These are provided
@@ -43,10 +43,6 @@ Some audio backends are optional and will only be compiled with a [feature flag]
4343
- PipeWire (on Linux): `pipewire` (currently in testing, feel free to share your feedback!)
4444
- ASIO (on Windows): `asio`
4545

46-
Oboe can either use a shared or static runtime. The static runtime is used by default, but activating the
47-
`oboe-shared-stdcxx` feature makes it use the shared runtime, which requires `libc++_shared.so` from the Android NDK to
48-
be present during execution.
49-
5046
## ASIO on Windows
5147

5248
[ASIO](https://en.wikipedia.org/wiki/Audio_Stream_Input/Output) is an audio

examples/android/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/target
2+
/Cargo.lock
3+
.cargo/
4+
.DS_Store
5+
recorded.wav
6+
rls*.log

examples/android/Cargo.toml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[package]
2+
name = "android"
3+
version = "0.1.0"
4+
edition = "2024"
5+
6+
[dependencies]
7+
cpal = { path = "../../" }
8+
anyhow = "1.0"
9+
ndk-glue = "0.7"
10+
11+
[lib]
12+
name = "android"
13+
path = "src/lib.rs"
14+
crate-type = ["cdylib"]
15+
16+
[package.metadata.android]
17+
# Specifies the package property of the manifest.
18+
package = "com.foo.bar"
19+
20+
# Specifies the array of targets to build for.
21+
build_targets = [ "armv7-linux-androideabi", "aarch64-linux-android", "i686-linux-android", "x86_64-linux-android" ]
22+
23+
# Name for final APK file.
24+
# Defaults to package name.
25+
apk_name = "myapp"
26+
27+
[package.metadata.android.sdk]
28+
min_sdk_version = 26
29+
target_sdk_version = 30
30+
max_sdk_version = 29

examples/android/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## How to install
2+
3+
```sh
4+
rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android
5+
```
6+
7+
## How to build apk
8+
9+
```sh
10+
# Builds the project in release mode and places it into a `apk` file.
11+
cargo apk build --release
12+
```
13+
14+
more information at: https://github.com/rust-mobile/cargo-apk

examples/android.rs renamed to examples/android/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ extern crate cpal;
55

66
use cpal::{
77
traits::{DeviceTrait, HostTrait, StreamTrait},
8-
SizedSample,
8+
SizedSample, I24,
99
};
1010
use cpal::{FromSample, Sample};
1111

@@ -22,7 +22,7 @@ fn main() {
2222
match config.sample_format() {
2323
cpal::SampleFormat::I8 => run::<i8>(&device, &config.into()).unwrap(),
2424
cpal::SampleFormat::I16 => run::<i16>(&device, &config.into()).unwrap(),
25-
// cpal::SampleFormat::I24 => run::<I24>(&device, &config.into()).unwrap(),
25+
cpal::SampleFormat::I24 => run::<I24>(&device, &config.into()).unwrap(),
2626
cpal::SampleFormat::I32 => run::<i32>(&device, &config.into()).unwrap(),
2727
// cpal::SampleFormat::I48 => run::<I48>(&device, &config.into()).unwrap(),
2828
cpal::SampleFormat::I64 => run::<i64>(&device, &config.into()).unwrap(),

examples/beep.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clap::Parser;
22
use cpal::{
33
traits::{DeviceTrait, HostTrait, StreamTrait},
4-
FromSample, Sample, SizedSample,
4+
FromSample, Sample, SizedSample, I24,
55
};
66

77
#[derive(Parser, Debug)]
@@ -118,7 +118,7 @@ fn main() -> anyhow::Result<()> {
118118
match config.sample_format() {
119119
cpal::SampleFormat::I8 => run::<i8>(&device, &config.into()),
120120
cpal::SampleFormat::I16 => run::<i16>(&device, &config.into()),
121-
// cpal::SampleFormat::I24 => run::<I24>(&device, &config.into()),
121+
cpal::SampleFormat::I24 => run::<I24>(&device, &config.into()),
122122
cpal::SampleFormat::I32 => run::<i32>(&device, &config.into()),
123123
// cpal::SampleFormat::I48 => run::<I48>(&device, &config.into()),
124124
cpal::SampleFormat::I64 => run::<i64>(&device, &config.into()),

examples/synth_tones.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ extern crate cpal;
88

99
use cpal::{
1010
traits::{DeviceTrait, HostTrait, StreamTrait},
11-
SizedSample,
11+
SizedSample, I24,
1212
};
1313
use cpal::{FromSample, Sample};
1414

@@ -98,6 +98,7 @@ where
9898
match config.sample_format() {
9999
cpal::SampleFormat::I8 => make_stream::<i8>(&device, &config.into()),
100100
cpal::SampleFormat::I16 => make_stream::<i16>(&device, &config.into()),
101+
cpal::SampleFormat::I24 => make_stream::<I24>(&device, &config.into()),
101102
cpal::SampleFormat::I32 => make_stream::<i32>(&device, &config.into()),
102103
cpal::SampleFormat::I64 => make_stream::<i64>(&device, &config.into()),
103104
cpal::SampleFormat::U8 => make_stream::<u8>(&device, &config.into()),
File renamed without changes.

0 commit comments

Comments
 (0)