Bug 1746352 - Update audioipc to 776ef93a. r=cubeb-reviewers,padenot

Differential Revision: https://phabricator.services.mozilla.com/D133995
This commit is contained in:
Matthew Gregan 2021-12-16 09:32:27 +00:00
Родитель 8f586038da
Коммит 96e9bde4a3
12 изменённых файлов: 16 добавлений и 201 удалений

Просмотреть файл

@ -35,7 +35,7 @@ rev = "dea28d0c7d9952bbf430701ee244f6a4349c98f1"
[source."https://github.com/mozilla/audioipc-2"]
git = "https://github.com/mozilla/audioipc-2"
replace-with = "vendored-sources"
rev = "470320364f59672c0e1ee60240f2cd15f0e5b52f"
rev = "776ef93a9fdb20ac1ef6b7907bdd0493480388ee"
[source."https://github.com/mozilla/application-services"]
git = "https://github.com/mozilla/application-services"
@ -61,11 +61,6 @@ git = "https://github.com/kinetiknz/audioipc-2"
replace-with = "vendored-sources"
rev = "abd4a0132ea65057b554221c8f112a9bedd33a92"
[source."https://github.com/kinetiknz/ashmem-rs"]
git = "https://github.com/kinetiknz/ashmem-rs"
replace-with = "vendored-sources"
rev = "e47f470a54193532d60057ec54f864e06aeaff36"
[source."https://github.com/jfkthame/mapped_hyph.git"]
git = "https://github.com/jfkthame/mapped_hyph.git"
replace-with = "vendored-sources"

20
Cargo.lock сгенерированный
Просмотреть файл

