Gate ASIO behind opt-in cargo feature

Signed-off-by: Rajesh Digambar Bagul <102693488+Rajesh270712@users.noreply.github.com>
This commit is contained in:
Rajesh Digambar Bagul 2026-06-16 21:12:57 +05:30
commit c82285c832
4 changed files with 25 additions and 14 deletions

View file

@ -205,7 +205,7 @@ jobs:
- name: Build rustdesk
run: |
# Windows: build RustDesk
python3 .\build.py --portable --hwcodec --flutter --vram --skip-portable-pack
python3 .\build.py --portable --hwcodec --flutter --vram --asio --skip-portable-pack
mv ./flutter/build/windows/x64/runner/Release ./rustdesk
# Download usbmmidd_v2.zip and extract it to ./rustdesk
@ -442,7 +442,7 @@ jobs:
# Patch sciter x86
sed -i 's/branch = "dyn"/branch = "dyn_x86"/g' ./Cargo.toml
cargo update -p sciter-rs --precise 674e07d3066ca9a92ced3816203ab6b652629d1e
cargo build --locked --features inline,vram,hwcodec --release --bins
cargo build --locked --features inline,vram,hwcodec,asio --release --bins
mkdir -p ./Release
mv ./target/release/rustdesk.exe ./Release/rustdesk.exe
curl -LJ -o ./Release/sciter.dll https://github.com/c-smile/sciter-sdk/raw/master/bin.win/x32/sciter.dll

View file

@ -41,6 +41,7 @@ unix-file-copy-paste = [
"clipboard/unix-file-copy-paste",
]
screencapturekit = ["cpal/screencapturekit"]
asio = ["cpal/asio"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -107,7 +108,7 @@ system_shutdown = "4.0"
qrcode-generator = "4.1"
[target.'cfg(target_os = "windows")'.dependencies]
cpal = { git = "https://github.com/rustdesk-org/cpal", branch = "osx-screencapturekit", features = ["asio"] }
cpal = { git = "https://github.com/rustdesk-org/cpal", branch = "osx-screencapturekit" }
winapi = { version = "0.3", features = [
"winuser",
"wincrypt",

View file

@ -129,6 +129,11 @@ def make_parser():
action='store_true',
help='Build with unix file copy paste feature'
)
parser.add_argument(
'--asio',
action='store_true',
help='Enable ASIO audio support on Windows'
)
parser.add_argument(
'--skip-cargo',
action='store_true',
@ -281,6 +286,8 @@ def get_features(args):
features.append('flutter')
if args.unix_file_copy_paste:
features.append('unix-file-copy-paste')
if args.asio:
features.append('asio')
if osx:
if args.screencapturekit:
features.append('screencapturekit')

View file

@ -73,7 +73,7 @@ fn strip_asio_device_suffix(device: &str) -> Option<&str> {
device.strip_suffix(ASIO_DEVICE_SUFFIX)
}
#[cfg(windows)]
#[cfg(all(windows, feature = "asio"))]
pub fn get_asio_input_devices() -> Vec<String> {
use cpal::traits::{DeviceTrait, HostTrait};
@ -120,7 +120,7 @@ pub fn get_asio_input_devices() -> Vec<String> {
out
}
#[cfg(not(windows))]
#[cfg(not(all(windows, feature = "asio")))]
pub fn get_asio_input_devices() -> Vec<String> {
Vec::new()
}
@ -346,14 +346,17 @@ mod cpal_impl {
fn get_device() -> ResultType<(Device, SupportedStreamConfig)> {
let audio_input = super::get_audio_input();
if !audio_input.is_empty() {
match get_asio_audio_input(&audio_input) {
Ok(Some(device)) => return Ok(device),
Ok(None) => {}
Err(err) => {
log::warn!(
"Failed to get ASIO audio input, falling back to default audio input: {:?}",
err
);
#[cfg(feature = "asio")]
{
match get_asio_audio_input(&audio_input) {
Ok(Some(device)) => return Ok(device),
Ok(None) => {}
Err(err) => {
log::warn!(
"Failed to get ASIO audio input, falling back to default audio input: {:?}",
err
);
}
}
}
return get_audio_input(&audio_input);
@ -373,7 +376,7 @@ mod cpal_impl {
Ok((device, format))
}
#[cfg(windows)]
#[cfg(all(windows, feature = "asio"))]
fn get_asio_audio_input(
audio_input: &str,
) -> ResultType<Option<(Device, SupportedStreamConfig)>> {