Bug 1689517 - mach vendor rust. r=cubeb-reviewers,padenot

Differential Revision: https://phabricator.services.mozilla.com/D105446
This commit is contained in:
Matthew Gregan 2021-02-17 20:06:44 +00:00
parent 5a3728c565
commit c7ff9a211c
47 changed files with 3061 additions and 273 deletions

View File

@ -32,6 +32,16 @@ git = "https://github.com/mozilla/mp4parse-rust"
replace-with = "vendored-sources"
rev = "3011a2b923c8b0f1b392bcdd008cd8b95ffd846b"
[source."https://github.com/mozilla/cubeb-pulse-rs"]
git = "https://github.com/mozilla/cubeb-pulse-rs"
replace-with = "vendored-sources"
rev = "c87b50aebfa088c1ad30c74819d4e9829f88b2e3"
[source."https://github.com/mozilla/cubeb-coreaudio-rs"]
git = "https://github.com/mozilla/cubeb-coreaudio-rs"
replace-with = "vendored-sources"
rev = "3d071d733d13bde0af033e7973e53938b2ab53e6"
[source."https://github.com/mozilla/application-services"]
git = "https://github.com/mozilla/application-services"
replace-with = "vendored-sources"
@ -97,11 +107,6 @@ git = "https://github.com/gfx-rs/gfx"
replace-with = "vendored-sources"
rev = "1d14789011cb892f4c1a205d3f8a87d479c2e354"
[source."https://github.com/djg/cubeb-pulse-rs"]
git = "https://github.com/djg/cubeb-pulse-rs"
replace-with = "vendored-sources"
rev = "bf31534d08b2c16fb5e4c5834944ae3271efbd63"
[source."https://github.com/badboy/failure"]
git = "https://github.com/badboy/failure"
replace-with = "vendored-sources"
@ -117,11 +122,6 @@ git = "https://github.com/PLSysSec/lucet_sandbox_compiler"
replace-with = "vendored-sources"
rev = "cd07861d1c92147b35b538e6f94fde7d1986f9ad"
[source."https://github.com/ChunMinChang/cubeb-coreaudio-rs"]
git = "https://github.com/ChunMinChang/cubeb-coreaudio-rs"
replace-with = "vendored-sources"
rev = "1e1222d6213e28eabd7f4302d00765ae1153a31e"
[source.crates-io]
replace-with = "vendored-sources"

26
Cargo.lock generated
View File

