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
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repository = "https://github.com/RustAudio/cpal"
documentation = "https://docs.rs/cpal"
license = "Apache-2.0"
keywords = ["audio", "sound"]
edition = "2021"
edition = "2024"
rust-version = "1.85"

[badges]
Expand Down Expand Up @@ -90,7 +90,7 @@ dasp_sample = "0.11"
anyhow = "1.0"
hound = "3.5"
ringbuf = "0.4"
clap = { version = ">=4.6, <5", features = ["derive"] }
clap = { version = "4.6", features = ["derive"] }

# Support a range of versions in order to avoid duplication of this crate. Make sure to test all
# versions when bumping to a new release, and only increase the minimum when absolutely necessary.
Expand All @@ -114,7 +114,7 @@ windows = { version = ">=0.61, <=0.62", features = [
"Win32_UI_Shell_PropertiesSystem",
] }
audio_thread_priority = { version = "0.35", optional = true, default-features = false }
asio-sys = { version = "0.3.0", path = "asio-sys", optional = true }
asio-sys = { version = "0.4.0", path = "asio-sys", optional = true }
num-traits = { version = "0.2", optional = true }
jack = { version = "0.13", optional = true }

Expand Down
8 changes: 4 additions & 4 deletions asio-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[package]
name = "asio-sys"
version = "0.3.0"
version = "0.4.0"
authors = ["Tom Gowan <tomrgowan@gmail.com>"]
description = "Low-level interface and binding generation for the steinberg ASIO SDK."
description = "Low-level interface and binding generation for the Steinberg ASIO SDK."
repository = "https://github.com/RustAudio/cpal/"
documentation = "https://docs.rs/asio-sys"
license = "Apache-2.0"
keywords = ["audio", "sound", "asio", "steinberg"]
edition = "2021"
rust-version = "1.82"
edition = "2024"
rust-version = "1.85"

[build-dependencies]
bindgen = "0.72"
Expand Down
2 changes: 1 addition & 1 deletion asio-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ fn invoke_vcvars_if_not_set() {
// Filters the output of vcvarsall.bat to only include lines of the form "VARNAME=VALUE"
let parts: Vec<&str> = line.splitn(2, '=').collect();
if parts.len() == 2 {
env::set_var(parts[0], parts[1]);
unsafe { env::set_var(parts[0], parts[1]) };
println!("{}={}", parts[0], parts[1]);
}
}
Expand Down
1 change: 1 addition & 0 deletions asio-sys/src/bindings/asio_import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(clippy::missing_safety_doc)]
#![allow(unsafe_op_in_unsafe_fn)]

include!(concat!(env!("OUT_DIR"), "/asio_bindings.rs"));
2 changes: 1 addition & 1 deletion asio-sys/src/bindings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use std::{
os::raw::{c_char, c_double, c_void},
ptr::null_mut,
sync::{
atomic::{AtomicBool, AtomicU32, AtomicU64, Ordering},
Arc, Mutex, MutexGuard, Weak,
atomic::{AtomicBool, AtomicU32, AtomicU64, Ordering},
},
time::Duration,
};
Expand Down
5 changes: 3 additions & 2 deletions examples/android/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[package]
name = "android"
version = "0.1.0"
edition = "2021"
version = "0.2.0"
edition = "2024"
rust-version = "1.85"

[dependencies]
cpal = { path = "../../" }
Expand Down
5 changes: 3 additions & 2 deletions examples/audioworklet-beep/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[package]
name = "audioworklet-beep"
description = "cpal beep example for WebAssembly on an AudioWorklet"
version = "0.1.0"
edition = "2021"
version = "0.2.0"
edition = "2024"
rust-version = "1.85"
authors = ["Ian Kettlewell <ian.kettlewell@gmail.com>"]

[lib]
Expand Down
4 changes: 2 additions & 2 deletions examples/beep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

use clap::Parser;
use cpal::{
Device, Error, ErrorKind, FromSample, HostId, I24, OutputCallbackInfo, Sample, SampleFormat,
SizedSample, StreamConfig,
traits::{DeviceTrait, HostTrait, StreamTrait},
Device, Error, ErrorKind, FromSample, HostId, OutputCallbackInfo, Sample, SampleFormat,
SizedSample, StreamConfig, I24,
};

