ayaports/user/zotero/update-audio-pc.patch

798 lines
34 KiB
Diff

--- a/.cargo/config.in
+++ b/.cargo/config.in
@@ -55,19 +55,19 @@ git = "https://github.com/mozilla-spider
rev = "64ba08e24749616de2344112f226d1ef4ba893ae"
replace-with = "vendored-sources"
[source."git+https://github.com/mozilla/application-services?rev=c82bccfa500813f273f4db0ead64fc73bfa2b34c"]
git = "https://github.com/mozilla/application-services"
rev = "c82bccfa500813f273f4db0ead64fc73bfa2b34c"
replace-with = "vendored-sources"
-[source."git+https://github.com/mozilla/audioipc?rev=ec6af6ecf8ba50b51f13d18f417de8cfb8460543"]
+[source."git+https://github.com/mozilla/audioipc?rev=6be424d75f1367e70f2f5ddcacd6d0237e81a6a9"]
git = "https://github.com/mozilla/audioipc"
-rev = "ec6af6ecf8ba50b51f13d18f417de8cfb8460543"
+rev = "6be424d75f1367e70f2f5ddcacd6d0237e81a6a9"
replace-with = "vendored-sources"
[source."git+https://github.com/mozilla/cubeb-coreaudio-rs?rev=93b5c01a131f65c83c11aeb317f4583405c5eb79"]
git = "https://github.com/mozilla/cubeb-coreaudio-rs"
rev = "93b5c01a131f65c83c11aeb317f4583405c5eb79"
replace-with = "vendored-sources"
[source."git+https://github.com/mozilla/cubeb-pulse-rs?rev=cf48897be5cbe147d051ebbbe1eaf5fd8fb6bbc9"]
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -230,32 +230,32 @@ version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c41dc008c1973ce58ff3cfc52df53814a9b7b78d73d95b071b5ff0ed4b2db3e1"
dependencies = [
"bitflags 1.999.999",
]
[[package]]
name = "audio_thread_priority"
-version = "0.26.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8b7cd1bfd03dab20ad72e0c5e58d65818d62c0d199d8dec8361053d0f073dbae"
-dependencies = [
- "cfg-if 0.1.999",
+version = "0.30.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a7e6839a6e8e72338137b3126c7fe61af95b9acc3076d2b7109696f808d1234f"
+dependencies = [
+ "cfg-if 1.0.0",
"dbus",
"libc",
"log",
"mach",
- "winapi",
+ "windows-sys",
]
[[package]]
name = "audioipc2"
version = "0.5.0"
-source = "git+https://github.com/mozilla/audioipc?rev=ec6af6ecf8ba50b51f13d18f417de8cfb8460543#ec6af6ecf8ba50b51f13d18f417de8cfb8460543"
+source = "git+https://github.com/mozilla/audioipc?rev=6be424d75f1367e70f2f5ddcacd6d0237e81a6a9#6be424d75f1367e70f2f5ddcacd6d0237e81a6a9"
dependencies = [
"arrayvec",
"ashmem",
"audio_thread_priority",
"bincode",
"byteorder",
"bytes",
"cc",
@@ -273,28 +273,28 @@ dependencies = [
"serde_derive",
"slab",
"windows-sys",
]
[[package]]
name = "audioipc2-client"
version = "0.5.0"
-source = "git+https://github.com/mozilla/audioipc?rev=ec6af6ecf8ba50b51f13d18f417de8cfb8460543#ec6af6ecf8ba50b51f13d18f417de8cfb8460543"
+source = "git+https://github.com/mozilla/audioipc?rev=6be424d75f1367e70f2f5ddcacd6d0237e81a6a9#6be424d75f1367e70f2f5ddcacd6d0237e81a6a9"
dependencies = [
"audio_thread_priority",
"audioipc2",
"cubeb-backend",
"log",
]
[[package]]
name = "audioipc2-server"
version = "0.5.0"
-source = "git+https://github.com/mozilla/audioipc?rev=ec6af6ecf8ba50b51f13d18f417de8cfb8460543#ec6af6ecf8ba50b51f13d18f417de8cfb8460543"
+source = "git+https://github.com/mozilla/audioipc?rev=6be424d75f1367e70f2f5ddcacd6d0237e81a6a9#6be424d75f1367e70f2f5ddcacd6d0237e81a6a9"
dependencies = [
"audio_thread_priority",
"audioipc2",
"cubeb-core",
"error-chain",
"log",
"once_cell",
"slab",
--- a/supply-chain/imports.lock
+++ b/supply-chain/imports.lock
@@ -38,16 +38,23 @@ user-name = "Amanieu d'Antras"
[[publisher.audio_thread_priority]]
version = "0.26.1"
when = "2022-03-22"
user-id = 1258
user-login = "padenot"
user-name = "Paul Adenot"
+[[publisher.audio_thread_priority]]
+version = "0.30.0"
+when = "2023-11-06"
+user-id = 1258
+user-login = "padenot"
+user-name = "Paul Adenot"
+
[[publisher.authenticator]]
version = "0.4.0-alpha.20"
when = "2023-08-24"
user-id = 175410
user-login = "jschanck"
user-name = "John Schanck"
[[publisher.authenticator]]
--- a/third_party/rust/audio_thread_priority/.cargo-checksum.json
+++ b/third_party/rust/audio_thread_priority/.cargo-checksum.json
@@ -1,1 +1,1 @@
-{"files":{"Cargo.toml":"f2a927f4fdf4171eb2111ad9f770fd113d058d6d7dffa10fce7bd7577edda582","LICENSE":"32ee9dbf6196874fc9d406c54a888a6c4cbb9aa4a7f35b46befeaff43a78fe85","Makefile":"0f9a771cfb30c7c4b9961d82fdca4e9e229a955bb2e636474a4101389e18e938","README.md":"c123692b3b50dd621b896a8269814d609cbf1e532b461bf4a77854ddd607eb7a","atp_test.cpp":"8075a040941a65fb9e3f7cbf0535853ca6661c3ac442ec35569b42b24bbec797","audio_thread_priority.h":"f0ecaf1b674f794cde0dc834028e074d4e4675d22ae96acf08b2ae1dceb3474e","generate_osx_bindings.sh":"06e4e03450f788ced18d31fff5660919e6f6ec1119ddace363ffeb82f0518a71","src/lib.rs":"975de6a74e0adb999a08bc41f08a3bd68fe11c154731bc12c43df546ddb32949","src/mach_sys.rs":"352560fcb9b41d877cff92e5b3b04d6dc68b1f30508ce4b9aed78940120a883e","src/rt_linux.rs":"4ea9f6eb1902aff0126d1b957be7f723d599e9a8bbd75ca8013a2820ef5fe68a","src/rt_mach.rs":"e4587fdf640df37f251e50c6c9313f6a73eae4d54f4b8a84cefc6bc730e94be8","src/rt_win.rs":"c41f6e277051a92f8d38939cf9d78ee6deea736a4686b3bcd185492e47e1650a"},"package":"8b7cd1bfd03dab20ad72e0c5e58d65818d62c0d199d8dec8361053d0f073dbae"}
\ No newline at end of file
+{"files":{"Cargo.toml":"b66cf5a2203f39d8425d2b2170f64a5c7220ef76efa7ea14ad20ba99d3435e84","LICENSE":"32ee9dbf6196874fc9d406c54a888a6c4cbb9aa4a7f35b46befeaff43a78fe85","Makefile":"0f9a771cfb30c7c4b9961d82fdca4e9e229a955bb2e636474a4101389e18e938","README.md":"c123692b3b50dd621b896a8269814d609cbf1e532b461bf4a77854ddd607eb7a","atp_test.cpp":"8075a040941a65fb9e3f7cbf0535853ca6661c3ac442ec35569b42b24bbec797","audio_thread_priority.h":"f0ecaf1b674f794cde0dc834028e074d4e4675d22ae96acf08b2ae1dceb3474e","generate_osx_bindings.sh":"06e4e03450f788ced18d31fff5660919e6f6ec1119ddace363ffeb82f0518a71","src/lib.rs":"fe417e81a6677c581d9f617ff7989f08780465401b6fa22b6e3abfedf9e3e221","src/mach_sys.rs":"352560fcb9b41d877cff92e5b3b04d6dc68b1f30508ce4b9aed78940120a883e","src/rt_linux.rs":"27004821a29e6af73f9e13f4d1f060e024152c4cc379d6a0df38d6f5b61039ad","src/rt_mach.rs":"29f8c0397f14cecbac1f76394c2abfe0e05903b54486cf735f9a94a10c168643","src/rt_win.rs":"f2ba097cebf65252c27d9d6dcfbe1fcc041c4b312724bd98e080e114a4de3bb6"},"package":"a7e6839a6e8e72338137b3126c7fe61af95b9acc3076d2b7109696f808d1234f"}
\ No newline at end of file
--- a/third_party/rust/audio_thread_priority/Cargo.toml
+++ b/third_party/rust/audio_thread_priority/Cargo.toml
@@ -7,53 +7,59 @@
#
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
edition = "2018"
name = "audio_thread_priority"
-version = "0.26.1"
+version = "0.30.0"
authors = ["Paul Adenot <paul@paul.cx>"]
description = "Bump a thread to real-time priority, for audio work, on Linux, Windows and macOS"
+readme = "README.md"
license = "MPL-2.0"
repository = "https://github.com/padenot/audio_thread_priority"
[lib]
name = "audio_thread_priority"
-crate-type = ["staticlib", "rlib"]
+crate-type = [
+ "staticlib",
+ "rlib",
+]
+
[dependencies.cfg-if]
-version = "0.1"
+version = "1.0"
[dependencies.log]
version = "0.4"
[dependencies.simple_logger]
version = "0.4"
optional = true
+
[dev-dependencies.nix]
-version = "0.15.0"
+version = "0.26"
[features]
-default = ["with_dbus", "winapi"]
+default = ["with_dbus"]
terminal-logging = ["simple_logger"]
with_dbus = ["dbus"]
+
[target."cfg(target_os = \"linux\")".dependencies.dbus]
version = "0.6.4"
optional = true
[target."cfg(target_os = \"linux\")".dependencies.libc]
version = "0.2"
+
[target."cfg(target_os = \"macos\")".dependencies.libc]
version = "0.2"
[target."cfg(target_os = \"macos\")".dependencies.mach]
version = "0.3"
-[target."cfg(target_os = \"windows\")".dependencies.winapi]
-version = "0.3"
-features = ["avrt", "errhandlingapi", "minwindef"]
-optional = true
-[target."cfg(target_os = \"windows\")".dependencies.windows]
-version = "^0.32.0"
-features = ["Win32_Foundation", "Win32_System_Threading"]
-optional = true
+[target."cfg(target_os = \"windows\")".dependencies.windows-sys]
+version = "0.48"
+features = [
+ "Win32_Foundation",
+ "Win32_System_Threading",
+]
--- a/third_party/rust/audio_thread_priority/src/lib.rs
+++ b/third_party/rust/audio_thread_priority/src/lib.rs
@@ -253,34 +253,43 @@ pub extern "C" fn atp_get_current_thread
///
/// # Arguments
///
/// thread_info: the `atp_thread_info` structure to free.
///
/// # Return value
///
/// 0 in case of success, 1 otherwise (if `thread_info` is NULL).
+///
+/// # Safety
+///
+/// This function is safe only and only if the pointer comes from this library, of if is null.
#[no_mangle]
pub unsafe extern "C" fn atp_free_thread_info(thread_info: *mut atp_thread_info) -> i32 {
if thread_info.is_null() {
return 1;
}
- Box::from_raw(thread_info);
+ drop(Box::from_raw(thread_info));
0
}
/// Return a byte buffer containing serialized information about a thread, to promote it to
/// real-time from elsewhere, with a C API.
///
/// `bytes` MUST be `std::mem::size_of<RtPriorityThreadInfo>()` bytes long.
///
/// This is exposed in the C API as `ATP_THREAD_INFO_SIZE`.
///
/// This call is useful on Linux desktop only, when the process is sandboxed, cannot promote itself
/// directly, and the `atp_thread_info` struct must be passed via IPC.
+///
+/// # Safety
+///
+/// This function is safe only and only if the first pointer comes from this library, and the
+/// second pointer is at least ATP_THREAD_INFO_SIZE bytes long.
#[no_mangle]
pub unsafe extern "C" fn atp_serialize_thread_info(
thread_info: *mut atp_thread_info,
bytes: *mut libc::c_void,
) {
let thread_info = &mut *thread_info;
let source = thread_info.0.serialize();
std::ptr::copy(source.as_ptr(), bytes as *mut u8, source.len());
@@ -289,16 +298,20 @@ pub unsafe extern "C" fn atp_serialize_t
/// From a byte buffer, return a `RtPriorityThreadInfo`, with a C API.
///
/// This call is useful on Linux desktop only, when the process is sandboxed and
/// cannot promote itself directly.
///
/// # Arguments
///
/// A byte buffer containing a serializezd `RtPriorityThreadInfo`.
+///
+/// # Safety
+///
+/// This function is safe only and only if pointer is at least ATP_THREAD_INFO_SIZE bytes long.
#[no_mangle]
pub unsafe extern "C" fn atp_deserialize_thread_info(
in_bytes: *mut u8,
) -> *mut atp_thread_info {
let bytes = *(in_bytes as *mut [u8; std::mem::size_of::<RtPriorityThreadInfoInternal>()]);
let thread_info = RtPriorityThreadInfoInternal::deserialize(bytes);
Box::into_raw(Box::new(atp_thread_info(thread_info)))
}
@@ -364,16 +377,20 @@ pub struct atp_thread_info(RtPriorityThr
/// `atp_get_current_thread_info` on the thread to promote.
/// * `audio_buffer_frames` - the exact or an upper limit on the number of frames that have to be
/// rendered each callback, or 0 for a sensible default value.
/// * `audio_samplerate_hz` - the sample-rate for this audio stream, in Hz.
///
/// # Return value
///
/// A pointer to an `atp_handle` in case of success, NULL otherwise.
+///
+/// # Safety
+///
+/// This function is safe as long as the first pointer comes from this library.
#[no_mangle]
pub unsafe extern "C" fn atp_promote_thread_to_real_time(
thread_info: *mut atp_thread_info,
audio_buffer_frames: u32,
audio_samplerate_hz: u32,
) -> *mut atp_handle {
let thread_info = &mut *thread_info;
match promote_thread_to_real_time(thread_info.0, audio_buffer_frames, audio_samplerate_hz) {
@@ -386,16 +403,20 @@ pub unsafe extern "C" fn atp_promote_thr
///
/// # Arguments
///
/// `handle` - an opaque struct received from a promoting function.
///
/// # Return value
///
/// 0 in case of success, non-zero otherwise.
+///
+/// # Safety
+///
+/// This function is safe as long as the first pointer comes from this library, or is null.
#[no_mangle]
pub unsafe extern "C" fn atp_demote_thread_from_real_time(thread_info: *mut atp_thread_info) -> i32 {
if thread_info.is_null() {
return 1;
}
let thread_info = (*thread_info).0;
match demote_thread_from_real_time(thread_info) {
@@ -631,22 +652,22 @@ mod tests {
let info2 = thread_info_deserialize(bytes);
assert!(info == info2);
}
}
#[test]
fn test_remote_promotion() {
let (rd, wr) = pipe().unwrap();
- match fork().expect("fork failed") {
+ match unsafe { fork().expect("fork failed") } {
ForkResult::Parent{ child } => {
eprintln!("Parent PID: {}", getpid());
let mut bytes = [0_u8; std::mem::size_of::<RtPriorityThreadInfo>()];
match read(rd, &mut bytes) {
- Ok(_) => {
+ Ok(_) => {
let info = RtPriorityThreadInfo::deserialize(bytes);
match promote_thread_to_real_time(info, 0, 44100) {
Ok(_) => {
eprintln!("thread promotion in the child from the parent succeeded");
assert!(true);
}
Err(_) => {
eprintln!("promotion Err");
--- a/third_party/rust/audio_thread_priority/src/rt_linux.rs
+++ b/third_party/rust/audio_thread_priority/src/rt_linux.rs
@@ -3,16 +3,17 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
/* Widely copied from dbus-rs/dbus/examples/rtkit.rs */
extern crate dbus;
extern crate libc;
use std::cmp;
+use std::convert::TryInto;
use std::error::Error;
use std::io::Error as OSError;
use dbus::{BusType, Connection, Message, MessageItem, Props};
use crate::AudioThreadPriorityError;
const DBUS_SOCKET_TIMEOUT: i32 = 10_000;
@@ -107,27 +108,27 @@ fn rtkit_set_realtime(thread: u64, pid:
};
let c = Connection::get_private(BusType::System)?;
c.send_with_reply_and_block(m, DBUS_SOCKET_TIMEOUT)?;
Ok(())
}
/// Returns the maximum priority, maximum real-time time slice, and the current real-time time
/// slice for this process.
-fn get_limits() -> Result<(i64, u64, libc::rlimit64), AudioThreadPriorityError> {
+fn get_limits() -> Result<(i64, u64, libc::rlimit), AudioThreadPriorityError> {
let c = Connection::get_private(BusType::System)?;
let p = Props::new(
&c,
"org.freedesktop.RealtimeKit1",
"/org/freedesktop/RealtimeKit1",
"org.freedesktop.RealtimeKit1",
DBUS_SOCKET_TIMEOUT,
);
- let mut current_limit = libc::rlimit64 {
+ let mut current_limit = libc::rlimit {
rlim_cur: 0,
rlim_max: 0,
};
let max_prio = item_as_i64(p.get("MaxRealtimePriority")?)?;
if max_prio < 0 {
return Err(AudioThreadPriorityError::new(
"invalid negative MaxRealtimePriority",
@@ -136,36 +137,41 @@ fn get_limits() -> Result<(i64, u64, lib
let max_rttime = item_as_i64(p.get("RTTimeUSecMax")?)?;
if max_rttime < 0 {
return Err(AudioThreadPriorityError::new(
"invalid negative RTTimeUSecMax",
));
}
- if unsafe { libc::getrlimit64(libc::RLIMIT_RTTIME, &mut current_limit) } < 0 {
+ if unsafe { libc::getrlimit(libc::RLIMIT_RTTIME, &mut current_limit) } < 0 {
return Err(AudioThreadPriorityError::new_with_inner(
- "getrlimit64",
+ "getrlimit",
Box::new(OSError::last_os_error()),
));
}
Ok((max_prio, (max_rttime as u64), current_limit))
}
fn set_limits(request: u64, max: u64) -> Result<(), AudioThreadPriorityError> {
// Set a soft limit to the limit requested, to be able to handle going over the limit using
- // SIGXCPU. Set the hard limit to the maxium slice to prevent getting SIGKILL.
- let new_limit = libc::rlimit64 {
- rlim_cur: request,
- rlim_max: max,
+ // SIGXCPU. Set the hard limit to the maximum slice to prevent getting SIGKILL.
+ #[allow(clippy::useless_conversion)]
+ let new_limit = libc::rlimit {
+ rlim_cur: request
+ .try_into()
+ .map_err(|_| AudioThreadPriorityError::new("setrlimit"))?,
+ rlim_max: max
+ .try_into()
+ .map_err(|_| AudioThreadPriorityError::new("setrlimit"))?,
};
- if unsafe { libc::setrlimit64(libc::RLIMIT_RTTIME, &new_limit) } < 0 {
+ if unsafe { libc::setrlimit(libc::RLIMIT_RTTIME, &new_limit) } < 0 {
return Err(AudioThreadPriorityError::new_with_inner(
- "setrlimit64",
+ "setrlimit",
Box::new(OSError::last_os_error()),
));
}
Ok(())
}
pub fn promote_current_thread_to_real_time_internal(
@@ -267,43 +273,45 @@ pub fn set_real_time_hard_limit_internal
};
let budget_us = (buffer_frames * 1_000_000 / audio_samplerate_hz) as u64;
// It's only necessary to set RLIMIT_RTTIME to something when in the child, skip it if it's a
// remoting call.
let (_, max_rttime, _) = get_limits()?;
// Only take what we need, or cap at the system limit, no further.
- let rttime_request = cmp::min(budget_us, max_rttime as u64);
+ let rttime_request = cmp::min(budget_us, max_rttime);
set_limits(rttime_request, max_rttime)?;
Ok(())
}
/// Promote a thread (possibly in another process) identified by its tid, to real-time.
pub fn promote_thread_to_real_time_internal(
thread_info: RtPriorityThreadInfoInternal,
audio_buffer_frames: u32,
audio_samplerate_hz: u32,
) -> Result<RtPriorityHandleInternal, AudioThreadPriorityError> {
let RtPriorityThreadInfoInternal { pid, thread_id, .. } = thread_info;
let handle = RtPriorityHandleInternal { thread_info };
- let (_, _, limits) = get_limits()?;
set_real_time_hard_limit_internal(audio_buffer_frames, audio_samplerate_hz)?;
let r = rtkit_set_realtime(thread_id as u64, pid as u64, RT_PRIO_DEFAULT);
match r {
Ok(_) => Ok(handle),
Err(e) => {
- if unsafe { libc::setrlimit64(libc::RLIMIT_RTTIME, &limits) } < 0 {
+ let (_, _, limits) = get_limits()?;
+ if limits.rlim_cur != libc::RLIM_INFINITY
+ && unsafe { libc::setrlimit(libc::RLIMIT_RTTIME, &limits) } < 0
+ {
return Err(AudioThreadPriorityError::new_with_inner(
- "setrlimit64",
+ "setrlimit",
Box::new(OSError::last_os_error()),
));
}
Err(AudioThreadPriorityError::new_with_inner(
"Thread promotion error",
e,
))
}
--- a/third_party/rust/audio_thread_priority/src/rt_mach.rs
+++ b/third_party/rust/audio_thread_priority/src/rt_mach.rs
@@ -65,17 +65,17 @@ pub fn demote_current_thread_from_real_t
unsafe {
let mut h = rt_priority_handle;
let rv: kern_return_t = thread_policy_set(
h.tid,
THREAD_TIME_CONSTRAINT_POLICY,
(&mut h.previous_time_constraint_policy) as *mut _ as thread_policy_t,
THREAD_TIME_CONSTRAINT_POLICY_COUNT!(),
);
- if rv != KERN_SUCCESS as i32 {
+ if rv != KERN_SUCCESS {
return Err(AudioThreadPriorityError::new(
"thread demotion error: thread_policy_get: RT",
));
}
info!("thread {} priority restored.", h.tid);
}
@@ -114,17 +114,17 @@ pub fn promote_current_thread_to_real_ti
let mut rv: kern_return_t = thread_policy_get(
tid,
THREAD_TIME_CONSTRAINT_POLICY,
(&mut time_constraints) as *mut _ as thread_policy_t,
&mut count,
&mut get_default,
);
- if rv != KERN_SUCCESS as i32 {
+ if rv != KERN_SUCCESS {
return Err(AudioThreadPriorityError::new(
"thread promotion error: thread_policy_get: time_constraint",
));
}
rt_priority_handle.previous_time_constraint_policy = time_constraints;
let cb_duration = buffer_frames as f32 / (audio_samplerate_hz as f32) * 1000.;
@@ -144,17 +144,17 @@ pub fn promote_current_thread_to_real_ti
};
rv = thread_policy_set(
tid,
THREAD_TIME_CONSTRAINT_POLICY,
(&mut time_constraints) as *mut _ as thread_policy_t,
THREAD_TIME_CONSTRAINT_POLICY_COUNT!(),
);
- if rv != KERN_SUCCESS as i32 {
+ if rv != KERN_SUCCESS {
return Err(AudioThreadPriorityError::new(
"thread promotion error: thread_policy_set: time_constraint",
));
}
info!("thread {} bumped to real time priority.", tid);
}
--- a/third_party/rust/audio_thread_priority/src/rt_win.rs
+++ b/third_party/rust/audio_thread_priority/src/rt_win.rs
@@ -1,72 +1,43 @@
-#[cfg(feature = "windows")]
-mod os {
- pub use windows::Win32::Foundation::GetLastError;
- pub use windows::Win32::Foundation::HANDLE;
- pub use windows::Win32::Foundation::PSTR;
- pub use windows::Win32::System::Threading::{
- AvRevertMmThreadCharacteristics, AvSetMmThreadCharacteristicsA,
- };
-
- pub fn ok(rv: windows::Win32::Foundation::BOOL) -> bool {
- rv.as_bool()
- }
-
- pub fn invalid_handle(handle: HANDLE) -> bool {
- handle.is_invalid()
- }
-}
-#[cfg(feature = "winapi")]
-mod os {
- pub use winapi::shared::ntdef::HANDLE;
- pub use winapi::um::avrt::{AvRevertMmThreadCharacteristics, AvSetMmThreadCharacteristicsA};
- pub use winapi::um::errhandlingapi::GetLastError;
-
- pub fn ok(rv: winapi::shared::minwindef::BOOL) -> bool {
- rv != 0
- }
-
- #[allow(non_snake_case)]
- pub fn PSTR(ptr: *const u8) -> *const i8 {
- ptr as _
- }
-
- pub fn invalid_handle(handle: HANDLE) -> bool {
- handle.is_null()
- }
-}
+use windows_sys::s;
+use windows_sys::Win32::Foundation::GetLastError;
+use windows_sys::Win32::Foundation::FALSE;
+use windows_sys::Win32::Foundation::HANDLE;
+use windows_sys::Win32::System::Threading::{
+ AvRevertMmThreadCharacteristics, AvSetMmThreadCharacteristicsA,
+};
use crate::AudioThreadPriorityError;
use log::info;
#[derive(Debug)]
pub struct RtPriorityHandleInternal {
mmcss_task_index: u32,
- task_handle: os::HANDLE,
+ task_handle: HANDLE,
}
impl RtPriorityHandleInternal {
- pub fn new(mmcss_task_index: u32, task_handle: os::HANDLE) -> RtPriorityHandleInternal {
+ pub fn new(mmcss_task_index: u32, task_handle: HANDLE) -> RtPriorityHandleInternal {
RtPriorityHandleInternal {
mmcss_task_index,
task_handle,
}
}
}
pub fn demote_current_thread_from_real_time_internal(
rt_priority_handle: RtPriorityHandleInternal,
) -> Result<(), AudioThreadPriorityError> {
- let rv = unsafe { os::AvRevertMmThreadCharacteristics(rt_priority_handle.task_handle) };
- if !os::ok(rv) {
+ let rv = unsafe { AvRevertMmThreadCharacteristics(rt_priority_handle.task_handle) };
+ if rv == FALSE {
return Err(AudioThreadPriorityError::new(&format!(
"Unable to restore the thread priority ({:?})",
- unsafe { os::GetLastError() }
+ unsafe { GetLastError() }
)));
}
info!(
"task {} priority restored.",
rt_priority_handle.mmcss_task_index
);
@@ -74,24 +45,23 @@ pub fn demote_current_thread_from_real_t
}
pub fn promote_current_thread_to_real_time_internal(
_audio_buffer_frames: u32,
_audio_samplerate_hz: u32,
) -> Result<RtPriorityHandleInternal, AudioThreadPriorityError> {
let mut task_index = 0u32;
- let handle =
- unsafe { os::AvSetMmThreadCharacteristicsA(os::PSTR("Audio\0".as_ptr()), &mut task_index) };
+ let handle = unsafe { AvSetMmThreadCharacteristicsA(s!("Audio"), &mut task_index) };
let handle = RtPriorityHandleInternal::new(task_index, handle);
- if os::invalid_handle(handle.task_handle) {
+ if handle.task_handle == 0 {
return Err(AudioThreadPriorityError::new(&format!(
"Unable to restore the thread priority ({:?})",
- unsafe { os::GetLastError() }
+ unsafe { GetLastError() }
)));
}
info!(
"task {} bumped to real time priority.",
handle.mmcss_task_index
);
--- a/third_party/rust/audioipc2-client/.cargo-checksum.json
+++ b/third_party/rust/audioipc2-client/.cargo-checksum.json
@@ -1,1 +1,1 @@
-{"files":{"Cargo.toml":"234b81b986ab93768ccacc68d973d6125e3769337d4b0a7b137d19d1666db8a4","cbindgen.toml":"fb6abe1671497f432a06e40b1db7ed7cd2cceecbd9a2382193ad7534e8855e34","src/context.rs":"86d31460a48a9bdc0ac4fbef522d267c26f68dd79a12e0cbc35b3a4b6f6449dc","src/lib.rs":"c4a6797734489280f6b97dd72c9e51a7bd7be4104592eece3929e29d45cbca4a","src/send_recv.rs":"859abe75b521eb4297c84b30423814b5b87f3c7741ad16fe72189212e123e1ac","src/stream.rs":"3101f4052e35c1600adafedc67aed92d7d5531ff0ff4845de0a5ea3cedef872d"},"package":null}
\ No newline at end of file
+{"files":{"Cargo.toml":"d7cfe88a0f0086d4216e3f4ad3de0620417fcbda61c9852476459a9249131996","cbindgen.toml":"fb6abe1671497f432a06e40b1db7ed7cd2cceecbd9a2382193ad7534e8855e34","src/context.rs":"86d31460a48a9bdc0ac4fbef522d267c26f68dd79a12e0cbc35b3a4b6f6449dc","src/lib.rs":"c4a6797734489280f6b97dd72c9e51a7bd7be4104592eece3929e29d45cbca4a","src/send_recv.rs":"859abe75b521eb4297c84b30423814b5b87f3c7741ad16fe72189212e123e1ac","src/stream.rs":"3101f4052e35c1600adafedc67aed92d7d5531ff0ff4845de0a5ea3cedef872d"},"package":null}
\ No newline at end of file
--- a/third_party/rust/audioipc2-client/Cargo.toml
+++ b/third_party/rust/audioipc2-client/Cargo.toml
@@ -16,15 +16,18 @@ version = "0.5.0"
authors = [
"Matthew Gregan <kinetik@flim.org>",
"Dan Glastonbury <dan.glastonbury@gmail.com>",
]
description = "Cubeb Backend for talking to remote cubeb server."
license = "ISC"
[dependencies]
-audio_thread_priority = "0.26"
cubeb-backend = "0.10"
log = "0.4"
+[dependencies.audio_thread_priority]
+version = "0.30"
+default-features = false
+
[dependencies.audioipc]
path = "../audioipc"
package = "audioipc2"
--- a/third_party/rust/audioipc2-server/.cargo-checksum.json
+++ b/third_party/rust/audioipc2-server/.cargo-checksum.json
@@ -1,1 +1,1 @@
-{"files":{"Cargo.toml":"9c801164c20a9af8c43135848244112002bd07a05b1c7165c2eb7be2db23898b","cbindgen.toml":"fb6abe1671497f432a06e40b1db7ed7cd2cceecbd9a2382193ad7534e8855e34","src/lib.rs":"06aff4fd1326aeabb16b01f81a6f3c59c1717ebe96285a063724830cdf30303a","src/server.rs":"ea839fe4607ba6b70a1ef5dfb2305eb668b148820c5590b87192609fbe3c9edd"},"package":null}
\ No newline at end of file
+{"files":{"Cargo.toml":"4e66d9ec1e8baa7ad01ace373a921bc019e38bcb23f782be1daa8578f40b6086","cbindgen.toml":"fb6abe1671497f432a06e40b1db7ed7cd2cceecbd9a2382193ad7534e8855e34","src/lib.rs":"06aff4fd1326aeabb16b01f81a6f3c59c1717ebe96285a063724830cdf30303a","src/server.rs":"ea839fe4607ba6b70a1ef5dfb2305eb668b148820c5590b87192609fbe3c9edd"},"package":null}
\ No newline at end of file
--- a/third_party/rust/audioipc2-server/Cargo.toml
+++ b/third_party/rust/audioipc2-server/Cargo.toml
@@ -16,21 +16,24 @@ version = "0.5.0"
authors = [
"Matthew Gregan <kinetik@flim.org>",
"Dan Glastonbury <dan.glastonbury@gmail.com>",
]
description = "Remote cubeb server"
license = "ISC"
[dependencies]
-audio_thread_priority = "0.26"
cubeb-core = "0.10.0"
log = "0.4"
once_cell = "1.2.0"
slab = "0.4"
+[dependencies.audio_thread_priority]
+version = "0.30"
+default-features = false
+
[dependencies.audioipc]
path = "../audioipc"
package = "audioipc2"
[dependencies.error-chain]
version = "0.12.0"
default-features = false
--- a/third_party/rust/audioipc2/.cargo-checksum.json
+++ b/third_party/rust/audioipc2/.cargo-checksum.json
@@ -1,1 +1,1 @@
-{"files":{"Cargo.toml":"8434bf0fc2131bdca6655fc0e6ff3b87218c92f342785dd453a4018ed1a70b52","benches/serialization.rs":"d56855d868dab6aa22c8b03a61084535351b76c94b68d8b1d20764e352fe473f","build.rs":"65df9a97c6cdaa3faf72581f04ac289197b0b1797d69d22c1796e957ff1089e2","src/codec.rs":"38408b512d935cd7889a03b25dd14b36083ec4e6d2fcabd636182cf45e3d50bc","src/errors.rs":"67a4a994d0724397657581cde153bdfc05ce86e7efc467f23fafc8f64df80fa4","src/ipccore.rs":"ba339eebdc2d8a6d0cb9b294344809e63e404e220fda643b63a8a3ff63a755e8","src/lib.rs":"3881e9069f37e824cbb5dacf1c37192c08b84068098fef96ede6f2ae284edfe3","src/messages.rs":"452362da2cace9a0f2e3134c190ecb6a9997f8be4036cde06643e17c6c238240","src/rpccore.rs":"025b6614f1c42b96b0a8e74fd7881032d338c66e0d67ec0af70f910a9e30ebe1","src/shm.rs":"f8bc0ab17e04b86a746aea7aa4eb15f402e29d80e0d2f9d7c22ac8375a0cea85","src/sys/mod.rs":"e6fa1d260abf093e1f7b50185195e2d3aee0eb8c9774c6f253953b5896d838f3","src/sys/unix/cmsg.rs":"6f0236bf6cd66ccd237b268348a826ae1d266073c2adadcfaae703c556230065","src/sys/unix/cmsghdr.c":"d7344b3dc15cdce410c68669b848bb81f7fe36362cd3699668cb613fa05180f8","src/sys/unix/mod.rs":"59835f0d5509940078b1820a54f49fc5514adeb3e45e7d21e3ab917431da2e74","src/sys/unix/msg.rs":"0e297d73bae9414184f85c2209cca0a3fde6d999a3f1d3f42faa3f56b6d57233","src/sys/windows/mod.rs":"7eaabb76e62c6962b636320e2bbf79a78fce61659c799a798f7dd6d56b0be8a1"},"package":null}
\ No newline at end of file
+{"files":{"Cargo.toml":"4d025a5bf0f59f660b3b52ec6a0da028f61269b17e4e33041b768ea07b8a9448","benches/serialization.rs":"d56855d868dab6aa22c8b03a61084535351b76c94b68d8b1d20764e352fe473f","build.rs":"65df9a97c6cdaa3faf72581f04ac289197b0b1797d69d22c1796e957ff1089e2","src/codec.rs":"38408b512d935cd7889a03b25dd14b36083ec4e6d2fcabd636182cf45e3d50bc","src/errors.rs":"67a4a994d0724397657581cde153bdfc05ce86e7efc467f23fafc8f64df80fa4","src/ipccore.rs":"ba339eebdc2d8a6d0cb9b294344809e63e404e220fda643b63a8a3ff63a755e8","src/lib.rs":"3881e9069f37e824cbb5dacf1c37192c08b84068098fef96ede6f2ae284edfe3","src/messages.rs":"452362da2cace9a0f2e3134c190ecb6a9997f8be4036cde06643e17c6c238240","src/rpccore.rs":"025b6614f1c42b96b0a8e74fd7881032d338c66e0d67ec0af70f910a9e30ebe1","src/shm.rs":"f8bc0ab17e04b86a746aea7aa4eb15f402e29d80e0d2f9d7c22ac8375a0cea85","src/sys/mod.rs":"e6fa1d260abf093e1f7b50185195e2d3aee0eb8c9774c6f253953b5896d838f3","src/sys/unix/cmsg.rs":"6f0236bf6cd66ccd237b268348a826ae1d266073c2adadcfaae703c556230065","src/sys/unix/cmsghdr.c":"d7344b3dc15cdce410c68669b848bb81f7fe36362cd3699668cb613fa05180f8","src/sys/unix/mod.rs":"59835f0d5509940078b1820a54f49fc5514adeb3e45e7d21e3ab917431da2e74","src/sys/unix/msg.rs":"0e297d73bae9414184f85c2209cca0a3fde6d999a3f1d3f42faa3f56b6d57233","src/sys/windows/mod.rs":"7eaabb76e62c6962b636320e2bbf79a78fce61659c799a798f7dd6d56b0be8a1"},"package":null}
\ No newline at end of file
--- a/third_party/rust/audioipc2/Cargo.toml
+++ b/third_party/rust/audioipc2/Cargo.toml
@@ -58,17 +58,17 @@ features = ["html_reports"]
[build-dependencies]
cc = "1.0"
[target."cfg(target_os = \"android\")".dependencies]
ashmem = "0.1.2"
[target."cfg(target_os = \"linux\")".dependencies.audio_thread_priority]
-version = "0.26.1"
+version = "0.30"
default-features = false
[target."cfg(unix)".dependencies]
arrayvec = "0.7"
iovec = "0.1"
libc = "0.2"
memmap2 = "0.5"
--- a/toolkit/library/rust/shared/Cargo.toml
+++ b/toolkit/library/rust/shared/Cargo.toml
@@ -20,18 +20,18 @@ xpcom = { path = "../../../../xpcom/rust
prefs_parser = { path = "../../../../modules/libpref/parser" }
static_prefs = { path = "../../../../modules/libpref/init/static_prefs" }
profiler_helper = { path = "../../../../tools/profiler/rust-helper", optional = true }
mozurl = { path = "../../../../netwerk/base/mozurl" }
webrender_bindings = { path = "../../../../gfx/webrender_bindings" }
cubeb-coreaudio = { git = "https://github.com/mozilla/cubeb-coreaudio-rs", rev = "93b5c01a131f65c83c11aeb317f4583405c5eb79", optional = true }
cubeb-pulse = { git = "https://github.com/mozilla/cubeb-pulse-rs", rev="cf48897be5cbe147d051ebbbe1eaf5fd8fb6bbc9", optional = true, features=["pulse-dlopen"] }
cubeb-sys = { version = "0.10.3", optional = true, features=["gecko-in-tree"] }
-audioipc2-client = { git = "https://github.com/mozilla/audioipc", rev = "ec6af6ecf8ba50b51f13d18f417de8cfb8460543", optional = true }
-audioipc2-server = { git = "https://github.com/mozilla/audioipc", rev = "ec6af6ecf8ba50b51f13d18f417de8cfb8460543", optional = true }
+audioipc2-client = { git = "https://github.com/mozilla/audioipc", rev = "6be424d75f1367e70f2f5ddcacd6d0237e81a6a9", optional = true }
+audioipc2-server = { git = "https://github.com/mozilla/audioipc", rev = "6be424d75f1367e70f2f5ddcacd6d0237e81a6a9", optional = true }
encoding_glue = { path = "../../../../intl/encoding_glue" }
authrs_bridge = { path = "../../../../dom/webauthn/authrs_bridge" }
gkrust_utils = { path = "../../../../xpcom/rust/gkrust_utils" }
gecko_logger = { path = "../../../../xpcom/rust/gecko_logger" }
rsdparsa_capi = { path = "../../../../dom/media/webrtc/sdp/rsdparsa_capi" }
# We have these to enforce common feature sets for said crates.
log = {version = "0.4", features = ["release_max_level_info"]}
cose-c = { version = "0.1.5" }
@@ -39,17 +39,17 @@ jsrust_shared = { path = "../../../../js
cascade_bloom_filter = { path = "../../../components/cascade_bloom_filter" }
cert_storage = { path = "../../../../security/manager/ssl/cert_storage" }
crypto_hash = { path = "../../../../security/manager/ssl/crypto_hash" }
data_storage = { path = "../../../../security/manager/ssl/data_storage" }
bitsdownload = { path = "../../../components/bitsdownload", optional = true }
storage = { path = "../../../../storage/rust" }
bookmark_sync = { path = "../../../components/places/bookmark_sync", optional = true }
chardetng_c = "0.1.1"
-audio_thread_priority = { version = "0.26.1", default_features = false, features = ["winapi"] }
+audio_thread_priority = { version = "0.30", default_features = false }
mdns_service = { path="../../../../dom/media/webrtc/transport/mdns_service", optional = true }
neqo_glue = { path = "../../../../netwerk/socket/neqo_glue" }
wgpu_bindings = { path = "../../../../gfx/wgpu_bindings" }
mapped_hyph = { git = "https://github.com/jfkthame/mapped_hyph.git", rev = "c7651a0cffff41996ad13c44f689bd9cd2192c01" }
fog_control = { path = "../../../components/glean" }
app_services_logger = { path = "../../../../services/common/app_services_logger" }
http_sfv = { path = "../../../../netwerk/base/http-sfv" }
unic-langid = { version = "0.9", features = ["likelysubtags"] }