@ -743,7 +743,7 @@ dependencies = [
[[package]]
name = "coreaudio-sys-utils"
version = "0.1.0"
source = "git+https://github.com/ChunMinChang/cubeb-coreaudio-rs?rev=1e1222d6213e28eabd7f4302d00765ae1153a31e#1e1222d6213e28eabd7f4302d00765ae1153a31e"
source = "git+https://github.com/mozilla/cubeb-coreaudio-rs?rev=3d071d733d13bde0af033e7973e53938b2ab53e6#3d071d733d13bde0af033e7973e53938b2ab53e6"
dependencies = [
"core-foundation-sys",
"coreaudio-sys",
@ -990,27 +990,27 @@ dependencies = [
[[package]]
name = "cubeb"
version = "0.8.0"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "289952682b57343f3d852161d60f2a34a07c5fc39c113f155ab8aa3f471c917b"
checksum = "33c84c136ac07ad218df6ca1b3ca0f0a1f7358ce059ea13a2c5527d4311c36c0"
dependencies = [
"cubeb-core",
]
[[package]]
name = "cubeb-backend"
version = "0.8.0"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2052099fa6e07b444a43aa167874fb0350ed9be840f399e639f9e50cf37ec05c"
checksum = "e3b874bbad81519f5a7e3fe6fdd29821d08c3ffb445f818a97f3ff11e1d6ec48"
dependencies = [
"cubeb-core",
]
[[package]]
name = "cubeb-core"
version = "0.8.0"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6197f805b94171473c3fa3059f688f00a2df1ee76259f9ea641401b58917df3"
checksum = "40aa77fed9bd627aaf11654c4d2753038d43d0f10abb6651db6e9330f81270e9"
dependencies = [
"bitflags",
"cubeb-sys",
@ -1019,7 +1019,7 @@ dependencies = [
[[package]]
name = "cubeb-coreaudio"
version = "0.1.0"
source = "git+https://github.com/ChunMinChang/cubeb-coreaudio-rs?rev=1e1222d6213e28eabd7f4302d00765ae1153a31e#1e1222d6213e28eabd7f4302d00765ae1153a31e"
source = "git+https://github.com/mozilla/cubeb-coreaudio-rs?rev=3d071d733d13bde0af033e7973e53938b2ab53e6#3d071d733d13bde0af033e7973e53938b2ab53e6"
dependencies = [
"atomic",
"audio-mixer",
@ -1037,7 +1037,7 @@ dependencies = [
[[package]]
name = "cubeb-pulse"
version = "0.3.0"
source = "git+https://github.com/djg/cubeb-pulse-rs?rev=bf31534d08b2c16fb5e4c5834944ae3271efbd63#bf31534d08b2c16fb5e4c5834944ae3271efbd63"
source = "git+https://github.com/mozilla/cubeb-pulse-rs?rev=c87b50aebfa088c1ad30c74819d4e9829f88b2e3#c87b50aebfa088c1ad30c74819d4e9829f88b2e3"
dependencies = [
"cubeb-backend",
"pulse",
@ -1048,9 +1048,9 @@ dependencies = [
[[package]]
name = "cubeb-sys"
version = "0.8.0"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b0f751f2aee031f589bcfd812b99cfbf923aa1612d34c9757608cf540f74ad9"
checksum = "eaedd862c6194a52c45efc3b5fd43e42e11fe3cd915520add4d1a5d03a818796"
dependencies = [
"cmake",
"pkg-config",
@ -4078,7 +4078,7 @@ dependencies = [
[[package]]
name = "pulse"
version = "0.3.0"
source = "git+https://github.com/djg/cubeb-pulse-rs?rev=bf31534d08b2c16fb5e4c5834944ae3271efbd63#bf31534d08b2c16fb5e4c5834944ae3271efbd63"
source = "git+https://github.com/mozilla/cubeb-pulse-rs?rev=c87b50aebfa088c1ad30c74819d4e9829f88b2e3#c87b50aebfa088c1ad30c74819d4e9829f88b2e3"
dependencies = [
"bitflags",
"pulse-ffi",
@ -4087,7 +4087,7 @@ dependencies = [
[[package]]
name = "pulse-ffi"
version = "0.1.0"
source = "git+https://github.com/djg/cubeb-pulse-rs?rev=bf31534d08b2c16fb5e4c5834944ae3271efbd63#bf31534d08b2c16fb5e4c5834944ae3271efbd63"
source = "git+https://github.com/mozilla/cubeb-pulse-rs?rev=c87b50aebfa088c1ad30c74819d4e9829f88b2e3#c87b50aebfa088c1ad30c74819d4e9829f88b2e3"
dependencies = [
"libc",
]

View File

@ -1 +1 @@
{"files":{"Cargo.toml":"47ed9c84aeefa661dfc3f37490159ffad25c46a0f5e9368abb79669ea199d455","LICENSE":"8c044baa5d883274736eeece0b955249076c2697b826e576fce59496235b2cf5","src/capi.rs":"a24fb59538c2adc258f4fa7a843d2bb72dcb21fcb0e2e4c6f2c5094fbf2c6dd6","src/lib.rs":"94b80747ae1037423a2281f2572fc6d15cd7702417974ae3730adccd71c7a300","src/log.rs":"cf8e3a778f6b72d4cd80c1c56963355aa2224f19fd4fdf07d03f6fb366000899","src/ops.rs":"5ab7ed9c11e9713ea0954fc235983b98b806a9e756ddeb693bb65a67a15118ed","src/traits.rs":"0de6e31e4765d2a8db2451b1dfe7ff7c0ec60b4ccc9b042bf0aede449ea63e74","tests/test_capi.rs":"da296f48eee39564ace7c48a4ee3145b9d130eb206b91c793276451813abd759"},"package":"2052099fa6e07b444a43aa167874fb0350ed9be840f399e639f9e50cf37ec05c"}
{"files":{"Cargo.toml":"a98b7a5abd5c2e7948da6aa53d6c9cc51e1bca422626b1b80c4f1c209c809d1f","LICENSE":"8c044baa5d883274736eeece0b955249076c2697b826e576fce59496235b2cf5","src/capi.rs":"8ed3a1fbabeb4848fd38a41a2ffbf350b09712c7ad51d929303e82ed7fb79f51","src/lib.rs":"94b80747ae1037423a2281f2572fc6d15cd7702417974ae3730adccd71c7a300","src/log.rs":"cf8e3a778f6b72d4cd80c1c56963355aa2224f19fd4fdf07d03f6fb366000899","src/ops.rs":"514b299ec9e7b7dfdc2c43a265a0aa6ec4f2df1555dfb9e60346c6fba468a5f2","src/traits.rs":"f033d84bf14c6fb19ead4bc2b5cf1061281abf20a55b7c6bddaa9be9da49fb89","tests/test_capi.rs":"3cd9ee5aad6c786c4caf888014dda5aa89e4f4070d663c0777479d088221063c"},"package":"e3b874bbad81519f5a7e3fe6fdd29821d08c3ffb445f818a97f3ff11e1d6ec48"}

View File

@ -12,7 +12,7 @@
[package]
name = "cubeb-backend"
version = "0.8.0"
version = "0.9.0"
authors = ["Dan Glastonbury <dglastonbury@mozilla.com>"]
description = "Bindings to libcubeb internals to facilitate implementing cubeb backends in rust.\n"
homepage = "https://github.com/djg/cubeb-rs"
@ -21,7 +21,7 @@ categories = ["api-bindings"]
license = "ISC"
repository = "https://github.com/djg/cubeb-rs"
[dependencies.cubeb-core]
version = "0.8.0"
version = "0.9.0"
[features]
gecko-in-tree = ["cubeb-core/gecko-in-tree"]

View File

@ -45,8 +45,6 @@ macro_rules! capi_new(
stream_destroy: Some($crate::capi::capi_stream_destroy::<$stm>),
stream_start: Some($crate::capi::capi_stream_start::<$stm>),
stream_stop: Some($crate::capi::capi_stream_stop::<$stm>),
stream_reset_default_device:
Some($crate::capi::capi_stream_reset_default_device::<$stm>),
stream_get_position: Some($crate::capi::capi_stream_get_position::<$stm>),
stream_get_latency: Some($crate::capi::capi_stream_get_latency::<$stm>),
stream_get_input_latency: Some($crate::capi::capi_stream_get_input_latency::<$stm>),
@ -189,15 +187,6 @@ pub unsafe extern "C" fn capi_stream_stop<STM: StreamOps>(s: *mut ffi::cubeb_str
ffi::CUBEB_OK
}
pub unsafe extern "C" fn capi_stream_reset_default_device<STM: StreamOps>(
s: *mut ffi::cubeb_stream,
) -> c_int {
let stm = &mut *(s as *mut STM);
_try!(stm.reset_default_device());
ffi::CUBEB_OK
}
pub unsafe extern "C" fn capi_stream_get_position<STM: StreamOps>(
s: *mut ffi::cubeb_stream,
position: *mut u64,

View File

@ -57,8 +57,6 @@ pub struct Ops {
pub stream_destroy: Option<unsafe extern "C" fn(stream: *mut ffi::cubeb_stream)>,
pub stream_start: Option<unsafe extern "C" fn(stream: *mut ffi::cubeb_stream) -> c_int>,
pub stream_stop: Option<unsafe extern "C" fn(stream: *mut ffi::cubeb_stream) -> c_int>,
pub stream_reset_default_device:
Option<unsafe extern "C" fn(stream: *mut ffi::cubeb_stream) -> c_int>,
pub stream_get_position:
Option<unsafe extern "C" fn(stream: *mut ffi::cubeb_stream, position: *mut u64) -> c_int>,
pub stream_get_latency:

View File

@ -45,7 +45,6 @@ pub trait ContextOps {
pub trait StreamOps {
fn start(&mut self) -> Result<()>;
fn stop(&mut self) -> Result<()>;
fn reset_default_device(&mut self) -> Result<()>;
fn position(&mut self) -> Result<u64>;
fn latency(&mut self) -> Result<u32>;
fn input_latency(&mut self) -> Result<u32>;

View File

@ -91,9 +91,6 @@ impl StreamOps for TestStream {
fn stop(&mut self) -> Result<()> {
Ok(())
}
fn reset_default_device(&mut self) -> Result<()> {
Ok(())
}
fn position(&mut self) -> Result<u64> {
Ok(0u64)
}

View File

@ -1 +1 @@
{"files":{"Cargo.toml":"f847e823e011300f8d020e13dd07c1ea6eecb33258495f55e74564362b876f1f","LICENSE":"8c044baa5d883274736eeece0b955249076c2697b826e576fce59496235b2cf5","src/builders.rs":"ca97e3a3d1f3fc451c17851c8538964ec67f3964dfe29e902d904ee7445becca","src/channel.rs":"971488fca24a11d49046f8fe9c396765560c070013e5d022afcbe27cfd51d941","src/context.rs":"09625b75070ec88d566a907ab2e574e2d85df4c6df295f798b3372df2cdc8f7a","src/device.rs":"c526d8f992c8ad6d137b0bda803c5182247c9c32797a6f86e0d86d4f6361eb4c","src/device_collection.rs":"f6d0c1628cc34b524f86b84a1e1c79971c3f64ebc4ac64eeb10a1330bbe8c238","src/error.rs":"60454b30bd496dffa94ed9c1bee5a39f29219f2411b76cff6a4f3074f3154701","src/ffi_types.rs":"d815d7a80895b5e86907e708dc0219fca4ac4668cde114afee434e7d702a145d","src/format.rs":"5513c537a72af1c222ee7c30b26d4de9d368a69772688b95d88b1a99f6892d5c","src/lib.rs":"6010a5e20b836b8e5c9fba382fde819e6f3c18c0ec2016e6e7e118eabedbcd51","src/log.rs":"c46bae3472043fd076df3229c3421d948a87fae8495c1524b41ab2d8608f612a","src/stream.rs":"06aae5ff1228f86c28c2ba1a306d9f72f886875a036ae917caf0381cdbb7d771","src/try_call.rs":"99c59a13db90326613d8cf91909e8a7eaef80646984d10927cbc7cde2cb4b066","src/util.rs":"308cfbaacd615ff600e74415c52daeef007fff34a4a0648a73c0042f6067f84f"},"package":"c6197f805b94171473c3fa3059f688f00a2df1ee76259f9ea641401b58917df3"}
{"files":{"Cargo.toml":"97e07c37ecc492b6f12e73fba925d1868416cb2b73154b701409f278f698fca7","LICENSE":"8c044baa5d883274736eeece0b955249076c2697b826e576fce59496235b2cf5","src/builders.rs":"ca97e3a3d1f3fc451c17851c8538964ec67f3964dfe29e902d904ee7445becca","src/channel.rs":"971488fca24a11d49046f8fe9c396765560c070013e5d022afcbe27cfd51d941","src/context.rs":"09625b75070ec88d566a907ab2e574e2d85df4c6df295f798b3372df2cdc8f7a","src/device.rs":"c526d8f992c8ad6d137b0bda803c5182247c9c32797a6f86e0d86d4f6361eb4c","src/device_collection.rs":"f6d0c1628cc34b524f86b84a1e1c79971c3f64ebc4ac64eeb10a1330bbe8c238","src/error.rs":"60454b30bd496dffa94ed9c1bee5a39f29219f2411b76cff6a4f3074f3154701","src/ffi_types.rs":"d815d7a80895b5e86907e708dc0219fca4ac4668cde114afee434e7d702a145d","src/format.rs":"5513c537a72af1c222ee7c30b26d4de9d368a69772688b95d88b1a99f6892d5c","src/lib.rs":"6010a5e20b836b8e5c9fba382fde819e6f3c18c0ec2016e6e7e118eabedbcd51","src/log.rs":"c46bae3472043fd076df3229c3421d948a87fae8495c1524b41ab2d8608f612a","src/stream.rs":"0d6278e0e5ba721ed2295d336678da0683c297f87a3194e11511ffe88b621be7","src/try_call.rs":"99c59a13db90326613d8cf91909e8a7eaef80646984d10927cbc7cde2cb4b066","src/util.rs":"308cfbaacd615ff600e74415c52daeef007fff34a4a0648a73c0042f6067f84f"},"package":"40aa77fed9bd627aaf11654c4d2753038d43d0f10abb6651db6e9330f81270e9"}

View File

@ -12,7 +12,7 @@
[package]
name = "cubeb-core"
version = "0.8.0"
version = "0.9.0"
authors = ["Dan Glastonbury <dglastonbury@mozilla.com>"]
description = "Common types and definitions for cubeb rust and C bindings. Not intended for direct use.\n"
homepage = "https://github.com/djg/cubeb-rs"
@ -24,7 +24,7 @@ repository = "https://github.com/djg/cubeb-rs"
version = "1.2.0"
[dependencies.cubeb-sys]
version = "0.8.0"
version = "0.9.0"
[features]
gecko-in-tree = ["cubeb-sys/gecko-in-tree"]

View File

@ -119,11 +119,6 @@ impl StreamRef {
unsafe { call!(ffi::cubeb_stream_stop(self.as_ptr())) }
}
/// Reset stream to the default device.
pub fn reset_default_device(&self) -> Result<()> {
unsafe { call!(ffi::cubeb_stream_reset_default_device(self.as_ptr())) }
}
/// Get the current stream playback position.
pub fn position(&self) -> Result<u64> {
let mut position = 0u64;

View File

@ -1 +1 @@
{"files":{".editorconfig":"4e53b182bcc78b83d7e1b5c03efa14d22d4955c4ed2514d1ba4e99c1eb1a50ba",".githooks/pre-push":"8b8b26544cd56f54c0c33812551f786bb25cb08c86dbfeb6bf3daad881c826a1",".travis.yml":"dc07bac53f70f16c9bdf52264bdc58500ae6018c1b4c567bc7642f6b4ca3cc35","Cargo.toml":"9f97e1566873abf7f452f954665cf238078db5ab2f4a4254e10a6964574f3378","LICENSE":"6e6f56aff5bbf3cbc60747e152fb1a719bd0716aaf6d711c554f57d92e96297c","README.md":"22c786b3e8706d075031b508780896e1fa29a932628c731679b3865ef7e41a19","build-audiounit-rust-in-cubeb.sh":"2b724ade9c0b17e0ef4a87d38ef6eb0e5f613033fc1dbbe5dc0f71251278787f","install_git_hook.sh":"d38c8e51e636f6b90b489621ac34ccd1d1b1f40dccce3d178ed1da1c5068f16d","install_rustfmt_clippy.sh":"4ae90d8dcb9757cb3ae4ae142ef80e5377c0dde61c63f4a3c32418646e80ca7b","run_device_tests.sh":"4b7d65eb638c1a278ffc8ecb6d30d47b3b8405392e976cae38c6f744e2bed532","run_sanitizers.sh":"2f0934ba01cbcd74485f19d50147f6b604cf9730bbd3a3d3f3d958e40d0f799f","run_tests.sh":"916a7ae4a406d2274417d6eca939a878db5adcb6144e5680d9d148bf90178f1c","src/backend/aggregate_device.rs":"e153a39c4c4884951e3fe70566b891f1bf96fe0d3d7567b33b4027043c54148c","src/backend/auto_release.rs":"050fdcee74cf46b9a8a85a877e166d72a853d33220f59cf734cbb6ea09daa441","src/backend/buffer_manager.rs":"9c10a261792e32e75833b5f976b18547c338ca6beb2330eeab1ad203cc8c32bf","src/backend/device_property.rs":"d43642ea6e5f40e29c2a59ec7d81b42c154134685e417585045785359aa31686","src/backend/mixer.rs":"949c34927ba72b3365bc733a63b2f7950aef707ee08363f97242a4de6b7d4818","src/backend/mod.rs":"515aa69a723c8f073b09dcac4bd30da3df4ae178fcb4f0ed854bc3ce164d7e74","src/backend/resampler.rs":"fd1281d28a4db1659d2f75e43b8457651745e1b6eb5a53a77f04d752135f6dc7","src/backend/tests/aggregate_device.rs":"107f5c637844cd5ae43d2b42cec4ef3369bb702751586078c0a9d50f039161cd","src/backend/tests/api.rs":"9ce44a867519d7b7a2b43c7f833327c35be38af7ba6fcc3d277ed1d7d8e7c8c2","src/backend/tests/backlog.rs":"3b189a7e036543c467cc242af0ed3332721179ee2b1c8847a6db563546f1ac52","src/backend/tests/device_change.rs":"8261f561f69dabd374ac47d69aa484812b65070a9e9581dfb2605e8404eaad6d","src/backend/tests/device_property.rs":"373f76d3bee83b263db3f02be3b94b408bdf852d84e4b5153273fda34b11a374","src/backend/tests/interfaces.rs":"14943e84a79976a7ef52882edeb9330350705d5190db6647f98b4ffa851a8396","src/backend/tests/manual.rs":"87210af9527feece99ad2b7b85651fbc8f02ec306ba8082da0c0705070e882af","src/backend/tests/mod.rs":"8dba770023d7f9c4228f0e11915347f0e07da5fd818e3ee4478c4b197af9aa2a","src/backend/tests/parallel.rs":"f9e1883660d6146b6e5075806561f5f689810e25c5e7764dfd28c9b939821a49","src/backend/tests/tone.rs":"fadf78543950249cccd64d6d42ca41cd58c68d4a4c2dc656d474da6a44eb550e","src/backend/tests/utils.rs":"1bb99ef71d3c18545bca49767e7b6bfffbe11896246994f41be7ed372772fd48","src/backend/utils.rs":"6c3ffbcd602e6cc9f56deb9ecb07b2eef2e6f074ef924178e466f380aae5c595","src/capi.rs":"21b66b70545bf04ec719928004d1d9adb45b24ced51288f5b2993d79aaf78f5f","src/lib.rs":"5e586d45cd6b3722f0a6736d9252593299269817a153eef1930a5fb9bfbb56f5","todo.md":"3a537412b5f27cbaad0b37c35d0f460ef6084030804a2910a3c67d37908a44fc"},"package":null}
{"files":{".editorconfig":"4e53b182bcc78b83d7e1b5c03efa14d22d4955c4ed2514d1ba4e99c1eb1a50ba",".githooks/pre-push":"8b8b26544cd56f54c0c33812551f786bb25cb08c86dbfeb6bf3daad881c826a1",".travis.yml":"dc07bac53f70f16c9bdf52264bdc58500ae6018c1b4c567bc7642f6b4ca3cc35","Cargo.toml":"6170d7b1c191efee92f0b43c024633cd12addfddaa57babdda23af846e1cb06c","LICENSE":"6e6f56aff5bbf3cbc60747e152fb1a719bd0716aaf6d711c554f57d92e96297c","README.md":"22c786b3e8706d075031b508780896e1fa29a932628c731679b3865ef7e41a19","build-audiounit-rust-in-cubeb.sh":"2b724ade9c0b17e0ef4a87d38ef6eb0e5f613033fc1dbbe5dc0f71251278787f","install_git_hook.sh":"d38c8e51e636f6b90b489621ac34ccd1d1b1f40dccce3d178ed1da1c5068f16d","install_rustfmt_clippy.sh":"4ae90d8dcb9757cb3ae4ae142ef80e5377c0dde61c63f4a3c32418646e80ca7b","run_device_tests.sh":"4b7d65eb638c1a278ffc8ecb6d30d47b3b8405392e976cae38c6f744e2bed532","run_sanitizers.sh":"2f0934ba01cbcd74485f19d50147f6b604cf9730bbd3a3d3f3d958e40d0f799f","run_tests.sh":"916a7ae4a406d2274417d6eca939a878db5adcb6144e5680d9d148bf90178f1c","src/backend/aggregate_device.rs":"e153a39c4c4884951e3fe70566b891f1bf96fe0d3d7567b33b4027043c54148c","src/backend/auto_release.rs":"050fdcee74cf46b9a8a85a877e166d72a853d33220f59cf734cbb6ea09daa441","src/backend/buffer_manager.rs":"9c10a261792e32e75833b5f976b18547c338ca6beb2330eeab1ad203cc8c32bf","src/backend/device_property.rs":"d43642ea6e5f40e29c2a59ec7d81b42c154134685e417585045785359aa31686","src/backend/mixer.rs":"949c34927ba72b3365bc733a63b2f7950aef707ee08363f97242a4de6b7d4818","src/backend/mod.rs":"2796a29ce3ab38e33d0aa59cb262541e57878f3bfa688aeb1e99e4211ba4eb84","src/backend/resampler.rs":"fd1281d28a4db1659d2f75e43b8457651745e1b6eb5a53a77f04d752135f6dc7","src/backend/tests/aggregate_device.rs":"107f5c637844cd5ae43d2b42cec4ef3369bb702751586078c0a9d50f039161cd","src/backend/tests/api.rs":"9ce44a867519d7b7a2b43c7f833327c35be38af7ba6fcc3d277ed1d7d8e7c8c2","src/backend/tests/backlog.rs":"3b189a7e036543c467cc242af0ed3332721179ee2b1c8847a6db563546f1ac52","src/backend/tests/device_change.rs":"8261f561f69dabd374ac47d69aa484812b65070a9e9581dfb2605e8404eaad6d","src/backend/tests/device_property.rs":"373f76d3bee83b263db3f02be3b94b408bdf852d84e4b5153273fda34b11a374","src/backend/tests/interfaces.rs":"b48d646b6ea06ca1bf7ce4b0ada59a164bc094e40b0cd66bb63b269f9032b022","src/backend/tests/manual.rs":"87210af9527feece99ad2b7b85651fbc8f02ec306ba8082da0c0705070e882af","src/backend/tests/mod.rs":"8dba770023d7f9c4228f0e11915347f0e07da5fd818e3ee4478c4b197af9aa2a","src/backend/tests/parallel.rs":"f9e1883660d6146b6e5075806561f5f689810e25c5e7764dfd28c9b939821a49","src/backend/tests/tone.rs":"fadf78543950249cccd64d6d42ca41cd58c68d4a4c2dc656d474da6a44eb550e","src/backend/tests/utils.rs":"1bb99ef71d3c18545bca49767e7b6bfffbe11896246994f41be7ed372772fd48","src/backend/utils.rs":"6c3ffbcd602e6cc9f56deb9ecb07b2eef2e6f074ef924178e466f380aae5c595","src/capi.rs":"21b66b70545bf04ec719928004d1d9adb45b24ced51288f5b2993d79aaf78f5f","src/lib.rs":"5e586d45cd6b3722f0a6736d9252593299269817a153eef1930a5fb9bfbb56f5","todo.md":"3a537412b5f27cbaad0b37c35d0f460ef6084030804a2910a3c67d37908a44fc"},"package":null}

View File

@ -11,7 +11,7 @@ crate-type = ["staticlib", "rlib"]
atomic = "0.4"
bitflags = "1.0"
coreaudio-sys-utils = { path = "coreaudio-sys-utils" }
cubeb-backend = "0.8"
cubeb-backend = "0.9"
float-cmp = "0.6"
libc = "0.2"
lazy_static = "1.2"

View File

@ -3490,9 +3490,6 @@ impl<'ctx> StreamOps for AudioUnitStream<'ctx> {
);
Ok(())
}
fn reset_default_device(&mut self) -> Result<()> {
Err(Error::not_supported())
}
fn position(&mut self) -> Result<u64> {
let OutputCallbackTimingData {
frames_queued,

View File

@ -531,16 +531,6 @@ fn test_ops_stream_stop() {
});
}
#[test]
fn test_ops_stream_reset_default_device() {
test_default_output_stream_operation("stream: reset default device", |stream| {
assert_eq!(
unsafe { OPS.stream_reset_default_device.unwrap()(stream) },
ffi::CUBEB_ERROR_NOT_SUPPORTED
);
});
}
#[test]
fn test_ops_stream_position() {
test_default_output_stream_operation("stream: position", |stream| {

View File

@ -1 +1 @@
{"files":{".editorconfig":"bf047bd1da10cabb99eea666d1e57c321eba4716dccb3e4ed0e2c5fe3ca53858",".travis.yml":"0394e2adb041175457685cde5ee05ff04bdab8885fd8a62551f2ff43d9e48872","AUTHORS":"0e0ac930a68ce2f6b876126b195add177f0d3886facb9260f4d9b69f1988f0cc","Cargo.toml":"f4c3a703af8daa96b8b581ca2dd2619a076cbd0249d8add88f69b25a517cc67a","LICENSE":"44c6b5ae5ec3fe2fbc608b00e6f4896f4d2d5c7e525fcbaa3eaa3cf2f3d5a983","README.md":"e6a98ee5630b9ce1a096a2907d095454f2770e298a5b0976ab552cc53ca96cfc","src/backend/context.rs":"33d9fdf1504fe1ae43d301e288daf6eaeabeb47aa0ef86efa135c6d984425fc4","src/backend/cork_state.rs":"4a0f1afc7d9f333dac89218cc56d7d32fbffb487cd48c1c9a4e03d79cb3b5e28","src/backend/intern.rs":"374a9a3bd79fddc47739dda1dbfc5929aea5a91946794fe65fba3c8d130fbda9","src/backend/mod.rs":"06ce9250865abf0ea461f215b128470636d072a6776821efef3caf5a7b992fb9","src/backend/stream.rs":"2d4f200506ac62be2db7fd1446c937b98fe1a429d614f16af855f19f26fcd997","src/capi.rs":"b2c1be8128cadd36caa65c80950440f9d6f2aa0c24cc7bae6a9eaf6347ac454d","src/lib.rs":"7282560d84b134b09acfd8d6282600982e42fb3557f72454c535637cc26c7bf6"},"package":null}
{"files":{".editorconfig":"bf047bd1da10cabb99eea666d1e57c321eba4716dccb3e4ed0e2c5fe3ca53858",".travis.yml":"0394e2adb041175457685cde5ee05ff04bdab8885fd8a62551f2ff43d9e48872","AUTHORS":"0e0ac930a68ce2f6b876126b195add177f0d3886facb9260f4d9b69f1988f0cc","Cargo.toml":"56e90cb82ec36ead07e551a28fc2455fa658fa8308c3d73f8d856d85bfcd2122","LICENSE":"44c6b5ae5ec3fe2fbc608b00e6f4896f4d2d5c7e525fcbaa3eaa3cf2f3d5a983","README.md":"e6a98ee5630b9ce1a096a2907d095454f2770e298a5b0976ab552cc53ca96cfc","src/backend/context.rs":"33d9fdf1504fe1ae43d301e288daf6eaeabeb47aa0ef86efa135c6d984425fc4","src/backend/cork_state.rs":"4a0f1afc7d9f333dac89218cc56d7d32fbffb487cd48c1c9a4e03d79cb3b5e28","src/backend/intern.rs":"374a9a3bd79fddc47739dda1dbfc5929aea5a91946794fe65fba3c8d130fbda9","src/backend/mod.rs":"06ce9250865abf0ea461f215b128470636d072a6776821efef3caf5a7b992fb9","src/backend/stream.rs":"b8700fffb4d1537bc2fd3f0e26e7bbb16bc6e7cc7a803723e06704610ca1f6f5","src/capi.rs":"b2c1be8128cadd36caa65c80950440f9d6f2aa0c24cc7bae6a9eaf6347ac454d","src/lib.rs":"7282560d84b134b09acfd8d6282600982e42fb3557f72454c535637cc26c7bf6"},"package":null}

View File

@ -12,7 +12,7 @@ pulse-dlopen = ["pulse-ffi/dlopen"]
crate-type = ["staticlib", "rlib"]
[dependencies]
cubeb-backend = "0.8"
cubeb-backend = "0.9"
pulse-ffi = { path = "pulse-ffi" }
pulse = { path = "pulse-rs" }
semver = "^0.9"

View File

@ -636,10 +636,6 @@ impl<'ctx> StreamOps for PulseStream<'ctx> {
Ok(())
}
fn reset_default_device(&mut self) -> Result<()> {
Err(not_supported())
}
fn position(&mut self) -> Result<u64> {
let in_thread = self.context.mainloop.in_thread();

File diff suppressed because one or more lines are too long

View File

@ -12,7 +12,7 @@
[package]
name = "cubeb-sys"
version = "0.8.0"
version = "0.9.0"
authors = ["Dan Glastonbury <dglastonbury@mozilla.com>"]
build = "build.rs"
links = "cubeb"

View File

@ -35,7 +35,7 @@ if(BUILD_TESTS)
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/googletest/CMakeLists.txt")
message(FATAL_ERROR "Could not find googletest: run\n\tgit submodule update --init --recursive\nin base git checkout")
endif()
add_definitions(-DGTEST_HAS_TR1_TUPLE=0)
add_definitions(-DGTEST_HAS_TR1_TUPLE=0 -DGTEST_HAS_RTTI=0)
set(gtest_force_shared_crt ON CACHE BOOL "")
add_subdirectory(googletest)
endif()
@ -60,7 +60,10 @@ endif()
set(CMAKE_CXX_WARNING_LEVEL 4)
if(NOT MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -fno-exceptions -fno-rtti")
else()
string(REPLACE "/GR" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # Disable RTTI
string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # Disable Exceptions
endif()
add_library(cubeb
@ -199,6 +202,38 @@ if(USE_OPENSL)
target_link_libraries(cubeb PRIVATE OpenSLES)
endif()
check_include_files(sys/soundcard.h HAVE_SYS_SOUNDCARD_H)
if(HAVE_SYS_SOUNDCARD_H)
try_compile(USE_OSS "${PROJECT_BINARY_DIR}/compile_tests"
${PROJECT_SOURCE_DIR}/cmake/compile_tests/oss_is_v4.c)
if(USE_OSS)
target_sources(cubeb PRIVATE
src/cubeb_oss.c)
target_compile_definitions(cubeb PRIVATE USE_OSS)
target_link_libraries(cubeb PRIVATE pthread)
endif()
endif()
check_include_files(aaudio/AAudio.h USE_AAUDIO)
if(USE_AAUDIO)
target_sources(cubeb PRIVATE
src/cubeb_aaudio.cpp)
target_compile_definitions(cubeb PRIVATE USE_AAUDIO)
# set this definition to enable low latency mode. Possibly bad for battery
target_compile_definitions(cubeb PRIVATE CUBEB_AAUDIO_LOW_LATENCY)
# set this definition to enable power saving mode. Possibly resulting
# in high latency
# target_compile_definitions(cubeb PRIVATE CUBEB_AAUDIO_LOW_POWER_SAVING)
# set this mode to make the backend use an exclusive stream.
# will decrease latency.
# target_compile_definitions(cubeb PRIVATE CUBEB_AAUDIO_EXCLUSIVE_STREAM)
target_link_libraries(cubeb PRIVATE ${CMAKE_DL_LIBS})
endif()
check_include_files(android/log.h USE_AUDIOTRACK)
if(USE_AUDIOTRACK)
target_sources(cubeb PRIVATE

View File

@ -0,0 +1,10 @@
#include <sys/soundcard.h>
#if SOUND_VERSION < 0x040000
# error "OSSv4 is not available in sys/soundcard.h"
#endif
int main()
{
return 0;
}

View File

@ -230,12 +230,22 @@ typedef enum {
CUBEB_STREAM_PREF_DISABLE_DEVICE_SWITCHING = 0x02, /**< Disable switching
default device on OS
changes. */
CUBEB_STREAM_PREF_VOICE = 0x04 /**< This stream is going to transport voice data.
CUBEB_STREAM_PREF_VOICE = 0x04, /**< This stream is going to transport voice data.
Depending on the backend and platform, this can
change the audio input or output devices
selected, as well as the quality of the stream,
for example to accomodate bluetooth SCO modes on
bluetooth devices. */
CUBEB_STREAM_PREF_RAW = 0x08, /**< Windows only. Bypass all signal processing
except for always on APO, driver and hardware. */
CUBEB_STREAM_PREF_PERSIST = 0x10, /**< Request that the volume and mute settings
should persist across restarts of the stream
and/or application. May not be honored for
all backends and platforms. */
CUBEB_STREAM_PREF_JACK_NO_AUTO_CONNECT = 0x20 /**< Don't automatically try to connect
ports. Only affects the jack
backend. */
} cubeb_stream_prefs;
/** Stream format initialization parameters. */
@ -499,7 +509,9 @@ CUBEB_EXPORT void cubeb_destroy(cubeb * context);
cubeb_devid allows the stream to follow that device type's
OS default.
@param output_stream_params Parameters for the output side of the stream, or
NULL if this stream is input only.
NULL if this stream is input only. When input
and output stream parameters are supplied, their
rate has to be the same.
@param latency_frames Stream latency in frames. Valid range
is [1, 96000].
@param data_callback Will be called to preroll data before playback is
@ -540,14 +552,6 @@ CUBEB_EXPORT int cubeb_stream_start(cubeb_stream * stream);
@retval CUBEB_ERROR */
CUBEB_EXPORT int cubeb_stream_stop(cubeb_stream * stream);
/** Reset stream to the default device.
@param stream
@retval CUBEB_OK
@retval CUBEB_ERROR_INVALID_PARAMETER
@retval CUBEB_ERROR_NOT_SUPPORTED
@retval CUBEB_ERROR */
CUBEB_EXPORT int cubeb_stream_reset_default_device(cubeb_stream * stream);
/** Get the current stream playback position.
@param stream
@param position Playback position in frames.

View File

@ -60,7 +60,6 @@ struct cubeb_ops {
void (* stream_destroy)(cubeb_stream * stream);
int (* stream_start)(cubeb_stream * stream);
int (* stream_stop)(cubeb_stream * stream);
int (* stream_reset_default_device)(cubeb_stream * stream);
int (* stream_get_position)(cubeb_stream * stream, uint64_t * position);
int (* stream_get_latency)(cubeb_stream * stream, uint32_t * latency);
int (* stream_get_input_latency)(cubeb_stream * stream, uint32_t * latency);

View File

@ -60,6 +60,12 @@ int sun_init(cubeb ** context, char const * context_name);
#if defined(USE_OPENSL)
int opensl_init(cubeb ** context, char const * context_name);
#endif
#if defined(USE_OSS)
int oss_init(cubeb ** context, char const * context_name);
#endif
#if defined(USE_AAUDIO)
int aaudio_init(cubeb ** context, char const * context_name);
#endif
#if defined(USE_AUDIOTRACK)
int audiotrack_init(cubeb ** context, char const * context_name);
#endif
@ -165,6 +171,14 @@ cubeb_init(cubeb ** context, char const * context_name, char const * backend_nam
} else if (!strcmp(backend_name, "opensl")) {
#if defined(USE_OPENSL)
init_oneshot = opensl_init;
#endif
} else if (!strcmp(backend_name, "oss")) {
#if defined(USE_OSS)
init_oneshot = oss_init;
#endif
} else if (!strcmp(backend_name, "aaudio")) {
#if defined(USE_AAUDIO)
init_oneshot = aaudio_init;
#endif
} else if (!strcmp(backend_name, "audiotrack")) {
#if defined(USE_AUDIOTRACK)
@ -200,6 +214,9 @@ cubeb_init(cubeb ** context, char const * context_name, char const * backend_nam
#if defined(USE_ALSA)
alsa_init,
#endif
#if defined (USE_OSS)
oss_init,
#endif
#if defined(USE_AUDIOUNIT_RUST)
audiounit_rust_init,
#endif
@ -217,6 +234,11 @@ cubeb_init(cubeb ** context, char const * context_name, char const * backend_nam
#endif
#if defined(USE_OPENSL)
opensl_init,
#endif
// TODO: should probably be preferred over OpenSLES when available.
// Initialization will fail on old android devices.
#if defined(USE_AAUDIO)
aaudio_init,
#endif
#if defined(USE_AUDIOTRACK)
audiotrack_init,
@ -382,20 +404,6 @@ cubeb_stream_stop(cubeb_stream * stream)
return stream->context->ops->stream_stop(stream);
}
int
cubeb_stream_reset_default_device(cubeb_stream * stream)
{
if (!stream) {
return CUBEB_ERROR_INVALID_PARAMETER;
}
if (!stream->context->ops->stream_reset_default_device) {
return CUBEB_ERROR_NOT_SUPPORTED;
}
return stream->context->ops->stream_reset_default_device(stream);
}
int
cubeb_stream_get_position(cubeb_stream * stream, uint64_t * position)
{

File diff suppressed because it is too large Load Diff

View File

@ -1441,7 +1441,6 @@ static struct cubeb_ops const alsa_ops = {
.stream_destroy = alsa_stream_destroy,
.stream_start = alsa_stream_start,
.stream_stop = alsa_stream_stop,
.stream_reset_default_device = NULL,
.stream_get_position = alsa_stream_get_position,
.stream_get_latency = alsa_stream_get_latency,
.stream_get_input_latency = NULL,

View File

@ -0,0 +1,17 @@
#ifndef CUBEB_ANDROID_H
#define CUBEB_ANDROID_H
#ifdef __cplusplus
extern "C" {
#endif
// If the latency requested is above this threshold, this stream is considered
// intended for playback (vs. real-time). Tell Android it should favor saving
// power over performance or latency.
// This is around 100ms at 44100 or 48000
const uint16_t POWERSAVE_LATENCY_FRAMES_THRESHOLD = 4000;
#ifdef __cplusplus
};
#endif
#endif // CUBEB_ANDROID_H

View File

@ -430,7 +430,6 @@ static struct cubeb_ops const audiotrack_ops = {
.stream_destroy = audiotrack_stream_destroy,
.stream_start = audiotrack_stream_start,
.stream_stop = audiotrack_stream_stop,
.stream_reset_default_device = NULL,
.stream_get_position = audiotrack_stream_get_position,
.stream_get_latency = audiotrack_stream_get_latency,
.stream_get_input_latency = NULL,

View File

@ -3618,7 +3618,6 @@ cubeb_ops const audiounit_ops = {
/*.stream_destroy =*/ audiounit_stream_destroy,
/*.stream_start =*/ audiounit_stream_start,
/*.stream_stop =*/ audiounit_stream_stop,
/*.stream_reset_default_device =*/ nullptr,
/*.stream_get_position =*/ audiounit_stream_get_position,
/*.stream_get_latency =*/ audiounit_stream_get_latency,
/*.stream_get_input_latency =*/ NULL,

View File

@ -64,6 +64,12 @@ enum devstream {
DUPLEX,
};
enum cbjack_connect_ports_options {
CBJACK_CP_OPTIONS_NONE = 0x0,
CBJACK_CP_OPTIONS_SKIP_OUTPUT = 0x1,
CBJACK_CP_OPTIONS_SKIP_INPUT = 0x2,
};
static void
s16ne_to_float(float * dst, const int16_t * src, size_t n)
{
@ -129,7 +135,6 @@ static struct cubeb_ops const cbjack_ops = {
.stream_destroy = cbjack_stream_destroy,
.stream_start = cbjack_stream_start,
.stream_stop = cbjack_stream_stop,
.stream_reset_default_device = NULL,
.stream_get_position = cbjack_stream_get_position,
.stream_get_latency = cbjack_get_latency,
.stream_get_input_latency = NULL,
@ -256,7 +261,7 @@ cbjack_connect_port_in (cubeb_stream * stream, const char * const phys_out_port,
}
static int
cbjack_connect_ports (cubeb_stream * stream)
cbjack_connect_ports (cubeb_stream * stream, enum cbjack_connect_ports_options options)
{
int r = CUBEB_ERROR;
const char ** phys_in_ports = api_jack_get_ports (stream->context->jack_client,
@ -268,7 +273,7 @@ cbjack_connect_ports (cubeb_stream * stream)
JackPortIsOutput
| JackPortIsPhysical);
if (phys_in_ports == NULL || *phys_in_ports == NULL) {
if (phys_in_ports == NULL || *phys_in_ports == NULL || options & CBJACK_CP_OPTIONS_SKIP_OUTPUT) {
goto skipplayback;
}
@ -285,7 +290,7 @@ cbjack_connect_ports (cubeb_stream * stream)
r = CUBEB_OK;
skipplayback:
if (phys_out_ports == NULL || *phys_out_ports == NULL) {
if (phys_out_ports == NULL || *phys_out_ports == NULL || options & CBJACK_CP_OPTIONS_SKIP_INPUT) {
goto end;
}
// Connect inputs to capture
@ -892,6 +897,13 @@ cbjack_stream_init(cubeb * context, cubeb_stream ** stream, char const * stream_
JACK_DEFAULT_AUDIO_TYPE,
JackPortIsOutput,
0);
if (!(output_stream_params->prefs & CUBEB_STREAM_PREF_JACK_NO_AUTO_CONNECT)) {
if (cbjack_connect_ports(stm, CBJACK_CP_OPTIONS_SKIP_INPUT) != CUBEB_OK) {
pthread_mutex_unlock(&stm->mutex);
cbjack_stream_destroy(stm);
return CUBEB_ERROR;
}
}
}
}
@ -904,15 +916,16 @@ cbjack_stream_init(cubeb * context, cubeb_stream ** stream, char const * stream_
JACK_DEFAULT_AUDIO_TYPE,
JackPortIsInput,
0);
if (!(input_stream_params->prefs & CUBEB_STREAM_PREF_JACK_NO_AUTO_CONNECT)) {
if (cbjack_connect_ports(stm, CBJACK_CP_OPTIONS_SKIP_OUTPUT) != CUBEB_OK) {
pthread_mutex_unlock(&stm->mutex);
cbjack_stream_destroy(stm);
return CUBEB_ERROR;
}
}
}
}
if (cbjack_connect_ports(stm) != CUBEB_OK) {
pthread_mutex_unlock(&stm->mutex);
cbjack_stream_destroy(stm);
return CUBEB_ERROR;
}
*stream = stm;
stm->ports_ready = true;

View File

@ -358,7 +358,6 @@ static struct cubeb_ops const kai_ops = {
/*.stream_destroy =*/ kai_stream_destroy,
/*.stream_start =*/ kai_stream_start,
/*.stream_stop =*/ kai_stream_stop,
/*.stream_reset_default_device =*/ NULL,
/*.stream_get_position =*/ kai_stream_get_position,
/*.stream_get_latency = */ kai_stream_get_latency,
/*.stream_get_input_latency = */ NULL,

View File

@ -46,6 +46,7 @@ void cubeb_async_log_reset_threads();
} while(0)
/* Asynchronous verbose logging, to log in real-time callbacks. */
/* Should not be used on android due to the use of global/static variables. */
#define ALOGV(fmt, ...) \
do { \
cubeb_async_log(fmt, ##__VA_ARGS__); \

View File

@ -27,6 +27,7 @@
#include "cubeb-sles.h"
#include "cubeb_array_queue.h"
#include "android/cubeb-output-latency.h"
#include "cubeb_android.h"
#if defined(__ANDROID__)
#ifdef LOG
@ -65,11 +66,6 @@
#define DEFAULT_SAMPLE_RATE 48000
#define DEFAULT_NUM_OF_FRAMES 480
// If the latency requested is above this threshold, this stream is considered
// intended for playback (vs. real-time). Tell Android it should favor saving
// power over performance or latency.
// This is around 100ms at 44100 or 48000
#define POWERSAVE_LATENCY_FRAMES_THRESHOLD 4000
static struct cubeb_ops const opensl_ops;
@ -1702,7 +1698,7 @@ opensl_stream_get_latency(cubeb_stream * stm, uint32_t * latency)
assert(latency);
uint32_t stream_latency_frames =
stm->user_output_rate * (stm->output_latency_ms / 1000);
stm->user_output_rate * stm->output_latency_ms / 1000;
return stream_latency_frames + cubeb_resampler_latency(stm->resampler);
}
@ -1751,7 +1747,6 @@ static struct cubeb_ops const opensl_ops = {
.stream_destroy = opensl_stream_destroy,
.stream_start = opensl_stream_start,
.stream_stop = opensl_stream_stop,
.stream_reset_default_device = NULL,
.stream_get_position = opensl_stream_get_position,
.stream_get_latency = opensl_stream_get_latency,
.stream_get_input_latency = NULL,

File diff suppressed because it is too large Load Diff

View File

@ -1625,7 +1625,6 @@ static struct cubeb_ops const pulse_ops = {
.stream_destroy = pulse_stream_destroy,
.stream_start = pulse_stream_start,
.stream_stop = pulse_stream_stop,
.stream_reset_default_device = NULL,
.stream_get_position = pulse_stream_get_position,
.stream_get_latency = pulse_stream_get_latency,
.stream_get_input_latency = NULL,

View File

@ -138,17 +138,6 @@ cubeb_resampler_speex<T, InputProcessor, OutputProcessor>
, user_ptr(ptr)
{
if (input_processor && output_processor) {
// Add some delay on the processor that has the lowest delay so that the
// streams are synchronized.
uint32_t in_latency = input_processor->latency();
uint32_t out_latency = output_processor->latency();
if (in_latency > out_latency) {
uint32_t latency_diff = in_latency - out_latency;
output_processor->add_latency(latency_diff);
} else if (in_latency < out_latency) {
uint32_t latency_diff = out_latency - in_latency;
input_processor->add_latency(latency_diff);
}
fill_internal = &cubeb_resampler_speex::fill_internal_duplex;
} else if (input_processor) {
fill_internal = &cubeb_resampler_speex::fill_internal_input;

View File

@ -213,17 +213,6 @@ public:
speex_resampler_destroy(speex_resampler);
}
/** Sometimes, it is necessary to add latency on one way of a two-way
* resampler so that the stream are synchronized. This must be called only on
* a fresh resampler, otherwise, silent samples will be inserted in the
* stream.
* @param frames the number of frames of latency to add. */
void add_latency(size_t frames)
{
additional_latency += frames;
resampling_in_buffer.push_silence(frames_to_samples(frames));
}
/* Fill the resampler with `input_frame_count` frames. */
void input(T * input_buffer, size_t input_frame_count)
{
@ -307,9 +296,11 @@ public:
uint32_t input_needed_for_output(int32_t output_frame_count) const
{
assert(output_frame_count >= 0); // Check overflow
int32_t unresampled_frames_left = samples_to_frames(resampling_in_buffer.length());
int32_t resampled_frames_left = samples_to_frames(resampling_out_buffer.length());
float input_frames_needed =
output_frame_count * resampling_ratio - resampled_frames_left;
float input_frames_needed =
(output_frame_count - unresampled_frames_left) * resampling_ratio
- resampled_frames_left;
if (input_frames_needed < 0) {
return 0;
}
@ -412,13 +403,6 @@ public:
/* Fill the delay line with some silent frames to add latency. */
delay_input_buffer.push_silence(frames * channels);
}
/* Add some latency to the delay line.
* @param frames the number of frames of latency to add. */
void add_latency(size_t frames)
{
length += frames;
delay_input_buffer.push_silence(frames_to_samples(frames));
}
/** Push some frames into the delay line.
* @parameter buffer the frames to push.
* @parameter frame_count the number of frames in #buffer. */

View File

@ -658,7 +658,6 @@ static struct cubeb_ops const sndio_ops = {
.stream_destroy = sndio_stream_destroy,
.stream_start = sndio_stream_start,
.stream_stop = sndio_stream_stop,
.stream_reset_default_device = NULL,
.stream_get_position = sndio_stream_get_position,
.stream_get_latency = sndio_stream_get_latency,
.stream_set_volume = sndio_stream_set_volume,

View File

@ -718,7 +718,6 @@ static struct cubeb_ops const sun_ops = {
.stream_destroy = sun_stream_destroy,
.stream_start = sun_stream_start,
.stream_stop = sun_stream_stop,
.stream_reset_default_device = NULL,
.stream_get_position = sun_stream_get_position,
.stream_get_latency = sun_stream_get_latency,
.stream_get_input_latency = NULL,

View File

@ -4,7 +4,7 @@
* This program is made available under an ISC-style license. See the
* accompanying file LICENSE for details.
*/
#define _WIN32_WINNT 0x0600
#define _WIN32_WINNT 0x0603
#define NOMINMAX
#include <initguid.h>
@ -778,12 +778,6 @@ hns_to_frames(cubeb_stream * stm, REFERENCE_TIME hns)
return hns_to_frames(get_rate(stm), hns);
}
REFERENCE_TIME
frames_to_hns(cubeb_stream * stm, uint32_t frames)
{
return std::ceil(frames * 10000000.0 / get_rate(stm));
}
REFERENCE_TIME
frames_to_hns(uint32_t rate, uint32_t frames)
{
@ -867,7 +861,17 @@ refill(cubeb_stream * stm, void * input_buffer, long input_frames_count,
return out_frames;
}
int wasapi_stream_reset_default_device(cubeb_stream * stm);
int trigger_async_reconfigure(cubeb_stream * stm)
{
XASSERT(stm && stm->reconfigure_event);
BOOL ok = SetEvent(stm->reconfigure_event);
if (!ok) {
LOG("SetEvent on reconfigure_event failed: %lx", GetLastError());
return CUBEB_ERROR;
}
return CUBEB_OK;
}
/* This helper grabs all the frames available from a capture client, put them in
* linear_input_buffer. linear_input_buffer should be cleared before the
@ -896,7 +900,7 @@ bool get_input_buffer(cubeb_stream * stm)
// Application can recover from this error. More info
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd316605(v=vs.85).aspx
LOG("Device invalidated error, reset default device");
wasapi_stream_reset_default_device(stm);
trigger_async_reconfigure(stm);
return true;
}
@ -999,7 +1003,7 @@ bool get_output_buffer(cubeb_stream * stm, void *& buffer, size_t & frame_count)
// Application can recover from this error. More info
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd316605(v=vs.85).aspx
LOG("Device invalidated error, reset default device");
wasapi_stream_reset_default_device(stm);
trigger_async_reconfigure(stm);
return true;
}
@ -1346,7 +1350,7 @@ void wasapi_destroy(cubeb * context);
HRESULT register_notification_client(cubeb_stream * stm)
{
assert(stm->device_enumerator);
XASSERT(stm->device_enumerator);
stm->notification_client.reset(new wasapi_endpoint_notification_client(stm->reconfigure_event, stm->role));
@ -1354,7 +1358,6 @@ HRESULT register_notification_client(cubeb_stream * stm)
if (FAILED(hr)) {
LOG("Could not register endpoint notification callback: %lx", hr);
stm->notification_client = nullptr;
stm->device_enumerator = nullptr;
}
return hr;
@ -1362,18 +1365,12 @@ HRESULT register_notification_client(cubeb_stream * stm)
HRESULT unregister_notification_client(cubeb_stream * stm)
{
XASSERT(stm);
HRESULT hr;
XASSERT(stm->device_enumerator);
if (!stm->device_enumerator) {
return S_OK;
}
hr = stm->device_enumerator->UnregisterEndpointNotificationCallback(stm->notification_client.get());
HRESULT hr = stm->device_enumerator->UnregisterEndpointNotificationCallback(stm->notification_client.get());
if (FAILED(hr)) {
// We can't really do anything here, we'll probably leak the
// notification client, but we can at least release the enumerator.
stm->device_enumerator = nullptr;
// notification client.
return S_OK;
}
@ -1813,6 +1810,29 @@ handle_channel_layout(cubeb_stream * stm, EDataFlow direction, com_heap_ptr<WAV
}
static bool
initialize_iaudioclient2(com_ptr<IAudioClient> & audio_client)
{
com_ptr<IAudioClient2> audio_client2;
audio_client->QueryInterface<IAudioClient2>(audio_client2.receive());
if (!audio_client2) {
LOG("Could not get IAudioClient2 interface, not setting AUDCLNT_STREAMOPTIONS_RAW.");
return CUBEB_OK;
}
AudioClientProperties properties = { 0 };
properties.cbSize = sizeof(AudioClientProperties);
#ifndef __MINGW32__
properties.Options |= AUDCLNT_STREAMOPTIONS_RAW;
#endif
HRESULT hr = audio_client2->SetClientProperties(&properties);
if (FAILED(hr)) {
LOG("IAudioClient2::SetClientProperties error: %lx", GetLastError());
return CUBEB_ERROR;
}
return CUBEB_OK;
}
// Not static to suppress a warning.
/* static */ bool
initialize_iaudioclient3(com_ptr<IAudioClient> & audio_client,
cubeb_stream * stm,
const com_heap_ptr<WAVEFORMATEX> & mix_format,
@ -1835,7 +1855,7 @@ initialize_iaudioclient3(com_ptr<IAudioClient> & audio_client,
// IAudioClient3 doesn't support AUDCLNT_STREAMFLAGS_NOPERSIST, and will return
// AUDCLNT_E_INVALID_STREAM_FLAG. This is undocumented.
flags = flags ^ AUDCLNT_STREAMFLAGS_NOPERSIST;
flags = flags & ~AUDCLNT_STREAMFLAGS_NOPERSIST;
// Some people have reported glitches with capture streams:
// http://blog.nirbheek.in/2018/03/low-latency-audio-on-windows-with.html
@ -2008,6 +2028,23 @@ int setup_wasapi_stream_one_side(cubeb_stream * stm,
com_heap_ptr<WAVEFORMATEX> mix_format(tmp);
mix_format->wBitsPerSample = stm->bytes_per_sample * 8;
if (mix_format->wFormatTag == WAVE_FORMAT_PCM ||
mix_format->wFormatTag == WAVE_FORMAT_IEEE_FLOAT) {
switch (mix_format->wBitsPerSample) {
case 8:
case 16:
mix_format->wFormatTag = WAVE_FORMAT_PCM;
break;
case 32:
mix_format->wFormatTag = WAVE_FORMAT_IEEE_FLOAT;
break;
default:
LOG("%u bits per sample is incompatible with PCM wave formats",
mix_format->wBitsPerSample);
return CUBEB_ERROR;
}
}
if (mix_format->wFormatTag == WAVE_FORMAT_EXTENSIBLE) {
WAVEFORMATEXTENSIBLE * format_pcm = reinterpret_cast<WAVEFORMATEXTENSIBLE *>(mix_format.get());
format_pcm->SubFormat = stm->waveformatextensible_sub_format;
@ -2032,7 +2069,13 @@ int setup_wasapi_stream_one_side(cubeb_stream * stm,
mix_params->format, mix_params->rate, mix_params->channels,
mix_params->layout);
DWORD flags = AUDCLNT_STREAMFLAGS_NOPERSIST;
DWORD flags = 0;
bool is_persist = stream_params->prefs & CUBEB_STREAM_PREF_PERSIST;
if (!is_persist) {
flags |= AUDCLNT_STREAMFLAGS_NOPERSIST;
}
// Check if a loopback device should be requested. Note that event callbacks
// do not work with loopback devices, so only request these if not looping.
@ -2057,9 +2100,11 @@ int setup_wasapi_stream_one_side(cubeb_stream * stm,
cubeb_device_info device_info;
int rv = wasapi_create_device(stm->context, device_info, stm->device_enumerator.get(), device.get());
if (rv == CUBEB_OK) {
const char* HANDSFREE_TAG = "BTHHFEENUM";
const char* HANDSFREE_TAG = "BTHHFENUM";
size_t len = sizeof(HANDSFREE_TAG);
if (direction == eCapture && strncmp(device_info.group_id, HANDSFREE_TAG, len) == 0) {
if (direction == eCapture &&
strlen(device_info.group_id) >= len &&
strncmp(device_info.group_id, HANDSFREE_TAG, len) == 0) {
// Rather high-latency to prevent constant under-runs in this particular
// case of an input device using bluetooth handsfree.
uint32_t default_period_frames = hns_to_frames(device_info.default_rate, default_period);
@ -2082,6 +2127,13 @@ int setup_wasapi_stream_one_side(cubeb_stream * stm,
LOG("Could not get cubeb_device_info.");
}
if (stream_params->prefs & CUBEB_STREAM_PREF_RAW) {
if (initialize_iaudioclient2(audio_client) != CUBEB_OK) {
LOG("Can't initialize an IAudioClient2, error: %lx", GetLastError());
// This is not fatal.
}
}
#if 0 // See https://bugzilla.mozilla.org/show_bug.cgi?id=1590902
if (initialize_iaudioclient3(audio_client, stm, mix_format, flags, direction)) {
LOG("Initialized with IAudioClient3");
@ -2131,7 +2183,7 @@ int setup_wasapi_stream_one_side(cubeb_stream * stm,
void wasapi_find_matching_output_device(cubeb_stream * stm) {
HRESULT hr;
cubeb_device_info * input_device;
cubeb_device_info * input_device = nullptr;
cubeb_device_collection collection;
// Only try to match to an output device if the input device is a bluetooth
@ -2153,6 +2205,9 @@ void wasapi_find_matching_output_device(cubeb_stream * stm) {
}
int rv = wasapi_enumerate_devices(stm->context, (cubeb_device_type)(CUBEB_DEVICE_TYPE_INPUT|CUBEB_DEVICE_TYPE_OUTPUT), &collection);
if (rv != CUBEB_OK) {
return;
}
// Find the input device, and then find the output device with the same group
// id and the same rate.
@ -2166,11 +2221,13 @@ void wasapi_find_matching_output_device(cubeb_stream * stm) {
for (uint32_t i = 0; i < collection.count; i++) {
cubeb_device_info dev = collection.device[i];
if (dev.type == CUBEB_DEVICE_TYPE_OUTPUT &&
dev.group_id && !strcmp(dev.group_id, input_device->group_id) &&
if (dev.type == CUBEB_DEVICE_TYPE_OUTPUT && dev.group_id && input_device &&
!strcmp(dev.group_id, input_device->group_id) &&
dev.default_rate == input_device->default_rate) {
LOG("Found matching device for %s: %s", input_device->friendly_name, dev.friendly_name);
stm->output_device_id = utf8_to_wstr(reinterpret_cast<char const *>(dev.devid));
LOG("Found matching device for %s: %s", input_device->friendly_name,
dev.friendly_name);
stm->output_device_id =
utf8_to_wstr(reinterpret_cast<char const *>(dev.devid));
}
}
@ -2696,17 +2753,6 @@ int wasapi_stream_stop(cubeb_stream * stm)
return CUBEB_OK;
}
int wasapi_stream_reset_default_device(cubeb_stream * stm)
{
XASSERT(stm && stm->reconfigure_event);
BOOL ok = SetEvent(stm->reconfigure_event);
if (!ok) {
LOG("SetEvent on reconfigure_event failed: %lx", GetLastError());
return CUBEB_ERROR;
}
return CUBEB_OK;
}
int wasapi_stream_get_position(cubeb_stream * stm, uint64_t * position)
{
XASSERT(stm && position);
@ -3206,7 +3252,6 @@ cubeb_ops const wasapi_ops = {
/*.stream_destroy =*/ wasapi_stream_destroy,
/*.stream_start =*/ wasapi_stream_start,
/*.stream_stop =*/ wasapi_stream_stop,
/*.stream_reset_default_device =*/ wasapi_stream_reset_default_device,
/*.stream_get_position =*/ wasapi_stream_get_position,
/*.stream_get_latency =*/ wasapi_stream_get_latency,
/*.stream_get_input_latency =*/ wasapi_stream_get_input_latency,

View File

@ -1056,7 +1056,6 @@ static struct cubeb_ops const winmm_ops = {
/*.stream_destroy =*/ winmm_stream_destroy,
/*.stream_start =*/ winmm_stream_start,
/*.stream_stop =*/ winmm_stream_stop,
/*.stream_reset_default_device =*/ NULL,
/*.stream_get_position =*/ winmm_stream_get_position,
/*.stream_get_latency = */ winmm_stream_get_latency,
/*.stream_get_input_latency = */ NULL,

View File

@ -642,65 +642,6 @@ TEST(cubeb, drain)
do_drain = 0;
}
TEST(cubeb, device_reset)
{
int r;
cubeb * ctx;
cubeb_stream * stream;
cubeb_stream_params params;
uint64_t position;
r = common_init(&ctx, "test_sanity");
ASSERT_EQ(r, CUBEB_OK);
ASSERT_NE(ctx, nullptr);
if (strcmp(cubeb_get_backend_id(ctx), "wasapi")) {
// cubeb_stream_reset_default_device is only useful and implemented in the
// WASAPI backend.
return;
}
params.format = STREAM_FORMAT;
params.rate = STREAM_RATE;
params.channels = STREAM_CHANNELS;
params.layout = STREAM_LAYOUT;
params.prefs = CUBEB_STREAM_PREF_NONE;
r = cubeb_stream_init(ctx, &stream, "test", NULL, NULL, NULL, &params, STREAM_LATENCY,
test_data_callback, test_state_callback, &dummy);
ASSERT_EQ(r, CUBEB_OK);
ASSERT_NE(stream, nullptr);
r = cubeb_stream_start(stream);
ASSERT_EQ(r, CUBEB_OK);
uint32_t iterations = 5;
uint64_t previous_position = 0;
while (iterations--) {
r = cubeb_stream_get_position(stream, &position);
ASSERT_EQ(r, CUBEB_OK);
ASSERT_GE(position, previous_position);
previous_position = position;
delay(100);
}
r = cubeb_stream_reset_default_device(stream);
ASSERT_EQ(r, CUBEB_OK);
iterations = 5;
while (iterations--) {
r = cubeb_stream_get_position(stream, &position);
ASSERT_EQ(r, CUBEB_OK);
ASSERT_GE(position, previous_position);
previous_position = position;
delay(100);
}
cubeb_stream_stop(stream);
cubeb_stream_destroy(stream);
cubeb_destroy(ctx);
}
TEST(cubeb, DISABLED_eos_during_prefill)
{
// This test needs to be implemented.

View File

@ -63,7 +63,6 @@ extern "C" {
pub fn cubeb_stream_destroy(stream: *mut cubeb_stream);
pub fn cubeb_stream_start(stream: *mut cubeb_stream) -> c_int;
pub fn cubeb_stream_stop(stream: *mut cubeb_stream) -> c_int;
pub fn cubeb_stream_reset_default_device(stream: *mut cubeb_stream) -> c_int;
pub fn cubeb_stream_get_position(stream: *mut cubeb_stream, position: *mut u64) -> c_int;
pub fn cubeb_stream_get_latency(stream: *mut cubeb_stream, latency: *mut c_uint) -> c_int;
pub fn cubeb_stream_get_input_latency(stream: *mut cubeb_stream, latency: *mut c_uint) -> c_int;

View File

@ -1 +1 @@
{"files":{"Cargo.lock":"5c6ff9f4925b4505337025ef175c6abeafd31a6d7f1035513bc1dad95bc980b4","Cargo.toml":"f98dcb39dea45c8a9b12a742dd8cd5e8385ee7da4c61cbd1411b8b840fba8dde","LICENSE":"8c044baa5d883274736eeece0b955249076c2697b826e576fce59496235b2cf5","README.md":"408c573ec240927cf5b9c036098e94e374ec41f71991415422586f450586b214","examples/common/mod.rs":"a5e1b79fc2b4addff1e442879ba3dbcb1cf5973e76b9a62d97dd0042597480db","examples/devices.rs":"ff5dcd588e7036165c4b4c20ec355d036e0ae90cf88b3b0f5cd86621fe2ce61d","examples/tone.rs":"8f5f9851b6d99f6f16c597fcb9312e3ef81769cbfb89341d2ea2522ca2e2214e","src/context.rs":"72507f5338a2f520fef9e2eface0638afba4c0d9e87fde92a0aaade643ba1335","src/frame.rs":"ed1e8f4576022d0c23106bb115125e5a2967b0375a10d0c54bbe99f04a70cc3f","src/lib.rs":"98e9280890551ac9305f2f808e315b6aa6bcd5781b8e96a078787ded0ef91e2a","src/log.rs":"704faeb31934dad6bc6d02e01caa85118754209bd559d30d03fcfa5cb8c1603c","src/sample.rs":"e23be3b691052001916f920ce9c1a0051bd097e39c9d34cbcb80ab8120265f45","src/stream.rs":"b3babf86252cd19cfbc98ffbc8f48bb033284f89db9cbdc46836611893356eff"},"package":"289952682b57343f3d852161d60f2a34a07c5fc39c113f155ab8aa3f471c917b"}
{"files":{"Cargo.lock":"dc8eea19a0aacf9a0a37136d40c4b05baf65a65f8b76e4ded6a95d8a3f5140a2","Cargo.toml":"c65fe4778409bfe61b0f3ce2d00fe385a5d2ca0be27fec413f50989d72fbcd13","LICENSE":"8c044baa5d883274736eeece0b955249076c2697b826e576fce59496235b2cf5","README.md":"408c573ec240927cf5b9c036098e94e374ec41f71991415422586f450586b214","examples/common/mod.rs":"a5e1b79fc2b4addff1e442879ba3dbcb1cf5973e76b9a62d97dd0042597480db","examples/devices.rs":"ff5dcd588e7036165c4b4c20ec355d036e0ae90cf88b3b0f5cd86621fe2ce61d","examples/tone.rs":"8f5f9851b6d99f6f16c597fcb9312e3ef81769cbfb89341d2ea2522ca2e2214e","src/context.rs":"72507f5338a2f520fef9e2eface0638afba4c0d9e87fde92a0aaade643ba1335","src/frame.rs":"ed1e8f4576022d0c23106bb115125e5a2967b0375a10d0c54bbe99f04a70cc3f","src/lib.rs":"98e9280890551ac9305f2f808e315b6aa6bcd5781b8e96a078787ded0ef91e2a","src/log.rs":"704faeb31934dad6bc6d02e01caa85118754209bd559d30d03fcfa5cb8c1603c","src/sample.rs":"e23be3b691052001916f920ce9c1a0051bd097e39c9d34cbcb80ab8120265f45","src/stream.rs":"b3babf86252cd19cfbc98ffbc8f48bb033284f89db9cbdc46836611893356eff"},"package":"33c84c136ac07ad218df6ca1b3ca0f0a1f7358ce059ea13a2c5527d4311c36c0"}

22
third_party/rust/cubeb/Cargo.lock generated vendored
View File

@ -8,31 +8,31 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
[[package]]
name = "cc"
version = "1.0.60"
version = "1.0.66"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef611cc68ff783f18535d77ddd080185275713d852c4f5cbb6122c462a7a825c"
checksum = "4c0496836a84f8d0495758516b8621a622beb77c0fed418570e50764093ced48"
[[package]]
name = "cmake"
version = "0.1.44"
version = "0.1.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e56268c17a6248366d66d4a47a3381369d068cce8409bb1716ed77ea32163bb"
checksum = "eb6210b637171dfba4cda12e579ac6dc73f5165ad56133e5d72ef3131f320855"
dependencies = [
"cc",
]
[[package]]
name = "cubeb"
version = "0.8.0"
version = "0.9.0"
dependencies = [
"cubeb-core",
]
[[package]]
name = "cubeb-core"
version = "0.8.0"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6197f805b94171473c3fa3059f688f00a2df1ee76259f9ea641401b58917df3"
checksum = "40aa77fed9bd627aaf11654c4d2753038d43d0f10abb6651db6e9330f81270e9"
dependencies = [
"bitflags",
"cubeb-sys",
@ -40,9 +40,9 @@ dependencies = [
[[package]]
name = "cubeb-sys"
version = "0.8.0"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b0f751f2aee031f589bcfd812b99cfbf923aa1612d34c9757608cf540f74ad9"
checksum = "eaedd862c6194a52c45efc3b5fd43e42e11fe3cd915520add4d1a5d03a818796"
dependencies = [
"cmake",
"pkg-config",
@ -50,6 +50,6 @@ dependencies = [
[[package]]
name = "pkg-config"
version = "0.3.18"
version = "0.3.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d36492546b6af1463394d46f0c834346f31548646f6ba10849802c9c9a27ac33"
checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c"

View File

@ -12,7 +12,7 @@
[package]
name = "cubeb"
version = "0.8.0"
version = "0.9.0"
authors = ["Dan Glastonbury <dglastonbury@mozilla.com>"]
description = "Bindings to libcubeb for interacting with system audio from rust.\n"
homepage = "https://github.com/djg/cubeb-rs"
@ -22,7 +22,7 @@ categories = ["api-bindings"]
license = "ISC"
repository = "https://github.com/djg/cubeb-rs"
[dependencies.cubeb-core]
version = "0.8.0"
version = "0.9.0"
[features]
gecko-in-tree = ["cubeb-core/gecko-in-tree"]