feat(native): upgrade dispatch2 to 0.3 (#11855)
This commit is contained in:
12
Cargo.lock
generated
12
Cargo.lock
generated
@@ -544,9 +544,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "block2"
|
name = "block2"
|
||||||
version = "0.6.0"
|
version = "0.6.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1d59b4c170e16f0405a2e95aff44432a0d41aa97675f3d52623effe95792a037"
|
checksum = "340d2f0bdb2a43c1d3cd40513185b2bd7def0aa1052f956455114bc98f82dcf2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"objc2",
|
"objc2",
|
||||||
]
|
]
|
||||||
@@ -1196,9 +1196,9 @@ checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dispatch2"
|
name = "dispatch2"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1a0d569e003ff27784e0e14e4a594048698e0c0f0b66cabcb51511be55a7caa0"
|
checksum = "89a09f22a6c6069a18470eb92d2298acf25463f14256d24778e1230d789a2aec"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.9.0",
|
"bitflags 2.9.0",
|
||||||
"block2",
|
"block2",
|
||||||
@@ -2561,9 +2561,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "objc2"
|
name = "objc2"
|
||||||
version = "0.6.0"
|
version = "0.6.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3531f65190d9cff863b77a99857e74c314dd16bf56c538c4b57c7cbc3f3a6e59"
|
checksum = "88c6597e14493ab2e44ce58f2fdecf095a51f12ca57bec060a11c57332520551"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"objc2-encode",
|
"objc2-encode",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ core-foundation = "0.10"
|
|||||||
coreaudio-rs = "0.12"
|
coreaudio-rs = "0.12"
|
||||||
criterion = { version = "0.5", features = ["html_reports"] }
|
criterion = { version = "0.5", features = ["html_reports"] }
|
||||||
criterion2 = { version = "3", default-features = false }
|
criterion2 = { version = "3", default-features = false }
|
||||||
dispatch2 = "0.2"
|
dispatch2 = "0.3"
|
||||||
docx-parser = { git = "https://github.com/toeverything/docx-parser" }
|
docx-parser = { git = "https://github.com/toeverything/docx-parser" }
|
||||||
dotenvy = "0.15"
|
dotenvy = "0.15"
|
||||||
file-format = { version = "0.26", features = ["reader"] }
|
file-format = { version = "0.26", features = ["reader"] }
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use std::ffi::c_void;
|
use std::{cmp::Ordering, ffi::c_void};
|
||||||
|
|
||||||
use coreaudio::sys::kAudioHardwareBadStreamError;
|
use coreaudio::sys::kAudioHardwareBadStreamError;
|
||||||
use objc2::{Encode, Encoding, RefEncode};
|
use objc2::{Encode, Encoding, RefEncode};
|
||||||
@@ -229,9 +229,11 @@ impl InputAndOutputAudioBufferList {
|
|||||||
} else {
|
} else {
|
||||||
let len1 = mixed_samples.len();
|
let len1 = mixed_samples.len();
|
||||||
let len2 = processed_output.len();
|
let len2 = processed_output.len();
|
||||||
if len1 < len2 {
|
match len1.cmp(&len2) {
|
||||||
|
Ordering::Less => {
|
||||||
mixed_samples.resize(len2, 0.0);
|
mixed_samples.resize(len2, 0.0);
|
||||||
} else if len2 < len1 {
|
}
|
||||||
|
Ordering::Greater => {
|
||||||
let mut padded_output = processed_output;
|
let mut padded_output = processed_output;
|
||||||
padded_output.resize(len1, 0.0);
|
padded_output.resize(len1, 0.0);
|
||||||
for (sample1, sample2) in mixed_samples.iter_mut().zip(padded_output.iter()) {
|
for (sample1, sample2) in mixed_samples.iter_mut().zip(padded_output.iter()) {
|
||||||
@@ -239,6 +241,8 @@ impl InputAndOutputAudioBufferList {
|
|||||||
}
|
}
|
||||||
return Ok(mixed_samples);
|
return Ok(mixed_samples);
|
||||||
}
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
|
||||||
for (sample1, sample2) in mixed_samples.iter_mut().zip(processed_output.iter()) {
|
for (sample1, sample2) in mixed_samples.iter_mut().zip(processed_output.iter()) {
|
||||||
*sample1 = (*sample1 + *sample2) / 2.0;
|
*sample1 = (*sample1 + *sample2) / 2.0;
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
pub(crate) fn create_audio_tap_queue() -> *mut dispatch2::ffi::dispatch_queue_s {
|
pub(crate) fn create_audio_tap_queue() -> dispatch2::DispatchRetained<dispatch2::DispatchQueue> {
|
||||||
let queue_attr = unsafe {
|
let queue_attr = dispatch2::DispatchQueueAttr::with_qos_class(
|
||||||
dispatch2::ffi::dispatch_queue_attr_make_with_qos_class(
|
dispatch2::DispatchQueueAttr::SERIAL,
|
||||||
dispatch2::ffi::DISPATCH_QUEUE_SERIAL,
|
dispatch2::DispatchQoS::UserInteractive,
|
||||||
dispatch2::ffi::dispatch_qos_class_t::QOS_CLASS_USER_INITIATED,
|
|
||||||
0,
|
0,
|
||||||
)
|
);
|
||||||
};
|
dispatch2::DispatchQueue::new("ProcessTapRecorder", Some(&queue_attr))
|
||||||
unsafe {
|
|
||||||
dispatch2::ffi::dispatch_queue_create(c"ProcessTapRecorder".as_ptr().cast(), queue_attr)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -316,7 +316,7 @@ impl AggregateDevice {
|
|||||||
AudioDeviceCreateIOProcIDWithBlock(
|
AudioDeviceCreateIOProcIDWithBlock(
|
||||||
&mut in_proc_id,
|
&mut in_proc_id,
|
||||||
self.id,
|
self.id,
|
||||||
queue.cast(),
|
dispatch2::DispatchRetained::as_ptr(&queue).as_ptr().cast(),
|
||||||
(&*in_io_block
|
(&*in_io_block
|
||||||
as *const Block<
|
as *const Block<
|
||||||
dyn Fn(*mut c_void, *mut c_void, *mut c_void, *mut c_void, *mut c_void) -> i32,
|
dyn Fn(*mut c_void, *mut c_void, *mut c_void, *mut c_void, *mut c_void) -> i32,
|
||||||
@@ -345,6 +345,7 @@ impl AggregateDevice {
|
|||||||
output_device_id: self.output_device_id,
|
output_device_id: self.output_device_id,
|
||||||
input_proc_id: self.input_proc_id,
|
input_proc_id: self.input_proc_id,
|
||||||
output_proc_id: self.output_proc_id,
|
output_proc_id: self.output_proc_id,
|
||||||
|
queue: Some(queue),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -416,6 +417,7 @@ pub struct AudioTapStream {
|
|||||||
output_device_id: AudioObjectID,
|
output_device_id: AudioObjectID,
|
||||||
input_proc_id: Option<AudioDeviceIOProcID>,
|
input_proc_id: Option<AudioDeviceIOProcID>,
|
||||||
output_proc_id: Option<AudioDeviceIOProcID>,
|
output_proc_id: Option<AudioDeviceIOProcID>,
|
||||||
|
queue: Option<dispatch2::DispatchRetained<dispatch2::DispatchQueue>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AudioTapStream {
|
impl AudioTapStream {
|
||||||
@@ -530,6 +532,9 @@ impl AudioTapStream {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// destroy the queue
|
||||||
|
drop(self.queue.take());
|
||||||
|
|
||||||
// Always return success to prevent errors from bubbling up to JavaScript
|
// Always return success to prevent errors from bubbling up to JavaScript
|
||||||
// since we've made a best effort to clean up
|
// since we've made a best effort to clean up
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user