#[derive(Parser, Debug)]
Expand Down
4 changes: 2 additions & 2 deletions examples/custom.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
use std::{
fmt,
sync::{
atomic::{AtomicBool, Ordering},
Arc,
atomic::{AtomicBool, Ordering},
},
time::{Duration, Instant},
};

use cpal::{
traits::{DeviceTrait, HostTrait, StreamTrait},
ChannelCount, Data, Device, DeviceDescription, DeviceDescriptionBuilder, DeviceId, Error,
ErrorKind, FrameCount, FromSample, InputCallbackInfo, OutputCallbackInfo,
OutputStreamTimestamp, Sample, SampleFormat, Stream, StreamConfig, StreamInstant,
SupportedBufferSize, SupportedStreamConfig, SupportedStreamConfigRange,
traits::{DeviceTrait, HostTrait, StreamTrait},
};

#[allow(dead_code)]
Expand Down
4 changes: 2 additions & 2 deletions examples/feedback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

use clap::Parser;
use cpal::{
traits::{DeviceTrait, HostTrait, StreamTrait},
Error, ErrorKind, HostId, InputCallbackInfo, OutputCallbackInfo, Sample, StreamConfig,
traits::{DeviceTrait, HostTrait, StreamTrait},
};
use ringbuf::{
traits::{Consumer, Producer, Split},
HeapRb,
traits::{Consumer, Producer, Split},
};

#[derive(Parser, Debug)]
Expand Down
5 changes: 3 additions & 2 deletions examples/ios-feedback/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[package]
name = "cpal-ios-example"
version = "0.1.0"
version = "0.2.0"
authors = ["Michael Hills <mhills@gmail.com>"]
edition = "2021"
edition = "2024"
rust-version = "1.85"

[lib]
name = "cpal_ios_example"
Expand Down
3 changes: 2 additions & 1 deletion examples/ios-feedback/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
mod feedback;

#[no_mangle]
// Required for Xcode to link this entry point from Objective-C.
#[unsafe(no_mangle)]
pub extern "C" fn rust_ios_main() {
feedback::run_example().unwrap();
}
4 changes: 2 additions & 2 deletions examples/record_wav.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use std::{

use clap::Parser;
use cpal::{
traits::{DeviceTrait, HostTrait, StreamTrait},
Error, ErrorKind, FromSample, HostId, Sample, SampleFormat, SupportedStreamConfig,
traits::{DeviceTrait, HostTrait, StreamTrait},
};

#[derive(Parser, Debug)]
Expand Down Expand Up @@ -155,7 +155,7 @@ fn main() -> Result<(), anyhow::Error> {
sample_format => {
return Err(anyhow::Error::msg(format!(
"Unsupported sample format '{sample_format}'"
)))
)));
}
};

Expand Down
4 changes: 2 additions & 2 deletions examples/synth_tones.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ extern crate clap;
extern crate cpal;

use cpal::{
Device, Error, ErrorKind, FromSample, Host, I24, OutputCallbackInfo, Sample, SampleFormat,
SizedSample, Stream, StreamConfig, SupportedStreamConfig, U24,
traits::{DeviceTrait, HostTrait, StreamTrait},
Device, Error, ErrorKind, FromSample, Host, OutputCallbackInfo, Sample, SampleFormat,
SizedSample, Stream, StreamConfig, SupportedStreamConfig, I24, U24,
};

fn main() -> anyhow::Result<()> {
Expand Down
4 changes: 2 additions & 2 deletions examples/wasm-beep/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "wasm-beep"
description = "cpal beep example for WebAssembly"
version = "0.1.0"
edition = "2021"
version = "0.2.0"
edition = "2024"
rust-version = "1.85"

[lib]
Expand Down
2 changes: 1 addition & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
edition = "2021"
edition = "2024"
4 changes: 2 additions & 2 deletions src/host/aaudio/java_interface/audio_features.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use super::{
PackageManager,
utils::{
get_context, get_package_manager, has_system_feature, with_attached, Env, JObject, JResult,
Env, JObject, JResult, get_context, get_package_manager, has_system_feature, with_attached,
},
PackageManager,
};

/**
Expand Down
2 changes: 1 addition & 1 deletion src/host/aaudio/java_interface/audio_manager.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::{
utils::{get_context, get_system_property, with_attached, Env, JResult},
AudioManager,
utils::{Env, JResult, get_context, get_system_property, with_attached},
};

impl AudioManager {
Expand Down
7 changes: 3 additions & 4 deletions src/host/aaudio/java_interface/devices_info.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
use num_traits::FromPrimitive;

use super::{
android_device_flags,
AudioDeviceInfo, AudioDeviceType, Context, android_device_flags,
utils::{
call_method_no_args_ret_bool, call_method_no_args_ret_char_sequence,
Env, JObject, JResult, call_method_no_args_ret_bool, call_method_no_args_ret_char_sequence,
call_method_no_args_ret_int, call_method_no_args_ret_int_array,
call_method_no_args_ret_string, get_context, get_devices, get_system_service,
with_attached, Env, JObject, JResult,
with_attached,
},
AudioDeviceInfo, AudioDeviceType, Context,
};
use crate::{DeviceDirection, SampleFormat};

Expand Down
2 changes: 1 addition & 1 deletion src/host/aaudio/java_interface/utils.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use jni::sys::jobject;
pub use jni::{
Env, JavaVM,
errors::Result as JResult,
objects::{JIntArray, JObject, JObjectArray, JString},
strings::JNIString,
Env, JavaVM,
};
use ndk_context::AndroidContext;

Expand Down
14 changes: 7 additions & 7 deletions src/host/aaudio/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ use std::{
fmt,
hash::{Hash, Hasher},
sync::{
atomic::{AtomicI32, Ordering},
Arc, Mutex,
atomic::{AtomicI32, Ordering},
},
time::Duration,
vec::IntoIter as VecIntoIter,
};

use crate::{
host::{emit_error, ErrorCallbackArc},
traits::{DeviceTrait, HostTrait, StreamTrait},
BufferSize, ChannelCount, Data, DeviceDescription, DeviceDescriptionBuilder, DeviceDirection,
DeviceId, DeviceType, Error, ErrorKind, FrameCount, InputCallbackInfo, InputStreamTimestamp,
InterfaceType, OutputCallbackInfo, OutputStreamTimestamp, ResultExt, SampleFormat, SampleRate,
StreamConfig, StreamInstant, SupportedBufferSize, SupportedStreamConfig,
SupportedStreamConfigRange,
host::{ErrorCallbackArc, emit_error},
traits::{DeviceTrait, HostTrait, StreamTrait},
};

extern crate ndk;
Expand Down Expand Up @@ -378,7 +378,7 @@ where
// SAFETY: Stream implements Send + Sync (see unsafe impl below). Arc<Mutex<AudioStream>>
// is safe because the Mutex provides exclusive access and AudioStream's thread safety
// is documented in the AAudio C API.
#[allow(clippy::arc_with_non_send_sync)]
#[expect(clippy::arc_with_non_send_sync)]
Ok(Stream {
inner: Arc::new(Mutex::new(stream)),
direction: DeviceDirection::Input,
Expand Down Expand Up @@ -535,7 +535,7 @@ where
// SAFETY: Stream implements Send + Sync (see unsafe impl below). Arc<Mutex<AudioStream>>
// is safe because the Mutex provides exclusive access and AudioStream's thread safety
// is documented in the AAudio C API.
#[allow(clippy::arc_with_non_send_sync)]
#[expect(clippy::arc_with_non_send_sync)]
Ok(Stream {
inner: Arc::new(Mutex::new(stream)),
direction: DeviceDirection::Output,
Expand Down Expand Up @@ -665,7 +665,7 @@ impl DeviceTrait for Device {
return Err(Error::with_message(
ErrorKind::UnsupportedConfig,
format!("Sample format {sample_format} is not supported"),
))
));
}
};
let builder = ndk::audio::AudioStreamBuilder::new()?
Expand Down Expand Up @@ -709,7 +709,7 @@ impl DeviceTrait for Device {
return Err(Error::with_message(
ErrorKind::UnsupportedConfig,
format!("Sample format {sample_format} is not supported"),
))
));
}
};
let builder = ndk::audio::AudioStreamBuilder::new()?
Expand Down
2 changes: 1 addition & 1 deletion src/host/alsa/enumerate.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::HashSet;

use super::{alsa, Device, Host};
use super::{Device, Host, alsa};
use crate::{DeviceDirection, Error};

const HW_PREFIX: &str = "hw";
Expand Down
Loading
Loading