@ -115,15 +115,6 @@ dependencies = [
"libloading 0.7.2",
]
[[package]]
name = "ashmem"
version = "0.1.0"
source = "git+https://github.com/kinetiknz/ashmem-rs?rev=e47f470a54193532d60057ec54f864e06aeaff36#e47f470a54193532d60057ec54f864e06aeaff36"
dependencies = [
"ioctl-sys",
"libc",
]
[[package]]
name = "ashmem"
version = "0.1.1"
@ -200,9 +191,9 @@ dependencies = [
[[package]]
name = "audioipc"
version = "0.2.5"
source = "git+https://github.com/mozilla/audioipc-2?rev=470320364f59672c0e1ee60240f2cd15f0e5b52f#470320364f59672c0e1ee60240f2cd15f0e5b52f"
source = "git+https://github.com/mozilla/audioipc-2?rev=776ef93a9fdb20ac1ef6b7907bdd0493480388ee#776ef93a9fdb20ac1ef6b7907bdd0493480388ee"
dependencies = [
"ashmem 0.1.0",
"ashmem",
"audio_thread_priority",
"bincode",
"bytes 0.4.12",
@ -229,12 +220,11 @@ dependencies = [
[[package]]
name = "audioipc-client"
version = "0.4.0"
source = "git+https://github.com/mozilla/audioipc-2?rev=470320364f59672c0e1ee60240f2cd15f0e5b52f#470320364f59672c0e1ee60240f2cd15f0e5b52f"
source = "git+https://github.com/mozilla/audioipc-2?rev=776ef93a9fdb20ac1ef6b7907bdd0493480388ee#776ef93a9fdb20ac1ef6b7907bdd0493480388ee"
dependencies = [
"audio_thread_priority",
"audioipc",
"cubeb-backend",
"fallible_collections",
"futures 0.1.31",
"futures-cpupool",
"log",
@ -244,7 +234,7 @@ dependencies = [
[[package]]
name = "audioipc-server"
version = "0.2.3"
source = "git+https://github.com/mozilla/audioipc-2?rev=470320364f59672c0e1ee60240f2cd15f0e5b52f#470320364f59672c0e1ee60240f2cd15f0e5b52f"
source = "git+https://github.com/mozilla/audioipc-2?rev=776ef93a9fdb20ac1ef6b7907bdd0493480388ee#776ef93a9fdb20ac1ef6b7907bdd0493480388ee"
dependencies = [
"audio_thread_priority",
"audioipc",
@ -262,7 +252,7 @@ name = "audioipc2"
version = "0.5.0"
source = "git+https://github.com/kinetiknz/audioipc-2?rev=abd4a0132ea65057b554221c8f112a9bedd33a92#abd4a0132ea65057b554221c8f112a9bedd33a92"
dependencies = [
"ashmem 0.1.1",
"ashmem",
"audio_thread_priority",
"bincode",
"bytes 0.4.12",

Просмотреть файл

@ -1 +0,0 @@
{"files":{"Cargo.toml":"90a69817003711b9f60ce9c907c8bd35b52aafafd074aecf4e66b1fa6e1c716f","src/lib.rs":"0024c010b7618e4e25bb6ea3295f229a0e4bf2ecd7144c764de3f175ad839ce5"},"package":null}

10
third_party/rust/ashmem-0.1.0/Cargo.toml поставляемый
Просмотреть файл

@ -1,10 +0,0 @@
[package]
name = "ashmem"
version = "0.1.0"
authors = ["Matthew Gregan <kinetik@flim.org>"]
edition = "2018"
license = "ISC"
[dependencies]
libc = "0.2"
ioctl-sys = "0.7"

160
third_party/rust/ashmem-0.1.0/src/lib.rs поставляемый
Просмотреть файл

@ -1,160 +0,0 @@
#![cfg(target_os = "android")]
//! Provides a wrapper around Android's ASharedMemory API.
//!
//! ashmem has existed in Android as a non-public API for some time.
//! Originally accessed via ioctl, it was later available via libcutils as ashmem_create_region etc.
//! ASharedMemory is the new public API, but it isn't available until API 26 (Android 8).
//! Builds targeting Android 10 (API 29) are no longer permitted to access ashmem via the ioctl interface.
//! This makes life for a portable program difficult - you can't reliably use the old or new interface during this transition period.
//! We try to dynamically load the new API first, then fall back to the ioctl interface.
//!
//! References:
//! - [ASharedMemory documentation](https://developer.android.com/ndk/reference/group/memory)
//! - [Linux ashmem.h definitions](https://elixir.bootlin.com/linux/v5.11.8/source/drivers/staging/android/uapi/ashmem.h)
#[macro_use]
extern crate ioctl_sys;
const __ASHMEMIOC: u32 = 0x77;
static mut LIBANDROID_ASHAREDMEMORY_CREATE: Option<
extern "C" fn(*const libc::c_char, libc::size_t) -> libc::c_int,
> = None;
static mut LIBANDROID_ASHAREDMEMORY_GETSIZE: Option<extern "C" fn(libc::c_int) -> libc::size_t> =
None;
static mut LIBANDROID_ASHAREDMEMORY_SETPROT: Option<
extern "C" fn(libc::c_int, libc::c_int) -> libc::c_int,
> = None;
unsafe fn maybe_init() {
const LIBANDROID_NAME: *const libc::c_char = "libandroid\0".as_ptr() as *const libc::c_char;
const LIBANDROID_ASHAREDMEMORY_CREATE_NAME: *const libc::c_char =
"ASharedMemory_create\0".as_ptr() as _;
const LIBANDROID_ASHAREDMEMORY_GETSIZE_NAME: *const libc::c_char =
"ASharedMemory_getSize\0".as_ptr() as _;
const LIBANDROID_ASHAREDMEMORY_SETPROT_NAME: *const libc::c_char =
"ASharedMemory_setProt\0".as_ptr() as _;
static ONCE: std::sync::Once = std::sync::Once::new();
ONCE.call_once(|| {
// Leak the handle, there's no safe time to close it.
let handle = libc::dlopen(LIBANDROID_NAME, libc::RTLD_LAZY | libc::RTLD_LOCAL);
if handle.is_null() {
return;
}
// Transmute guarantee for `fn -> Option<fn>`: https://doc.rust-lang.org/std/option/#representation
LIBANDROID_ASHAREDMEMORY_CREATE =
std::mem::transmute(libc::dlsym(handle, LIBANDROID_ASHAREDMEMORY_CREATE_NAME));
LIBANDROID_ASHAREDMEMORY_GETSIZE =
std::mem::transmute(libc::dlsym(handle, LIBANDROID_ASHAREDMEMORY_GETSIZE_NAME));
LIBANDROID_ASHAREDMEMORY_SETPROT =
std::mem::transmute(libc::dlsym(handle, LIBANDROID_ASHAREDMEMORY_SETPROT_NAME));
});
}
/// See [ASharedMemory_create NDK documentation](https://developer.android.com/ndk/reference/group/memory#asharedmemory_create)
///
/// # Safety
///
/// Directly calls C or kernel APIs.
#[allow(non_snake_case)]
pub unsafe fn ASharedMemory_create(name: *const libc::c_char, size: libc::size_t) -> libc::c_int {
const ASHMEM_NAME_DEF: *const libc::c_char = "/dev/ashmem".as_ptr() as _;
const ASHMEM_NAME_LEN: usize = 256;
const ASHMEM_SET_NAME: libc::c_int = iow!(
__ASHMEMIOC,
1,
std::mem::size_of::<[libc::c_char; ASHMEM_NAME_LEN]>()
) as _;
const ASHMEM_SET_SIZE: libc::c_int =
iow!(__ASHMEMIOC, 3, std::mem::size_of::<libc::size_t>()) as _;
maybe_init();
if let Some(fun) = LIBANDROID_ASHAREDMEMORY_CREATE {
return fun(name, size);
}
let fd = libc::open(ASHMEM_NAME_DEF, libc::O_RDWR, 0o600);
if fd < 0 {
return fd;
}
if !name.is_null() {
// NOTE: libcutils uses a local stack copy of `name`.
let r = libc::ioctl(fd, ASHMEM_SET_NAME, name);
if r != 0 {
libc::close(fd);
return -1;
}
}
let r = libc::ioctl(fd, ASHMEM_SET_SIZE, size);
if r != 0 {
libc::close(fd);
return -1;
}
fd
}
/// See [ASharedMemory_getSize NDK documentation](https://developer.android.com/ndk/reference/group/memory#asharedmemory_getsize)
///
/// # Safety
///
/// Directly calls C or kernel APIs.
#[allow(non_snake_case)]
pub unsafe fn ASharedMemory_getSize(fd: libc::c_int) -> libc::size_t {
const ASHMEM_GET_SIZE: libc::c_int = io!(__ASHMEMIOC, 4) as _;
maybe_init();
if let Some(fun) = LIBANDROID_ASHAREDMEMORY_GETSIZE {
return fun(fd);
}
libc::ioctl(fd, ASHMEM_GET_SIZE) as libc::size_t
}
/// See [ASharedMemory_setProt NDK documentation](https://developer.android.com/ndk/reference/group/memory#asharedmemory_setprot)
///
/// # Safety
///
/// Directly calls C or kernel APIs.
#[allow(non_snake_case)]
pub unsafe fn ASharedMemory_setProt(fd: libc::c_int, prot: libc::c_int) -> libc::c_int {
const ASHMEM_SET_PROT_MASK: libc::c_int =
iow!(__ASHMEMIOC, 5, std::mem::size_of::<libc::c_ulong>()) as _;
maybe_init();
if let Some(fun) = LIBANDROID_ASHAREDMEMORY_SETPROT {
return fun(fd, prot);
}
let r = libc::ioctl(fd, ASHMEM_SET_PROT_MASK, prot);
if r != 0 {
return -1;
}
r
}
#[cfg(test)]
mod tests {
#[test]
fn basic() {
unsafe {
let name = std::ffi::CString::new("/test-ashmem").unwrap();
let fd = super::ASharedMemory_create(name.as_ptr(), 128);
assert!(fd >= 0);
assert_eq!(super::ASharedMemory_getSize(fd), 128);
assert_eq!(super::ASharedMemory_setProt(fd, 0), 0);
libc::close(fd);
}
}
#[test]
fn anonymous() {
unsafe {
let fd = super::ASharedMemory_create(std::ptr::null(), 128);
assert!(fd >= 0);
libc::close(fd);
}
}
}

Просмотреть файл

@ -1 +1 @@
{"files":{"Cargo.toml":"67c604fd4e26eca79328eff5c235e6df79b3e4bdcd59609cf15ae6ffa7221b8b","cbindgen.toml":"bd89c5a9f52395b1c703ff04d1c0019dc3c92b691d571ae503c4b85753a44a39","src/context.rs":"89e2929aa2ba4bddcec6dd4a4511f528c681b7717adbaa7b7df4378c8e3c4d1c","src/lib.rs":"7016a5de8770d3269e62dd7ad096fdd00cf821febf916bbc3163225cf6a53002","src/send_recv.rs":"450bdb1d8a346634c0237f2081b424d11e2c19ad81670009303f8a03b3bfb196","src/stream.rs":"3b4937214a40fd41f817596af0c315100d8922a642fe99b33ada94c3e15a8fe5"},"package":null}
{"files":{"Cargo.toml":"4020e8c4119327dac49b47391c902eb69bb927c9e7d05f5882ad9e84cff4ec5e","cbindgen.toml":"bd89c5a9f52395b1c703ff04d1c0019dc3c92b691d571ae503c4b85753a44a39","src/context.rs":"89e2929aa2ba4bddcec6dd4a4511f528c681b7717adbaa7b7df4378c8e3c4d1c","src/lib.rs":"7016a5de8770d3269e62dd7ad096fdd00cf821febf916bbc3163225cf6a53002","src/send_recv.rs":"450bdb1d8a346634c0237f2081b424d11e2c19ad81670009303f8a03b3bfb196","src/stream.rs":"f493ddc3ae950fc18fe42249b13194bc0a80bd0ce88bc8c7d3295f9ee10a932e"},"package":null}

1
third_party/rust/audioipc-client/Cargo.toml поставляемый
Просмотреть файл

@ -17,4 +17,3 @@ futures = { version="0.1.18", default-features=false, features=["use_std"] }
futures-cpupool = { version="0.1.8", default-features=false }
log = "0.4"
tokio = "0.1"
fallible_collections = "0.4"

Просмотреть файл

@ -13,7 +13,6 @@ use audioipc::{
messages::{self, CallbackReq, CallbackResp, ClientMessage, ServerMessage},
};
use cubeb_backend::{ffi, DeviceRef, Error, Result, Stream, StreamOps};
use fallible_collections::FallibleVec;
use futures::Future;
use futures_cpupool::{CpuFuture, CpuPool};
use std::ffi::{CStr, CString};
@ -212,8 +211,9 @@ impl rpc::Server for CallbackServer {
};
self.duplex_input = if let StreamDirection::Duplex = self.dir {
match Vec::try_with_capacity(shm_area_size) {
Ok(duplex_input) => Some(duplex_input),
let mut duplex_input = Vec::new();
match duplex_input.try_reserve_exact(shm_area_size) {
Ok(()) => Some(duplex_input),
Err(e) => {
warn!(
"duplex_input allocation failed (size={}, err={:?})",

Просмотреть файл

@ -1 +1 @@
{"files":{"Cargo.toml":"0b9a3ce0f238c34e8d12eb867010ed5948f138d9a9b8a1be6812ac433335eea5","build.rs":"3f061cf9a989f63a71c693a543d26f7003e8b643c39c23ea555110252a2c39d2","src/async_msg.rs":"27c5c8215bcbe1364947065ac78198bcd4be7fbae0f5e49ea776cb454c5a6d2c","src/cmsg.rs":"97d8fe99ef94f75db9ed26cb4cf6faf9fbbc913cfa4152a8774ff4e76aead620","src/cmsghdr.c":"d7344b3dc15cdce410c68669b848bb81f7fe36362cd3699668cb613fa05180f8","src/codec.rs":"2e0a05968e07617adc6be0cbf04962c952c621e118f0db308eeeed5ccea4dfce","src/core.rs":"721de353d3b0b5126bf5b25cfb1f99244702309ce9f9f24cc2ce3c5858228794","src/errors.rs":"67a4a994d0724397657581cde153bdfc05ce86e7efc467f23fafc8f64df80fa4","src/framing.rs":"45122f0bc44458d8e111466437e784f0d17035309cb5f03d45a5861082168ea1","src/lib.rs":"717151468773630600530a16d6c89ba559e321551e95e0f3d83721474ec82ae6","src/messages.rs":"6d59588add4dc4eb324a630980fa10acd64ad5e1feda74a9ec10b0f7d10798f1","src/messagestream_unix.rs":"786ea7d2d2993c21987d34c0617abd78dbaa57079de68ea3ebbf5611a052f60b","src/messagestream_win.rs":"f5b2a0e22f56a14af24a76a4c13a1d6b066fbea347132a5413bee0bd2b757753","src/msg.rs":"f5353e942f7818742190541e568685d6b4d6200b55bfc60e46ee3db05f802436","src/rpc/client/mod.rs":"04e80b689548e7888b34441a7224dfa8cf557b8b4164754daee95a95b76f9aee","src/rpc/client/proxy.rs":"8d9c9b38ecec4ab5ee3b6e4c2d7aea9dbb4f7cf5c25d39a5db0c76aa41008497","src/rpc/driver.rs":"dea4efc844485e98c21f766772422e3a5c9ac153ade32c0ff51287516a05690b","src/rpc/mod.rs":"3b14af0be2b4c7b30a0dab9cca353e092652a16e29002f5aeba24dca45e33d1e","src/rpc/server.rs":"7caf0b2d659783b4c5c9dd9efe4cb9a2e7d5955c0dfda3d2e79581116bb9334b","src/shm.rs":"94dee9454acfb4541b7757fd6763b8ecfe1961bb0da780caf463dc6509ba1d98","src/tokio_named_pipes.rs":"c0d74ab6330ebdec53db12f0f532b60897c37e70345c368f10165d9b31409643","src/tokio_uds_stream.rs":"3251b91e4129f174a588648ec43575b35e139b67d4b8833fe324e82e67d5c3da"},"package":null}
{"files":{"Cargo.toml":"a250ee3074a7b740ad0c3e814dbbbd4d9ac21ecf5b7581c2da1d15ebc0a432d2","build.rs":"3f061cf9a989f63a71c693a543d26f7003e8b643c39c23ea555110252a2c39d2","src/async_msg.rs":"27c5c8215bcbe1364947065ac78198bcd4be7fbae0f5e49ea776cb454c5a6d2c","src/cmsg.rs":"97d8fe99ef94f75db9ed26cb4cf6faf9fbbc913cfa4152a8774ff4e76aead620","src/cmsghdr.c":"d7344b3dc15cdce410c68669b848bb81f7fe36362cd3699668cb613fa05180f8","src/codec.rs":"2e0a05968e07617adc6be0cbf04962c952c621e118f0db308eeeed5ccea4dfce","src/core.rs":"721de353d3b0b5126bf5b25cfb1f99244702309ce9f9f24cc2ce3c5858228794","src/errors.rs":"67a4a994d0724397657581cde153bdfc05ce86e7efc467f23fafc8f64df80fa4","src/framing.rs":"45122f0bc44458d8e111466437e784f0d17035309cb5f03d45a5861082168ea1","src/lib.rs":"717151468773630600530a16d6c89ba559e321551e95e0f3d83721474ec82ae6","src/messages.rs":"45ca1c8aee63b991d0160f50f06d280527e7bc28972c28fa35f4f649836cadb0","src/messagestream_unix.rs":"786ea7d2d2993c21987d34c0617abd78dbaa57079de68ea3ebbf5611a052f60b","src/messagestream_win.rs":"f5b2a0e22f56a14af24a76a4c13a1d6b066fbea347132a5413bee0bd2b757753","src/msg.rs":"f5353e942f7818742190541e568685d6b4d6200b55bfc60e46ee3db05f802436","src/rpc/client/mod.rs":"04e80b689548e7888b34441a7224dfa8cf557b8b4164754daee95a95b76f9aee","src/rpc/client/proxy.rs":"8d9c9b38ecec4ab5ee3b6e4c2d7aea9dbb4f7cf5c25d39a5db0c76aa41008497","src/rpc/driver.rs":"dea4efc844485e98c21f766772422e3a5c9ac153ade32c0ff51287516a05690b","src/rpc/mod.rs":"3b14af0be2b4c7b30a0dab9cca353e092652a16e29002f5aeba24dca45e33d1e","src/rpc/server.rs":"7caf0b2d659783b4c5c9dd9efe4cb9a2e7d5955c0dfda3d2e79581116bb9334b","src/shm.rs":"94dee9454acfb4541b7757fd6763b8ecfe1961bb0da780caf463dc6509ba1d98","src/tokio_named_pipes.rs":"c0d74ab6330ebdec53db12f0f532b60897c37e70345c368f10165d9b31409643","src/tokio_uds_stream.rs":"3251b91e4129f174a588648ec43575b35e139b67d4b8833fe324e82e67d5c3da"},"package":null}

2
third_party/rust/audioipc/Cargo.toml поставляемый
Просмотреть файл

@ -36,7 +36,7 @@ mio-named-pipes = { git = "https://github.com/kinetiknz/mio-named-pipes", rev =
winapi = { version = "0.3.6", features = ["combaseapi", "memoryapi", "objbase"] }
[target.'cfg(target_os = "android")'.dependencies]
ashmem = { git = "https://github.com/kinetiknz/ashmem-rs", rev = "e47f470a54193532d60057ec54f864e06aeaff36" }
ashmem = "0.1"
[dependencies.error-chain]
version = "0.11.0"

2
third_party/rust/audioipc/src/messages.rs поставляемый
Просмотреть файл

@ -312,6 +312,8 @@ pub enum SerializableHandle {
Empty,
}
// PlatformHandle is non-Send and containers a pointer (HANDLE) on Windows.
#[allow(clippy::non_send_fields_in_send_ty)]
unsafe impl Send for SerializableHandle {}
impl SerializableHandle {

Просмотреть файл

@ -75,8 +75,8 @@ webext_storage_bridge = { path = "../../../components/extensions/storage/webext_
# https://github.com/mozilla/audioipc-2/commits/master
[target.'cfg(not(target_os = "macos"))'.dependencies]
audioipc-client = { git = "https://github.com/mozilla/audioipc-2", rev = "470320364f59672c0e1ee60240f2cd15f0e5b52f", optional = true }
audioipc-server = { git = "https://github.com/mozilla/audioipc-2", rev = "470320364f59672c0e1ee60240f2cd15f0e5b52f", optional = true }
audioipc-client = { git = "https://github.com/mozilla/audioipc-2", rev = "776ef93a9fdb20ac1ef6b7907bdd0493480388ee", optional = true }
audioipc-server = { git = "https://github.com/mozilla/audioipc-2", rev = "776ef93a9fdb20ac1ef6b7907bdd0493480388ee", optional = true }
# https://github.com/kinetiknz/audioipc-2/commits/macos
[target.'cfg(target_os = "macos")'.dependencies]