Add apk build and alter CI
This commit is contained in:
parent
f8775b1e7b
commit
0ff26d163d
3 changed files with 43 additions and 9 deletions
16
.github/workflows/cpal.yml
vendored
16
.github/workflows/cpal.yml
vendored
|
|
@ -3,6 +3,7 @@ name: cpal
|
||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
clippy-test:
|
clippy-test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|
@ -224,3 +225,18 @@ jobs:
|
||||||
run: cargo check --example feedback --target armv7-linux-androideabi --verbose
|
run: cargo check --example feedback --target armv7-linux-androideabi --verbose
|
||||||
- name: Check record_wav
|
- name: Check record_wav
|
||||||
run: cargo check --example record_wav --target armv7-linux-androideabi --verbose
|
run: cargo check --example record_wav --target armv7-linux-androideabi --verbose
|
||||||
|
|
||||||
|
android-apk-build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Install Android targets
|
||||||
|
run: |
|
||||||
|
rustup target add armv7-linux-androideabi
|
||||||
|
rustup target add aarch64-linux-android
|
||||||
|
rustup target add i686-linux-android
|
||||||
|
rustup target add x86_64-linux-android
|
||||||
|
- name: Install Cargo APK
|
||||||
|
run: cargo install cargo-apk
|
||||||
|
- name: Build APK
|
||||||
|
run: cargo apk build --example beep
|
||||||
|
|
|
||||||
23
Cargo.toml
23
Cargo.toml
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "cpal"
|
name = "cpal"
|
||||||
version = "0.12.1"
|
version = "0.13.0"
|
||||||
authors = ["The CPAL contributors", "Pierre Krieger <pierre.krieger1708@gmail.com>"]
|
authors = ["The CPAL contributors", "Pierre Krieger <pierre.krieger1708@gmail.com>"]
|
||||||
description = "Low-level cross-platform audio I/O library in pure Rust."
|
description = "Low-level cross-platform audio I/O library in pure Rust."
|
||||||
repository = "https://github.com/rustaudio/cpal"
|
repository = "https://github.com/rustaudio/cpal"
|
||||||
|
|
@ -11,7 +11,6 @@ keywords = ["audio", "sound"]
|
||||||
[features]
|
[features]
|
||||||
asio = ["asio-sys", "num-traits"] # Only available on Windows. See README for setup instructions.
|
asio = ["asio-sys", "num-traits"] # Only available on Windows. See README for setup instructions.
|
||||||
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
thiserror = "1.0.2"
|
thiserror = "1.0.2"
|
||||||
|
|
||||||
|
|
@ -51,3 +50,23 @@ oboe = { version = "0.2.1", features = [ "java-interface" ] }
|
||||||
ndk = "0.2"
|
ndk = "0.2"
|
||||||
ndk-glue = "0.2"
|
ndk-glue = "0.2"
|
||||||
jni = "0.17"
|
jni = "0.17"
|
||||||
|
|
||||||
|
[[example]]
|
||||||
|
name = "beep"
|
||||||
|
path = "examples/beep.rs"
|
||||||
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
|
[[example]]
|
||||||
|
name = "enumerate"
|
||||||
|
path = "examples/enumerate.rs"
|
||||||
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
|
[[example]]
|
||||||
|
name = "feedback"
|
||||||
|
path = "examples/feedback.rs"
|
||||||
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
|
[[example]]
|
||||||
|
name = "record_wav"
|
||||||
|
path = "examples/record_wav.rs"
|
||||||
|
crate-type = ["cdylib"]
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,8 @@ extern crate cpal;
|
||||||
|
|
||||||
use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
|
use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
|
||||||
|
|
||||||
fn main() -> Result<(), anyhow::Error> {
|
#[cfg_attr(target_os = "android", ndk_glue::main(backtrace = "full"))]
|
||||||
|
fn main() {
|
||||||
// Conditionally compile with jack if the feature is specified.
|
// Conditionally compile with jack if the feature is specified.
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"),
|
any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"),
|
||||||
|
|
@ -34,15 +35,13 @@ fn main() -> Result<(), anyhow::Error> {
|
||||||
let device = host
|
let device = host
|
||||||
.default_output_device()
|
.default_output_device()
|
||||||
.expect("failed to find a default output device");
|
.expect("failed to find a default output device");
|
||||||
let config = device.default_output_config()?;
|
let config = device.default_output_config().unwrap();
|
||||||
|
|
||||||
match config.sample_format() {
|
match config.sample_format() {
|
||||||
cpal::SampleFormat::F32 => run::<f32>(&device, &config.into())?,
|
cpal::SampleFormat::F32 => run::<f32>(&device, &config.into()).unwrap(),
|
||||||
cpal::SampleFormat::I16 => run::<i16>(&device, &config.into())?,
|
cpal::SampleFormat::I16 => run::<i16>(&device, &config.into()).unwrap(),
|
||||||
cpal::SampleFormat::U16 => run::<u16>(&device, &config.into())?,
|
cpal::SampleFormat::U16 => run::<u16>(&device, &config.into()).unwrap(),
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run<T>(device: &cpal::Device, config: &cpal::StreamConfig) -> Result<(), anyhow::Error>
|
fn run<T>(device: &cpal::Device, config: &cpal::StreamConfig) -> Result<(), anyhow::Error>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue