From 3a954c24a7feed99d899a417767d6ebc3727501e Mon Sep 17 00:00:00 2001 From: Otto Date: Mon, 5 Feb 2024 20:15:24 +0100 Subject: [PATCH 1/3] Update to web-audio-api-rs 0.42 and add channelCount to media constraints --- Cargo.toml | 2 +- src/media_devices/get_user_media.rs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 70361816..40090019 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ crate-type = ["cdylib"] napi = {version="2.14", features=["napi9", "tokio_rt"]} napi-derive = "2.14" uuid = {version="1.6.1", features = ["v4","fast-rng"]} -web-audio-api = "0.41.1" +web-audio-api = "0.42" # web-audio-api = { path = "../web-audio-api-rs" } [target.'cfg(all(any(windows, unix), target_arch = "x86_64", not(target_env = "musl")))'.dependencies] diff --git a/src/media_devices/get_user_media.rs b/src/media_devices/get_user_media.rs index de8e70c9..452ec273 100644 --- a/src/media_devices/get_user_media.rs +++ b/src/media_devices/get_user_media.rs @@ -47,6 +47,13 @@ pub(crate) fn napi_get_user_media(ctx: CallContext) -> Result { constraints.latency = Some(latency); } + if let Ok(Some(js_channel_count)) = + js_constraints.get::<&str, JsNumber>("channelCount") + { + let channel_count = js_channel_count.get_uint32()?; + constraints.channel_count = Some(channel_count); + } + MediaStreamConstraints::AudioWithConstraints(constraints) } else { return Err(napi::Error::from_reason( From 181e0fdb239bf9b3f83df23debf01971c39a458c Mon Sep 17 00:00:00 2001 From: Otto Date: Mon, 5 Feb 2024 20:16:58 +0100 Subject: [PATCH 2/3] Revert accidental `wpt` submodule change --- wpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wpt b/wpt index d99b032d..51c87dc4 160000 --- a/wpt +++ b/wpt @@ -1 +1 @@ -Subproject commit d99b032d98eb39b2222e9b824a5f6cdff28c883f +Subproject commit 51c87dc4c5d4a61caef22344e4dba6f5f233ffc3 From 1fd1e2277f0ebebeb7ebfc0d9eb3a012fe0d87b7 Mon Sep 17 00:00:00 2001 From: Otto Date: Mon, 5 Feb 2024 20:26:18 +0100 Subject: [PATCH 3/3] Fix build - incompatible with napi 2.15 so stick with 2.14 ``` error[E0308]: mismatched types --> src/audio_buffer.rs:217:17 | 216 | .create_arraybuffer_with_borrowed_data( | ------------------------------------- arguments to this method are incorrect 217 | data_ptr, | ^^^^^^^^ types differ in mutability | = note: expected raw pointer `*mut u8` found raw pointer `*const u8` note: method defined here --> /Users/otto/.cargo/registry/src/index.crates.io-6f17d22bba15001f/napi-2.15.1/src/env.rs:508:17 | 508 | pub unsafe fn create_arraybuffer_with_borrowed_data( | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ``` --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 40090019..e12915c1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ version = "0.15.0" crate-type = ["cdylib"] [dependencies] -napi = {version="2.14", features=["napi9", "tokio_rt"]} +napi = {version="=2.14", features=["napi9", "tokio_rt"]} napi-derive = "2.14" uuid = {version="1.6.1", features = ["v4","fast-rng"]} web-audio-api = "0.42"