diff --git a/.cargo/config.in b/.cargo/config.in index 8872ae7584e2e..c1d5d3cf3eee2 100644 --- a/.cargo/config.in +++ b/.cargo/config.in @@ -75,7 +75,7 @@ rev = "5e870faf6f95d79d11efc813e56370ad124bbed5" [source."https://github.com/ChunMinChang/cubeb-coreaudio-rs"] git = "https://github.com/ChunMinChang/cubeb-coreaudio-rs" replace-with = "vendored-sources" -rev = "4acd80233efa645ac79769f37b07d495c1b42070" +rev = "799518a033a0c780cfdb82a4eaabfd9681cb7f3b" [source.crates-io] replace-with = "vendored-sources" diff --git a/Cargo.lock b/Cargo.lock index b5ddaaeb573e4..1dd5eb3275c07 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -686,7 +686,7 @@ dependencies = [ [[package]] name = "coreaudio-sys-utils" version = "0.1.0" -source = "git+https://github.com/ChunMinChang/cubeb-coreaudio-rs?rev=4acd80233efa645ac79769f37b07d495c1b42070#4acd80233efa645ac79769f37b07d495c1b42070" +source = "git+https://github.com/ChunMinChang/cubeb-coreaudio-rs?rev=799518a033a0c780cfdb82a4eaabfd9681cb7f3b#799518a033a0c780cfdb82a4eaabfd9681cb7f3b" dependencies = [ "core-foundation-sys", "coreaudio-sys", @@ -923,7 +923,7 @@ dependencies = [ [[package]] name = "cubeb-coreaudio" version = "0.1.0" -source = "git+https://github.com/ChunMinChang/cubeb-coreaudio-rs?rev=4acd80233efa645ac79769f37b07d495c1b42070#4acd80233efa645ac79769f37b07d495c1b42070" +source = "git+https://github.com/ChunMinChang/cubeb-coreaudio-rs?rev=799518a033a0c780cfdb82a4eaabfd9681cb7f3b#799518a033a0c780cfdb82a4eaabfd9681cb7f3b" dependencies = [ "atomic", "audio-mixer", diff --git a/third_party/rust/coreaudio-sys-utils/.cargo-checksum.json b/third_party/rust/coreaudio-sys-utils/.cargo-checksum.json index f121623d3ada6..4bbc97cb7a571 100644 --- a/third_party/rust/coreaudio-sys-utils/.cargo-checksum.json +++ b/third_party/rust/coreaudio-sys-utils/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"35acbd2f8633a6109f3d3e554bef8d847c049ce6ef7a5f570468819e41344d7f","src/aggregate_device.rs":"7d2bd5f5fd7f3d008ebb69ad81f522ca0cb73db6d7b3e50ed1a63ea26ff721f4","src/audio_object.rs":"df10160d9fd83a2c23a49e69b78d39db3a9d6389607df6acfc05821293b6af5f","src/audio_unit.rs":"d783878930df4923b57ad230138c0f3fd6b0b9bb80a39725092ff4c6615162d8","src/cf_mutable_dict.rs":"fc42edd270c6dfb02f123214d2d8e487bbd62b5bd923b71eec13190fd0104d2a","src/dispatch.rs":"195ca94cbc61948637bfdcbe22070a1e6d41e97cec22301df4e45dcef7b1c208","src/lib.rs":"bcc559d69ef6ed0cbea5b2a36fec89d8c011eb9da70e2f26c00f881ad97a2546","src/string.rs":"28f88b816c768bcfcc674a60d962b93f1c94e5e0f4cc8ed2a1301138b91039e7"},"package":null} \ No newline at end of file +{"files":{"Cargo.toml":"35acbd2f8633a6109f3d3e554bef8d847c049ce6ef7a5f570468819e41344d7f","src/aggregate_device.rs":"7d2bd5f5fd7f3d008ebb69ad81f522ca0cb73db6d7b3e50ed1a63ea26ff721f4","src/audio_object.rs":"df10160d9fd83a2c23a49e69b78d39db3a9d6389607df6acfc05821293b6af5f","src/audio_unit.rs":"d783878930df4923b57ad230138c0f3fd6b0b9bb80a39725092ff4c6615162d8","src/cf_mutable_dict.rs":"fc42edd270c6dfb02f123214d2d8e487bbd62b5bd923b71eec13190fd0104d2a","src/dispatch.rs":"0f4b05076bf4ce8e9ce2a98c65149fcdd716b772a7ab111f37f9d12678552e1e","src/lib.rs":"bcc559d69ef6ed0cbea5b2a36fec89d8c011eb9da70e2f26c00f881ad97a2546","src/string.rs":"28f88b816c768bcfcc674a60d962b93f1c94e5e0f4cc8ed2a1301138b91039e7"},"package":null} \ No newline at end of file diff --git a/third_party/rust/coreaudio-sys-utils/src/dispatch.rs b/third_party/rust/coreaudio-sys-utils/src/dispatch.rs index 064d7dea20f6f..8bd45bb7dadc5 100644 --- a/third_party/rust/coreaudio-sys-utils/src/dispatch.rs +++ b/third_party/rust/coreaudio-sys-utils/src/dispatch.rs @@ -4,148 +4,203 @@ use std::ffi::CString; use std::mem; use std::os::raw::c_void; use std::ptr; - -pub const DISPATCH_QUEUE_SERIAL: dispatch_queue_attr_t = ptr::null_mut::(); - -pub fn create_dispatch_queue( - label: &'static str, - queue_attr: dispatch_queue_attr_t, -) -> dispatch_queue_t { - let label = CString::new(label).unwrap(); - let c_string = label.as_ptr(); - unsafe { dispatch_queue_create(c_string, queue_attr) } -} - -pub fn release_dispatch_queue(queue: dispatch_queue_t) { - // TODO: This is incredibly unsafe. Find another way to release the queue. - unsafe { - dispatch_release(mem::transmute::(queue)); +use std::sync::atomic::{AtomicBool, Ordering}; + +// Queue: A wrapper around `dispatch_queue_t`. +// ------------------------------------------------------------------------------------------------ +#[derive(Debug)] +pub struct Queue(dispatch_queue_t); + +impl Queue { + pub fn new(label: &str) -> Self { + const DISPATCH_QUEUE_SERIAL: dispatch_queue_attr_t = + ptr::null_mut::(); + let label = CString::new(label).unwrap(); + let c_string = label.as_ptr(); + let queue = Self(unsafe { dispatch_queue_create(c_string, DISPATCH_QUEUE_SERIAL) }); + queue.set_should_cancel(Box::new(AtomicBool::new(false))); + queue } -} -pub fn async_dispatch(queue: dispatch_queue_t, work: F) -where - F: Send + FnOnce(), -{ - let (closure, executor) = create_closure_and_executor(work); - unsafe { - dispatch_async_f(queue, closure, executor); - } -} - -pub fn sync_dispatch(queue: dispatch_queue_t, work: F) -where - F: Send + FnOnce(), -{ - let (closure, executor) = create_closure_and_executor(work); - unsafe { - dispatch_sync_f(queue, closure, executor); - } -} - -// Return an raw pointer to a (unboxed) closure and an executor that -// will run the closure (after re-boxing the closure) when it's called. -fn create_closure_and_executor(closure: F) -> (*mut c_void, dispatch_function_t) -where - F: FnOnce(), -{ - extern "C" fn closure_executer(unboxed_closure: *mut c_void) + pub fn run_async(&self, work: F) where - F: FnOnce(), + F: Send + FnOnce(), { - // Retake the leaked closure. - let closure = unsafe { Box::from_raw(unboxed_closure as *mut F) }; - // Execute the closure. - (*closure)(); - // closure is released after finishing this function call. + let should_cancel = self.get_should_cancel(); + let (closure, executor) = Self::create_closure_and_executor(|| { + if should_cancel.map_or(false, |v| v.load(Ordering::SeqCst)) { + return; + } + work(); + }); + unsafe { + dispatch_async_f(self.0, closure, executor); + } } - let closure = Box::new(closure); // Allocate closure on heap. - let executor: dispatch_function_t = Some(closure_executer::); - - ( - Box::into_raw(closure) as *mut c_void, // Leak the closure. - executor, - ) -} - -#[cfg(test)] -mod test { - use super::*; - use std::sync::{Arc, Mutex}; - const COUNT: u32 = 10; - - #[test] - fn test_async_dispatch() { - use std::sync::mpsc::channel; - - get_queue_and_resource("Run with async dispatch api wrappers", |queue, resource| { - let (tx, rx) = channel(); - for i in 0..COUNT { - let (res, tx) = (Arc::clone(&resource), tx.clone()); - async_dispatch(queue, move || { - let mut res = res.lock().unwrap(); - assert_eq!(res.last_touched, if i == 0 { None } else { Some(i - 1) }); - assert_eq!(res.touched_count, i); - res.touch(i); - if i == COUNT - 1 { - tx.send(()).unwrap(); - } - }); + pub fn run_sync(&self, work: F) + where + F: Send + FnOnce(), + { + let should_cancel = self.get_should_cancel(); + let (closure, executor) = Self::create_closure_and_executor(|| { + if should_cancel.map_or(false, |v| v.load(Ordering::SeqCst)) { + return; } - rx.recv().unwrap(); // Wait until it's touched COUNT times. - let resource = resource.lock().unwrap(); - assert_eq!(resource.touched_count, COUNT); - assert_eq!(resource.last_touched.unwrap(), COUNT - 1); + work(); }); + unsafe { + dispatch_sync_f(self.0, closure, executor); + } } - #[test] - fn test_sync_dispatch() { - get_queue_and_resource("Run with sync dispatch api wrappers", |queue, resource| { - for i in 0..COUNT { - let res = Arc::clone(&resource); - sync_dispatch(queue, move || { - let mut res = res.lock().unwrap(); - assert_eq!(res.last_touched, if i == 0 { None } else { Some(i - 1) }); - assert_eq!(res.touched_count, i); - res.touch(i); - }); - } - let resource = resource.lock().unwrap(); - assert_eq!(resource.touched_count, COUNT); - assert_eq!(resource.last_touched.unwrap(), COUNT - 1); + pub fn run_final(&self, work: F) + where + F: Send + FnOnce(), + { + let should_cancel = self.get_should_cancel(); + let (closure, executor) = Self::create_closure_and_executor(|| { + work(); + should_cancel + .expect("dispatch context should be allocated!") + .store(true, Ordering::SeqCst); }); + unsafe { + dispatch_sync_f(self.0, closure, executor); + } } - struct Resource { - last_touched: Option, - touched_count: u32, + fn get_should_cancel(&self) -> Option<&mut AtomicBool> { + unsafe { + let context = dispatch_get_context( + mem::transmute::(self.0), + ) as *mut AtomicBool; + context.as_mut() + } } - impl Resource { - fn new() -> Self { - Resource { - last_touched: None, - touched_count: 0, + fn set_should_cancel(&self, context: Box) { + unsafe { + let queue = mem::transmute::(self.0); + // Leak the context from Box. + dispatch_set_context(queue, Box::into_raw(context) as *mut c_void); + + extern "C" fn finalizer(context: *mut c_void) { + // Retake the leaked context into box and then drop it. + let _ = unsafe { Box::from_raw(context as *mut AtomicBool) }; } + + // The `finalizer` is only run if the `context` in `queue` is set by `dispatch_set_context`. + dispatch_set_finalizer_f(queue, Some(finalizer)); } - fn touch(&mut self, who: u32) { - self.last_touched = Some(who); - self.touched_count += 1; + } + + fn release(&self) { + unsafe { + // This will release the inner `dispatch_queue_t` asynchronously. + // TODO: It's incredibly unsafe to call `transmute` directly. + // Find another way to release the queue. + dispatch_release(mem::transmute::( + self.0, + )); } } - fn get_queue_and_resource(label: &'static str, callback: F) + fn create_closure_and_executor(closure: F) -> (*mut c_void, dispatch_function_t) where - F: FnOnce(dispatch_queue_t, Arc>), + F: FnOnce(), { - let queue = create_dispatch_queue(label, DISPATCH_QUEUE_SERIAL); - let resource = Arc::new(Mutex::new(Resource::new())); + extern "C" fn closure_executer(unboxed_closure: *mut c_void) + where + F: FnOnce(), + { + // Retake the leaked closure. + let closure = unsafe { Box::from_raw(unboxed_closure as *mut F) }; + // Execute the closure. + (*closure)(); + // closure is released after finishing this function call. + } + + let closure = Box::new(closure); // Allocate closure on heap. + let executor: dispatch_function_t = Some(closure_executer::); + + ( + Box::into_raw(closure) as *mut c_void, // Leak the closure. + executor, + ) + } +} + +impl Drop for Queue { + fn drop(&mut self) { + self.release(); + } +} - callback(queue, resource); +impl Clone for Queue { + fn clone(&self) -> Self { + // TODO: It's incredibly unsafe to call `transmute` directly. + // Find another way to release the queue. + unsafe { + dispatch_retain(mem::transmute::( + self.0, + )); + } + Self(self.0) + } +} + +#[test] +fn run_tasks_in_order() { + let mut visited = Vec::::new(); + + // Rust compilter doesn't allow a pointer to be passed across threads. + // A hacky way to do that is to cast the pointer into a value, then + // the value, which is actually an address, can be copied into threads. + let ptr = &mut visited as *mut Vec as usize; + + fn visit(v: u32, visited_ptr: usize) { + let visited = unsafe { &mut *(visited_ptr as *mut Vec) }; + visited.push(v); + }; + + let queue = Queue::new("Run tasks in order"); - // Release the queue. - release_dispatch_queue(queue); + queue.run_sync(move || visit(1, ptr)); + queue.run_sync(move || visit(2, ptr)); + queue.run_async(move || visit(3, ptr)); + queue.run_async(move || visit(4, ptr)); + // Call sync here to block the current thread and make sure all the tasks are done. + queue.run_sync(move || visit(5, ptr)); + + assert_eq!(visited, vec![1, 2, 3, 4, 5]); +} + +#[test] +fn run_final_task() { + let mut visited = Vec::::new(); + + { + // Rust compilter doesn't allow a pointer to be passed across threads. + // A hacky way to do that is to cast the pointer into a value, then + // the value, which is actually an address, can be copied into threads. + let ptr = &mut visited as *mut Vec as usize; + + fn visit(v: u32, visited_ptr: usize) { + let visited = unsafe { &mut *(visited_ptr as *mut Vec) }; + visited.push(v); + }; + + let queue = Queue::new("Task after run_final will be cancelled"); + + queue.run_sync(move || visit(1, ptr)); + queue.run_async(move || visit(2, ptr)); + queue.run_final(move || visit(3, ptr)); + queue.run_async(move || visit(4, ptr)); + queue.run_sync(move || visit(5, ptr)); } + // `queue` will be dropped asynchronously and then the `finalizer` of the `queue` + // should be fired to clean up the `context` set in the `queue`. + + assert_eq!(visited, vec![1, 2, 3]); } diff --git a/third_party/rust/cubeb-coreaudio/.cargo-checksum.json b/third_party/rust/cubeb-coreaudio/.cargo-checksum.json index 1558663fd9e7f..56dfe83f309ca 100644 --- a/third_party/rust/cubeb-coreaudio/.cargo-checksum.json +++ b/third_party/rust/cubeb-coreaudio/.cargo-checksum.json @@ -1 +1 @@ -{"files":{".editorconfig":"4e53b182bcc78b83d7e1b5c03efa14d22d4955c4ed2514d1ba4e99c1eb1a50ba",".travis.yml":"878d9519da0844cd3de2999f81fce966452f0fb65150605c25a1abf3523360ab","Cargo.toml":"bcb3ec3785c3cbe799bb41c07176afdd0028328be79932a4e44bc97a364e8c69","LICENSE":"6e6f56aff5bbf3cbc60747e152fb1a719bd0716aaf6d711c554f57d92e96297c","README.md":"fa323b7386a8a0c75478b77a30a3c5d33f1df23d9775b97570fa0501ef784e95","install_rustfmt_clippy.sh":"4ae90d8dcb9757cb3ae4ae142ef80e5377c0dde61c63f4a3c32418646e80ca7b","run_sanitizers.sh":"913efec447b4c37751af93eef4a974f293426c20c720d37c5bbe69e955d105eb","run_tests.sh":"fcdae57b81426c5dbfc8873a9ff1ac07924ed0717f822b50a67934cac2e9d4f1","src/backend/aggregate_device.rs":"ae21129aa6b3c7bd3376751b6a94d1ebe6c9f7afcd1db3107fb4d703d04da6b3","src/backend/auto_array.rs":"5f35545baba2b005e13a2225bd1cbdd94ffc2097554d61479929bfc5442a6dd6","src/backend/auto_release.rs":"050fdcee74cf46b9a8a85a877e166d72a853d33220f59cf734cbb6ea09daa441","src/backend/device_property.rs":"324a7c9672daa49ee2221a56d140e1c8298719dab66f204b19d10f3632f96602","src/backend/mixer.rs":"0c237bd5ca63b028c4b22ddc5bc026d7e21c0fa9b4e337f00b6131ed0a0806a5","src/backend/mod.rs":"250cf24aabe1f1e9e8eafd375a538554523accaa6b514588b157d0c413d39b86","src/backend/resampler.rs":"fd1281d28a4db1659d2f75e43b8457651745e1b6eb5a53a77f04d752135f6dc7","src/backend/tests/aggregate_device.rs":"107f5c637844cd5ae43d2b42cec4ef3369bb702751586078c0a9d50f039161cd","src/backend/tests/api.rs":"d81128f0982ecc816666e91f57e722cc21ba9cc09a2a36103acc7c981f57b36d","src/backend/tests/backlog.rs":"3b189a7e036543c467cc242af0ed3332721179ee2b1c8847a6db563546f1ac52","src/backend/tests/device_change.rs":"2138e7ed4721872ce3a41f3652bfa4e7eca97fd136473af6472313c61ff24ed3","src/backend/tests/device_property.rs":"b1a9ae79aa5b9a3f180040d0ef0954b134680d586882d2062c5e017b555bff57","src/backend/tests/interfaces.rs":"14943e84a79976a7ef52882edeb9330350705d5190db6647f98b4ffa851a8396","src/backend/tests/manual.rs":"dc707836dab31f83d4b325afbc4dc4c8104ac8036e87f59ade3309ee83fe2d3f","src/backend/tests/mod.rs":"8dba770023d7f9c4228f0e11915347f0e07da5fd818e3ee4478c4b197af9aa2a","src/backend/tests/parallel.rs":"f9e1883660d6146b6e5075806561f5f689810e25c5e7764dfd28c9b939821a49","src/backend/tests/tone.rs":"16150438317ce501986734167b5fb97bfec567228acbcd8f3b4c4484c22f29e0","src/backend/tests/utils.rs":"1bb99ef71d3c18545bca49767e7b6bfffbe11896246994f41be7ed372772fd48","src/backend/utils.rs":"5ce1b753af0ffb654b6b2038d649aea88eebd27390a607a6d5988a9e40a4a717","src/capi.rs":"21b66b70545bf04ec719928004d1d9adb45b24ced51288f5b2993d79aaf78f5f","src/lib.rs":"5e586d45cd6b3722f0a6736d9252593299269817a153eef1930a5fb9bfbb56f5","todo.md":"29545b4d9c516396f82bd392797e2713d4602036eaba0f151b384af764f8515f"},"package":null} \ No newline at end of file +{"files":{".editorconfig":"4e53b182bcc78b83d7e1b5c03efa14d22d4955c4ed2514d1ba4e99c1eb1a50ba",".travis.yml":"878d9519da0844cd3de2999f81fce966452f0fb65150605c25a1abf3523360ab","Cargo.toml":"bcb3ec3785c3cbe799bb41c07176afdd0028328be79932a4e44bc97a364e8c69","LICENSE":"6e6f56aff5bbf3cbc60747e152fb1a719bd0716aaf6d711c554f57d92e96297c","README.md":"0d5a4c39e737aeeccfd5a54914e8927631ad86e3da8c24f62594f2f89a3302bf","install_rustfmt_clippy.sh":"4ae90d8dcb9757cb3ae4ae142ef80e5377c0dde61c63f4a3c32418646e80ca7b","run_device_tests.sh":"e66d32da5439818eee30fc5e7ed9ab9990723ffafe684870efe82dac11be07ef","run_sanitizers.sh":"54970203e86eed00245de3d9b53584d5d8868be983f90b27c603b310ba5554e5","run_tests.sh":"257ac9b30e0ff3775d713668a9704f15ad4ed2334aca7d8c544d079cde197e8a","src/backend/aggregate_device.rs":"ae21129aa6b3c7bd3376751b6a94d1ebe6c9f7afcd1db3107fb4d703d04da6b3","src/backend/auto_array.rs":"5f35545baba2b005e13a2225bd1cbdd94ffc2097554d61479929bfc5442a6dd6","src/backend/auto_release.rs":"050fdcee74cf46b9a8a85a877e166d72a853d33220f59cf734cbb6ea09daa441","src/backend/device_property.rs":"324a7c9672daa49ee2221a56d140e1c8298719dab66f204b19d10f3632f96602","src/backend/mixer.rs":"0c237bd5ca63b028c4b22ddc5bc026d7e21c0fa9b4e337f00b6131ed0a0806a5","src/backend/mod.rs":"e6ed4937f9ca52626a0ab6728631a88c9ae1369fd1ff61a377dfa64c3d406fb3","src/backend/resampler.rs":"fd1281d28a4db1659d2f75e43b8457651745e1b6eb5a53a77f04d752135f6dc7","src/backend/tests/aggregate_device.rs":"107f5c637844cd5ae43d2b42cec4ef3369bb702751586078c0a9d50f039161cd","src/backend/tests/api.rs":"58cbf67e3f4588f5e644ebcdc24942fcd6299c26f42a7e27fb4b6b9d8e5245f8","src/backend/tests/backlog.rs":"3b189a7e036543c467cc242af0ed3332721179ee2b1c8847a6db563546f1ac52","src/backend/tests/device_change.rs":"8261f561f69dabd374ac47d69aa484812b65070a9e9581dfb2605e8404eaad6d","src/backend/tests/device_property.rs":"b1a9ae79aa5b9a3f180040d0ef0954b134680d586882d2062c5e017b555bff57","src/backend/tests/interfaces.rs":"14943e84a79976a7ef52882edeb9330350705d5190db6647f98b4ffa851a8396","src/backend/tests/manual.rs":"dc707836dab31f83d4b325afbc4dc4c8104ac8036e87f59ade3309ee83fe2d3f","src/backend/tests/mod.rs":"8dba770023d7f9c4228f0e11915347f0e07da5fd818e3ee4478c4b197af9aa2a","src/backend/tests/parallel.rs":"f9e1883660d6146b6e5075806561f5f689810e25c5e7764dfd28c9b939821a49","src/backend/tests/tone.rs":"16150438317ce501986734167b5fb97bfec567228acbcd8f3b4c4484c22f29e0","src/backend/tests/utils.rs":"1bb99ef71d3c18545bca49767e7b6bfffbe11896246994f41be7ed372772fd48","src/backend/utils.rs":"5ce1b753af0ffb654b6b2038d649aea88eebd27390a607a6d5988a9e40a4a717","src/capi.rs":"21b66b70545bf04ec719928004d1d9adb45b24ced51288f5b2993d79aaf78f5f","src/lib.rs":"5e586d45cd6b3722f0a6736d9252593299269817a153eef1930a5fb9bfbb56f5","todo.md":"29545b4d9c516396f82bd392797e2713d4602036eaba0f151b384af764f8515f"},"package":null} \ No newline at end of file diff --git a/third_party/rust/cubeb-coreaudio/README.md b/third_party/rust/cubeb-coreaudio/README.md index 27ed5311072c4..0d7369e2bead6 100644 --- a/third_party/rust/cubeb-coreaudio/README.md +++ b/third_party/rust/cubeb-coreaudio/README.md @@ -43,14 +43,22 @@ by `sh run_sanitizers.sh`. The above command will run all the test suits in *run_tests.sh* by all the available _sanitizers_. However, it takes a long time for finshing the tests. -### Device Switching +### Device Tests + +Run `run_device_tests.sh`. + +If you'd like to run all the device tests with sanitizers, +use `RUSTFLAGS="-Z sanitizer=" sh run_device_tests.sh` +with valid `` such as `address` or `thread`. + +#### Device Switching The system default device will be changed during our tests. All the available devices will take turns being the system default device. However, after finishing the tests, the default device will be set to the original one. The sounds in the tests should be able to continue whatever the system default device is. -### Device Plugging/Unplugging +#### Device Plugging/Unplugging We implement APIs simulating plugging or unplugging a device by adding or removing an aggregate device programmatically. @@ -68,6 +76,15 @@ It's used to verify our callbacks for minitoring the system devices work. - Device collection change - `cargo test test_device_collection_change -- --ignored --nocapture` - Plug/Unplug devices to see events log. +- Manual Stream Tester + - `cargo test test_stream_tester -- --ignored --nocapture` + - `c` to create a stream + - `d` to destroy a stream + - `s` to start the created stream + - `t` to stop the created stream + - `q` to quit the test + - It's useful to simulate the stream bahavior to reproduce the bug we found, + with some modified code. ## TODO diff --git a/third_party/rust/cubeb-coreaudio/run_device_tests.sh b/third_party/rust/cubeb-coreaudio/run_device_tests.sh new file mode 100644 index 0000000000000..3ba18b46778d7 --- /dev/null +++ b/third_party/rust/cubeb-coreaudio/run_device_tests.sh @@ -0,0 +1,38 @@ +echo "\n\nRun device-changed tests\n====================" + +if [[ -z "${RUST_BACKTRACE}" ]]; then + # Display backtrace for debugging + export RUST_BACKTRACE=1 +fi +echo "RUST_BACKTRACE is set to ${RUST_BACKTRACE}\n" + +cargo test test_switch_device -- --ignored --nocapture +cargo test test_plug_and_unplug_device -- --ignored --nocapture +# cargo test test_register_device_changed_callback -- --ignored --nocapture --test-threads=1 +cargo test test_register_device_changed_callback_to_check_default_device_changed_input -- --ignored --nocapture +cargo test test_register_device_changed_callback_to_check_default_device_changed_output -- --ignored --nocapture +cargo test test_register_device_changed_callback_to_check_default_device_changed_duplex -- --ignored --nocapture +cargo test test_register_device_changed_callback_to_check_input_alive_changed_input -- --ignored --nocapture +cargo test test_register_device_changed_callback_to_check_input_alive_changed_duplex -- --ignored --nocapture + +cargo test test_destroy_input_stream_after_unplugging_a_nondefault_input_device -- --ignored --nocapture +cargo test test_destroy_input_stream_after_unplugging_a_default_input_device -- --ignored --nocapture +# FIXIT: The following test will hang since we don't monitor the alive status of the output device +# cargo test test_destroy_output_stream_after_unplugging_a_nondefault_output_device -- --ignored --nocapture +cargo test test_destroy_output_stream_after_unplugging_a_default_output_device -- --ignored --nocapture +cargo test test_destroy_duplex_stream_after_unplugging_a_nondefault_input_device -- --ignored --nocapture +cargo test test_destroy_duplex_stream_after_unplugging_a_default_input_device -- --ignored --nocapture +# FIXIT: The following test will hang since we don't monitor the alive status of the output device +# cargo test test_destroy_duplex_stream_after_unplugging_a_nondefault_output_device -- --ignored --nocapture +cargo test test_destroy_duplex_stream_after_unplugging_a_default_output_device -- --ignored --nocapture + +cargo test test_reinit_input_stream_by_unplugging_a_nondefault_input_device -- --ignored --nocapture +cargo test test_reinit_input_stream_by_unplugging_a_default_input_device -- --ignored --nocapture +# FIXIT: The following test will hang since we don't monitor the alive status of the output device +# cargo test test_reinit_output_stream_by_unplugging_a_nondefault_output_device -- --ignored --nocapture +cargo test test_reinit_output_stream_by_unplugging_a_default_output_device -- --ignored --nocapture +cargo test test_reinit_duplex_stream_by_unplugging_a_nondefault_input_device -- --ignored --nocapture +cargo test test_reinit_duplex_stream_by_unplugging_a_default_input_device -- --ignored --nocapture +# FIXIT: The following test will hang since we don't monitor the alive status of the output device +# cargo test test_reinit_duplex_stream_by_unplugging_a_nondefault_output_device -- --ignored --nocapture +cargo test test_reinit_duplex_stream_by_unplugging_a_default_output_device -- --ignored --nocapture diff --git a/third_party/rust/cubeb-coreaudio/run_sanitizers.sh b/third_party/rust/cubeb-coreaudio/run_sanitizers.sh index dd7036abbfab2..f0791a8bb1a74 100644 --- a/third_party/rust/cubeb-coreaudio/run_sanitizers.sh +++ b/third_party/rust/cubeb-coreaudio/run_sanitizers.sh @@ -6,42 +6,15 @@ toolchain=$(rustup default) echo "\nUse Rust toolchain: $toolchain" -if [[ $toolchain == nightly-* ]] -then - echo "Run sanitizers!" -else +if [[ $toolchain != nightly-* ]]; then echo "The sanitizer is only available on Rust Nightly only. Skip." exit fi -# Run tests in the sub crate -# ------------------------------------------------------------------------------------------------- -cd coreaudio-sys-utils - -echo "\n\nRun ASan\n-----------\n" -RUSTFLAGS="-Z sanitizer=address" cargo test - -echo "\n\nRun LSan\n-----------\n" -RUSTFLAGS="-Z sanitizer=leak" cargo test - -echo "\n\nRun MSan\n-----------\n" -RUSTFLAGS="-Z sanitizer=memory" cargo test - -echo "\n\nRun TSan\n-----------\n" -RUSTFLAGS="-Z sanitizer=thread" cargo test - -cd .. - -# Run tests in the main crate -# ------------------------------------------------------------------------------------------------- -echo "\n\nRun ASan\n-----------\n" -RUSTFLAGS="-Z sanitizer=address" sh run_tests.sh - -echo "\n\nRun LSan\n-----------\n" -RUSTFLAGS="-Z sanitizer=leak" sh run_tests.sh - -echo "\n\nRun MSan\n-----------\n" -RUSTFLAGS="-Z sanitizer=memory" sh run_tests.sh - -echo "\n\nRun TSan\n-----------\n" -RUSTFLAGS="-Z sanitizer=thread" sh run_tests.sh +sanitizers=("address" "leak" "memory" "thread") +for san in "${sanitizers[@]}" +do + San="$(tr '[:lower:]' '[:upper:]' <<< ${san:0:1})${san:1}" + echo "\n\nRun ${San}Sanitizer\n------------------------------" + RUSTFLAGS="-Z sanitizer=${san}" sh run_tests.sh +done diff --git a/third_party/rust/cubeb-coreaudio/run_tests.sh b/third_party/rust/cubeb-coreaudio/run_tests.sh index 8854ebab87be1..0a4b022691c0e 100644 --- a/third_party/rust/cubeb-coreaudio/run_tests.sh +++ b/third_party/rust/cubeb-coreaudio/run_tests.sh @@ -1,20 +1,30 @@ -# display backtrace for debugging -export RUST_BACKTRACE=1 +echo "\n\nTest suite for cubeb-coreaudio\n========================================" + +if [[ -z "${RUST_BACKTRACE}" ]]; then + # Display backtrace for debugging + export RUST_BACKTRACE=1 +fi +echo "RUST_BACKTRACE is set to ${RUST_BACKTRACE}\n" # Run tests in the sub crate +# Run the tests by `cargo * -p ` if it's possible. By doing so, the duplicate compiling +# between this crate and the can be saved. The compiling for can be reused +# when running `cargo *` with this crate. # ------------------------------------------------------------------------------------------------- -cd coreaudio-sys-utils +SUB_CRATE="coreaudio-sys-utils" # Format check +# `cargo fmt -p *` is only usable in workspaces, so a workaround is to enter to the sub crate +# and then exit from it. +cd $SUB_CRATE cargo fmt --all -- --check +cd .. # Lints check -cargo clippy -- -D warnings +cargo clippy -p $SUB_CRATE -- -D warnings # Regular Tests -cargo test - -cd .. +cargo test -p $SUB_CRATE # Run tests in the main crate # ------------------------------------------------------------------------------------------------- @@ -33,36 +43,7 @@ cargo test test_aggregate -- --ignored --test-threads=1 cargo test test_parallel -- --ignored --nocapture --test-threads=1 # Device-changed Tests -cargo test test_switch_device -- --ignored --nocapture -cargo test test_plug_and_unplug_device -- --ignored --nocapture -# cargo test test_register_device_changed_callback -- --ignored --nocapture --test-threads=1 -cargo test test_register_device_changed_callback_to_check_default_device_changed_input -- --ignored --nocapture -cargo test test_register_device_changed_callback_to_check_default_device_changed_output -- --ignored --nocapture -cargo test test_register_device_changed_callback_to_check_default_device_changed_duplex -- --ignored --nocapture -cargo test test_register_device_changed_callback_to_check_input_alive_changed_input -- --ignored --nocapture -cargo test test_register_device_changed_callback_to_check_input_alive_changed_duplex -- --ignored --nocapture - -cargo test test_destroy_input_stream_after_unplugging_a_nondefault_input_device -- --ignored --nocapture -cargo test test_destroy_input_stream_after_unplugging_a_default_input_device -- --ignored --nocapture -# FIXIT: The following test will hang since we don't monitor the alive status of the output device -# cargo test test_destroy_output_stream_after_unplugging_a_nondefault_output_device -- --ignored --nocapture -cargo test test_destroy_output_stream_after_unplugging_a_default_output_device -- --ignored --nocapture -cargo test test_destroy_duplex_stream_after_unplugging_a_nondefault_input_device -- --ignored --nocapture -cargo test test_destroy_duplex_stream_after_unplugging_a_default_input_device -- --ignored --nocapture -# FIXIT: The following test will hang since we don't monitor the alive status of the output device -# cargo test test_destroy_duplex_stream_after_unplugging_a_nondefault_output_device -- --ignored --nocapture -cargo test test_destroy_duplex_stream_after_unplugging_a_default_output_device -- --ignored --nocapture - -cargo test test_reinit_input_stream_by_unplugging_a_nondefault_input_device -- --ignored --nocapture -cargo test test_reinit_input_stream_by_unplugging_a_default_input_device -- --ignored --nocapture -# FIXIT: The following test will hang since we don't monitor the alive status of the output device -# cargo test test_reinit_output_stream_by_unplugging_a_nondefault_output_device -- --ignored --nocapture -cargo test test_reinit_output_stream_by_unplugging_a_default_output_device -- --ignored --nocapture -cargo test test_reinit_duplex_stream_by_unplugging_a_nondefault_input_device -- --ignored --nocapture -cargo test test_reinit_duplex_stream_by_unplugging_a_default_input_device -- --ignored --nocapture -# FIXIT: The following test will hang since we don't monitor the alive status of the output device -# cargo test test_reinit_duplex_stream_by_unplugging_a_nondefault_output_device -- --ignored --nocapture -cargo test test_reinit_duplex_stream_by_unplugging_a_default_output_device -- --ignored --nocapture +sh run_device_tests.sh # Manual Tests # cargo test test_switch_output_device -- --ignored --nocapture diff --git a/third_party/rust/cubeb-coreaudio/src/backend/mod.rs b/third_party/rust/cubeb-coreaudio/src/backend/mod.rs index 395551339daa6..d4755bc7efdd0 100644 --- a/third_party/rust/cubeb-coreaudio/src/backend/mod.rs +++ b/third_party/rust/cubeb-coreaudio/src/backend/mod.rs @@ -1597,8 +1597,8 @@ fn is_aggregate_device(device_info: &ffi::cubeb_device_info) -> bool { } } -fn audiounit_device_destroy(device: &mut ffi::cubeb_device_info) { - // This should be mapped to the memory allocation in audiounit_create_device_from_hwdev. +fn destroy_cubeb_device_info(device: &mut ffi::cubeb_device_info) { + // This should be mapped to the memory allocation in create_cubeb_device_info. // Set the pointers to null in case it points to some released memory. unsafe { if !device.device_id.is_null() { @@ -1696,12 +1696,12 @@ extern "C" fn audiounit_collection_changed_callback( ) -> OSStatus { let context = unsafe { &mut *(in_client_data as *mut AudioUnitContext) }; - let queue = context.serial_queue; + let queue = context.serial_queue.clone(); let mutexed_context = Arc::new(Mutex::new(context)); let also_mutexed_context = Arc::clone(&mutexed_context); // This can be called from inside an AudioUnit function, dispatch to another queue. - async_dispatch(queue, move || { + queue.run_async(move || { let ctx_guard = also_mutexed_context.lock().unwrap(); let ctx_ptr = *ctx_guard as *const AudioUnitContext; @@ -1849,10 +1849,7 @@ pub const OPS: Ops = capi_new!(AudioUnitContext, AudioUnitStream); #[derive(Debug)] pub struct AudioUnitContext { _ops: *const Ops, - // serial_queue will be created by dispatch_queue_create(create_dispatch_queue) - // without ARC(Automatic Reference Counting) support, so it should be released - // by dispatch_release(release_dispatch_queue). - serial_queue: dispatch_queue_t, + serial_queue: Queue, latency_controller: Mutex, devices: Mutex, } @@ -1861,7 +1858,7 @@ impl AudioUnitContext { fn new() -> Self { Self { _ops: &OPS as *const _, - serial_queue: create_dispatch_queue(DISPATCH_QUEUE_LABEL, DISPATCH_QUEUE_SERIAL), + serial_queue: Queue::new(DISPATCH_QUEUE_LABEL), latency_controller: Mutex::new(LatencyController::default()), devices: Mutex::new(SharedDevices::default()), } @@ -2098,7 +2095,7 @@ impl ContextOps for AudioUnitContext { let mut devices = retake_forgotten_vec(coll.device, coll.count); for device in &mut devices { - audiounit_device_destroy(device); + destroy_cubeb_device_info(device); } drop(devices); // Release the memory. coll.device = ptr::null_mut(); @@ -2168,6 +2165,10 @@ impl ContextOps for AudioUnitContext { global_latency_frames, )); + // Rename the task queue to be an unique label. + let queue_label = format!("{}.{:p}", DISPATCH_QUEUE_LABEL, boxed_stream.as_ref()); + boxed_stream.queue = Queue::new(queue_label.as_str()); + boxed_stream.core_stream_data = CoreStreamData::new(boxed_stream.as_ref(), in_stm_settings, out_stm_settings); @@ -2218,11 +2219,14 @@ impl Drop for AudioUnitContext { } } - // Unregister the callback if necessary. - self.remove_devices_changed_listener(DeviceType::INPUT); - self.remove_devices_changed_listener(DeviceType::OUTPUT); - - release_dispatch_queue(self.serial_queue); + // Make sure all the pending (device-collection-changed-callback) tasks + // in queue are done, and cancel all the tasks appended after `drop` is executed. + let queue = self.serial_queue.clone(); + queue.run_final(|| { + // Unregister the callback if necessary. + self.remove_devices_changed_listener(DeviceType::INPUT); + self.remove_devices_changed_listener(DeviceType::OUTPUT); + }); } } @@ -3071,6 +3075,8 @@ impl<'ctx> Drop for CoreStreamData<'ctx> { struct AudioUnitStream<'ctx> { context: &'ctx mut AudioUnitContext, user_ptr: *mut c_void, + // Task queue for the stream. + queue: Queue, data_callback: ffi::cubeb_data_callback, state_callback: ffi::cubeb_state_callback, @@ -3107,6 +3113,7 @@ impl<'ctx> AudioUnitStream<'ctx> { AudioUnitStream { context, user_ptr, + queue: Queue::new(DISPATCH_QUEUE_LABEL), data_callback, state_callback, device_changed_callback: Mutex::new(None), @@ -3266,12 +3273,12 @@ impl<'ctx> AudioUnitStream<'ctx> { return; } - let queue = self.context.serial_queue; + let queue = self.queue.clone(); let mutexed_stm = Arc::new(Mutex::new(self)); let also_mutexed_stm = Arc::clone(&mutexed_stm); // Use a new thread, through the queue, to avoid deadlock when calling // Get/SetProperties method from inside notify callback - async_dispatch(queue, move || { + queue.run_async(move || { let mut stm_guard = also_mutexed_stm.lock().unwrap(); let stm_ptr = *stm_guard as *const AudioUnitStream; if stm_guard.destroy_pending.load(Ordering::SeqCst) { @@ -3327,12 +3334,12 @@ impl<'ctx> AudioUnitStream<'ctx> { // Execute the stream destroy work. self.destroy_pending.store(true, Ordering::SeqCst); - let queue = self.context.serial_queue; + let queue = self.queue.clone(); let stream_ptr = self as *const AudioUnitStream; // Execute close in serial queue to avoid collision // with reinit when un/plug devices - sync_dispatch(queue, move || { + queue.run_final(move || { // Call stop_audiounits to avoid potential data race. If there is a running data callback, // which locks a mutex inside CoreAudio framework, then this call will block the current // thread until the callback is finished since this call asks to lock a mutex inside @@ -3361,11 +3368,10 @@ impl<'ctx> StreamOps for AudioUnitStream<'ctx> { self.draining.store(false, Ordering::SeqCst); // Execute start in serial queue to avoid racing with destroy or reinit. - let queue = self.context.serial_queue; let mut result = Err(Error::error()); let started = &mut result; let stream = &self; - sync_dispatch(queue, move || { + self.queue.run_sync(move || { *started = stream.core_stream_data.start_audiounits(); }); @@ -3385,9 +3391,8 @@ impl<'ctx> StreamOps for AudioUnitStream<'ctx> { self.shutdown.store(true, Ordering::SeqCst); // Execute stop in serial queue to avoid racing with destroy or reinit. - let queue = self.context.serial_queue; let stream = &self; - sync_dispatch(queue, move || { + self.queue.run_sync(move || { stream.core_stream_data.stop_audiounits(); }); diff --git a/third_party/rust/cubeb-coreaudio/src/backend/tests/api.rs b/third_party/rust/cubeb-coreaudio/src/backend/tests/api.rs index da26f500a0a5f..6f39b1e81b398 100644 --- a/third_party/rust/cubeb-coreaudio/src/backend/tests/api.rs +++ b/third_party/rust/cubeb-coreaudio/src/backend/tests/api.rs @@ -1355,24 +1355,22 @@ fn test_create_cubeb_device_info() { let mut results = test_create_device_infos_by_device(device); assert_eq!(results.len(), 2); // Input device type: + let input_result = results.pop_front().unwrap(); if is_input { - check_device_info_by_device( - results.pop_front().unwrap().unwrap(), - device, - Scope::Input, - ); + let mut input_device_info = input_result.unwrap(); + check_device_info_by_device(&input_device_info, device, Scope::Input); + destroy_cubeb_device_info(&mut input_device_info); } else { - assert_eq!(results.pop_front().unwrap().unwrap_err(), Error::error()); + assert_eq!(input_result.unwrap_err(), Error::error()); } // Output device type: + let output_result = results.pop_front().unwrap(); if is_output { - check_device_info_by_device( - results.pop_front().unwrap().unwrap(), - device, - Scope::Output, - ); + let mut output_device_info = output_result.unwrap(); + check_device_info_by_device(&output_device_info, device, Scope::Output); + destroy_cubeb_device_info(&mut output_device_info); } else { - assert_eq!(results.pop_front().unwrap().unwrap_err(), Error::error()); + assert_eq!(output_result.unwrap_err(), Error::error()); } } else { println!("No device for {:?}.", scope); @@ -1390,7 +1388,7 @@ fn test_create_cubeb_device_info() { results } - fn check_device_info_by_device(info: ffi::cubeb_device_info, id: AudioObjectID, scope: Scope) { + fn check_device_info_by_device(info: &ffi::cubeb_device_info, id: AudioObjectID, scope: Scope) { assert!(!info.devid.is_null()); assert!(mem::size_of_val(&info.devid) >= mem::size_of::()); assert_eq!(info.devid as AudioObjectID, id); @@ -1486,7 +1484,7 @@ fn test_is_aggregate_device() { assert!(!is_aggregate_device(&info)); } -// device_destroy +// destroy_cubeb_device_info // ------------------------------------ #[test] fn test_device_destroy() { @@ -1502,7 +1500,7 @@ fn test_device_destroy() { device.friendly_name = friendly_name.into_raw(); device.vendor_name = vendor_name.into_raw(); - audiounit_device_destroy(&mut device); + destroy_cubeb_device_info(&mut device); assert!(device.device_id.is_null()); assert!(device.group_id.is_null()); @@ -1514,24 +1512,9 @@ fn test_device_destroy() { #[should_panic] fn test_device_destroy_with_different_device_id_and_group_id() { let mut device = ffi::cubeb_device_info::default(); - - let device_id = CString::new("test: device id").unwrap(); - let group_id = CString::new("test: group id").unwrap(); - let friendly_name = CString::new("test: friendly name").unwrap(); - let vendor_name = CString::new("test: vendor name").unwrap(); - - device.device_id = device_id.into_raw(); - device.group_id = group_id.into_raw(); - device.friendly_name = friendly_name.into_raw(); - device.vendor_name = vendor_name.into_raw(); - - audiounit_device_destroy(&mut device); - // Hit the assertion above, so we will leak some memory allocated for the above cstring. - - assert!(device.device_id.is_null()); - assert!(device.group_id.is_null()); - assert!(device.friendly_name.is_null()); - assert!(device.vendor_name.is_null()); + device.device_id = 0xdeaddead as *const _; + device.group_id = 0xdeadbeef as *const _; + destroy_cubeb_device_info(&mut device); } #[test] @@ -1543,7 +1526,7 @@ fn test_device_destroy_empty_device() { assert!(device.friendly_name.is_null()); assert!(device.vendor_name.is_null()); - audiounit_device_destroy(&mut device); + destroy_cubeb_device_info(&mut device); assert!(device.device_id.is_null()); assert!(device.group_id.is_null()); diff --git a/third_party/rust/cubeb-coreaudio/src/backend/tests/device_change.rs b/third_party/rust/cubeb-coreaudio/src/backend/tests/device_change.rs index 5f08bcad3527d..f506bb8d7b0d4 100644 --- a/third_party/rust/cubeb-coreaudio/src/backend/tests/device_change.rs +++ b/third_party/rust/cubeb-coreaudio/src/backend/tests/device_change.rs @@ -32,18 +32,18 @@ fn test_switch_device() { } fn test_switch_device_in_scope(scope: Scope) { + println!( + "Switch default device for {:?} while the stream is working.", + scope + ); + // Do nothing if there is no 2 available devices at least. let devices = test_get_devices_in_scope(scope.clone()); if devices.len() < 2 { - println!("Need 2 devices for {:?} at least.", scope); + println!("Need 2 devices for {:?} at least. Skip.", scope); return; } - println!( - "Switch default device for {:?} while the stream is working.", - scope - ); - let mut device_switcher = TestDeviceSwitcher::new(scope.clone()); let count = Arc::new(Mutex::new(0)); diff --git a/third_party/rust/nom/.cargo-checksum.json b/third_party/rust/nom/.cargo-checksum.json index 262350f0269c1..b236aa3bb55cd 100644 --- a/third_party/rust/nom/.cargo-checksum.json +++ b/third_party/rust/nom/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"CHANGELOG.md":"f4015ae48bb8f7c672c4fdf1ca4bdde5910f1b423ddc12e9fe80395911759d3e","Cargo.lock":"d7985e783bf7275009ab524f13aac37adc7291838a1956e1f092413ff3b8ea04","Cargo.toml":"72afa6607971579c7009dff34b6b334d4893b1a9f1983cd80364c5e318e4ec2b","LICENSE":"4dbda04344456f09a7a588140455413a9ac59b6b26a1ef7cdf9c800c012d87f0","build.rs":"fd66799ca3bd6a83b10f18a62e6ffc3b1ac94074fe65de4e4c1c447bf71d6ebb","src/bits/complete.rs":"8a60ae4cd6aaf32cb232b598b1a3dda7858c619944ba12ebdb01a31c75243293","src/bits/macros.rs":"8d9ba23f237b4fc01e3b2106002d0f6d59930a42f34d80662c61e0057dfb4a5b","src/bits/mod.rs":"4ca0148b4ef2de4e88796da7831eaa5c4fcbc5515a101eae1b0bc4853c80b5e7","src/bits/streaming.rs":"7c587808476edee57caeccca7dccd744bdfdbb13ae1156400fb4961980fa325d","src/branch/macros.rs":"8b885185725c16369d90954fed8450070bcd4bf8ae7de1df1bb46bb378450d71","src/branch/mod.rs":"d0c871ad7b74428ddccef445a10254249c3907528005a00275e8eb6516255f2f","src/bytes/complete.rs":"107f776885161e48a596962925d2b1628f20fd4bbe5b3777bb34ec175b97e280","src/bytes/macros.rs":"914a821761bbf49f04425068b7426bdd60394e8cc30e7c2193160b16e06c266f","src/bytes/mod.rs":"577231e6e6bd51726a877a73292d8f1c626f6b32ebe4a57943acaed8a8a2975d","src/bytes/streaming.rs":"4b2e577e6057fda932d1edc2ebe53c5df71a21417a304b35d5230dd7221411f3","src/character/complete.rs":"bb80656f3405eca79ba93c674cae7cd296733d784928e5c45754ee27963b7325","src/character/macros.rs":"f330ab60d469802b1664dcbbccd4bfe3e1ca87b348e92609ef34e25b4d475983","src/character/mod.rs":"9f520d535a88849726eac8648aa5c8b86193ab2f3a984d63c8371b846cc0b72c","src/character/streaming.rs":"9be7051951e8d0a54e294542baaf115aeb6efb818521f045386cd3a1777ca6a0","src/combinator/macros.rs":"df9ba1157bda21313a9c23826baeefd99f54e92c47d60c8dbb25697fe4d52686","src/combinator/mod.rs":"d1b2073683be1c9c4a06d1d3764ac789027ad7401ec726805d1505c1ad8ab1fd","src/error.rs":"ef7feb06b9689aa2f4b11a367b6f7058df8fd151b673c7482edd6600e55e38da","src/internal.rs":"c4029b0e32d41eb6407e517f3102a41a3a80a6a69df4767008ac5656b28d7ab0","src/lib.rs":"f01cdc23cc17201f978796d2d80fb6bba5a9b81ffb4653286e1e53f904079911","src/methods.rs":"56099c30123e92f9f6bacb16017f29fcdbc6546afbf0f80cf4951d2d8093ba83","src/multi/macros.rs":"01d15ae913921bd1ed0ff579a868ea39a314a866e6b5a365ef6b448a75f9b3a8","src/multi/mod.rs":"342c30e0c601558c867df215f7094bc9e43534a7793f2e8b19c114fe07cfea41","src/number/complete.rs":"560dfb2ffbbfe7fe276389b60eec2d717fec20eab68cc72d10d87ff6e2195352","src/number/macros.rs":"e614ee142658c126902a466f29ef250a77016fa126b8dfd59db0c6657a0ef205","src/number/mod.rs":"e432c317ee839a2f928cd0e8e583acadb165ed84fb649e681688a0fcd84b0a75","src/number/streaming.rs":"4c6fbce64e0d535f69d2c928314e1d0a019480db5a09e4f47a654a2e8fd56e8c","src/regexp.rs":"ac6fc61c2e7b629e6786638b44d63d15139c50f9d6a38acd044e4c2b3a699e08","src/sequence/macros.rs":"0e72871cdb2f1bf804f7f637def117c8e531f78cc7da5a6a0e343f0dbfb04271","src/sequence/mod.rs":"ec34b969462703252c4f00c27a03928c9580da612c71b7100e0902190a633ab9","src/str.rs":"fcae4d6f2f7bc921cafe3d0ce682d0566618cbe5f3b3e4b51ca34d11cb0e3e93","src/traits.rs":"2a84c3aa40f1cf78e0149e344da8b85486f7b6c0ddff8f23689bccce0def2260","src/util.rs":"bcedca3c88ac24f11f73e836efd8fe00014562163cc3d43d0cec9d726a4687c3","src/whitespace.rs":"53bddd9d559dc7793effcb828f9c196a7f098338edb0877940d1246834761308","tests/arithmetic.rs":"c57bc547110e498e7bddc973a94202f22356bc525fed55dac4f03daf16eb54f7","tests/arithmetic_ast.rs":"8fbc4c5d8850fa1cf0a16f97e8718d5427b2657f12ca4a0b3b6c1b47fd9e67d4","tests/blockbuf-arithmetic.rs":"099fdf75da97ae032006d8c82ea2207265c5161a08d1370e1ddddb01e73afaf4","tests/css.rs":"b13466eb6a0831f98ede83ffdd752ba821f7d03db724fd92b5bfbc0b9f804a65","tests/custom_errors.rs":"3d2511f8a8d0eb20d9efc19f29ae4ab34389bdd33214a421989d0c47b540b7fd","tests/escaped.rs":"03ecb10828472e4de2ace05a12cb49997b47a113b6a3b0eea3d56bc2bafd8446","tests/float.rs":"92947cc112a6b865f5e19d80edbf300ddc0d0ca4b4e4543eda15337b5c60eedf","tests/inference.rs":"fe476d1367fce9f0baf82295dc037c79321ededf12b9bcc0c5acdc7cefff4720","tests/ini.rs":"04ebf3ead0008974b3bedc387e889bab5942efd0c9c8563fe47e056a9b90bbab","tests/ini_str.rs":"2831a4ee26b37734dba8862cc2972a3a1433abf4fcab253b6cf4fb43f120301d","tests/issues.rs":"142c8d206089b04cf2fd0cbd90f87421ded435ce300516c029294b056354e00f","tests/json.rs":"25476ec2daca19295f5f99b621eecc859a5db5789ac35be381eaf8703a70bce8","tests/mp4.rs":"d0e61bfc93ff40676ca7e9d7813a5ad7c73b1db874599d8f3ea784115bfcab87","tests/multiline.rs":"6a5321cb53c7f88778fa100499533abfa602bada7a6b1d0fbba7ef77b9c110f5","tests/named_args.rs":"bd8095c3abc6fb806c9181c6025c0111d1e7f3b7269ea89ae122bf3bb8ed7e7d","tests/overflow.rs":"d1d6d8ce9b34ed47b42a5f7250ce711805a397691dc6cad3cc8945ec230da161","tests/reborrow_fold.rs":"9328deafc2143c2a2d1a0be86e2448b644cffcb5f0935c8b24eb469f1f9477c0","tests/test1.rs":"06fc9e52638f16bfc3ef69cd26b927e0cf55706d6f132ab7c0f1072208475853"},"package":"0b471253da97532da4b61552249c521e01e736071f71c1a4f7ebbfbf0a06aad6"} \ No newline at end of file +{"files":{".travis.yml":"124c5613de02fe2088a7410a7057b0e0ed49dcbc8509704b690de98e83b289e0","CHANGELOG.md":"f4015ae48bb8f7c672c4fdf1ca4bdde5910f1b423ddc12e9fe80395911759d3e","Cargo.lock":"d7985e783bf7275009ab524f13aac37adc7291838a1956e1f092413ff3b8ea04","Cargo.toml":"72afa6607971579c7009dff34b6b334d4893b1a9f1983cd80364c5e318e4ec2b","LICENSE":"4dbda04344456f09a7a588140455413a9ac59b6b26a1ef7cdf9c800c012d87f0","build.rs":"fd66799ca3bd6a83b10f18a62e6ffc3b1ac94074fe65de4e4c1c447bf71d6ebb","src/bits/complete.rs":"8a60ae4cd6aaf32cb232b598b1a3dda7858c619944ba12ebdb01a31c75243293","src/bits/macros.rs":"8d9ba23f237b4fc01e3b2106002d0f6d59930a42f34d80662c61e0057dfb4a5b","src/bits/mod.rs":"4ca0148b4ef2de4e88796da7831eaa5c4fcbc5515a101eae1b0bc4853c80b5e7","src/bits/streaming.rs":"7c587808476edee57caeccca7dccd744bdfdbb13ae1156400fb4961980fa325d","src/branch/macros.rs":"8b885185725c16369d90954fed8450070bcd4bf8ae7de1df1bb46bb378450d71","src/branch/mod.rs":"d0c871ad7b74428ddccef445a10254249c3907528005a00275e8eb6516255f2f","src/bytes/complete.rs":"107f776885161e48a596962925d2b1628f20fd4bbe5b3777bb34ec175b97e280","src/bytes/macros.rs":"914a821761bbf49f04425068b7426bdd60394e8cc30e7c2193160b16e06c266f","src/bytes/mod.rs":"577231e6e6bd51726a877a73292d8f1c626f6b32ebe4a57943acaed8a8a2975d","src/bytes/streaming.rs":"4b2e577e6057fda932d1edc2ebe53c5df71a21417a304b35d5230dd7221411f3","src/character/complete.rs":"bb80656f3405eca79ba93c674cae7cd296733d784928e5c45754ee27963b7325","src/character/macros.rs":"f330ab60d469802b1664dcbbccd4bfe3e1ca87b348e92609ef34e25b4d475983","src/character/mod.rs":"9f520d535a88849726eac8648aa5c8b86193ab2f3a984d63c8371b846cc0b72c","src/character/streaming.rs":"9be7051951e8d0a54e294542baaf115aeb6efb818521f045386cd3a1777ca6a0","src/combinator/macros.rs":"df9ba1157bda21313a9c23826baeefd99f54e92c47d60c8dbb25697fe4d52686","src/combinator/mod.rs":"d1b2073683be1c9c4a06d1d3764ac789027ad7401ec726805d1505c1ad8ab1fd","src/error.rs":"ef7feb06b9689aa2f4b11a367b6f7058df8fd151b673c7482edd6600e55e38da","src/internal.rs":"c4029b0e32d41eb6407e517f3102a41a3a80a6a69df4767008ac5656b28d7ab0","src/lib.rs":"f01cdc23cc17201f978796d2d80fb6bba5a9b81ffb4653286e1e53f904079911","src/methods.rs":"56099c30123e92f9f6bacb16017f29fcdbc6546afbf0f80cf4951d2d8093ba83","src/multi/macros.rs":"01d15ae913921bd1ed0ff579a868ea39a314a866e6b5a365ef6b448a75f9b3a8","src/multi/mod.rs":"342c30e0c601558c867df215f7094bc9e43534a7793f2e8b19c114fe07cfea41","src/number/complete.rs":"560dfb2ffbbfe7fe276389b60eec2d717fec20eab68cc72d10d87ff6e2195352","src/number/macros.rs":"e614ee142658c126902a466f29ef250a77016fa126b8dfd59db0c6657a0ef205","src/number/mod.rs":"e432c317ee839a2f928cd0e8e583acadb165ed84fb649e681688a0fcd84b0a75","src/number/streaming.rs":"4c6fbce64e0d535f69d2c928314e1d0a019480db5a09e4f47a654a2e8fd56e8c","src/regexp.rs":"ac6fc61c2e7b629e6786638b44d63d15139c50f9d6a38acd044e4c2b3a699e08","src/sequence/macros.rs":"0e72871cdb2f1bf804f7f637def117c8e531f78cc7da5a6a0e343f0dbfb04271","src/sequence/mod.rs":"ec34b969462703252c4f00c27a03928c9580da612c71b7100e0902190a633ab9","src/str.rs":"fcae4d6f2f7bc921cafe3d0ce682d0566618cbe5f3b3e4b51ca34d11cb0e3e93","src/traits.rs":"2a84c3aa40f1cf78e0149e344da8b85486f7b6c0ddff8f23689bccce0def2260","src/util.rs":"bcedca3c88ac24f11f73e836efd8fe00014562163cc3d43d0cec9d726a4687c3","src/whitespace.rs":"53bddd9d559dc7793effcb828f9c196a7f098338edb0877940d1246834761308","tests/arithmetic.rs":"c57bc547110e498e7bddc973a94202f22356bc525fed55dac4f03daf16eb54f7","tests/arithmetic_ast.rs":"8fbc4c5d8850fa1cf0a16f97e8718d5427b2657f12ca4a0b3b6c1b47fd9e67d4","tests/blockbuf-arithmetic.rs":"099fdf75da97ae032006d8c82ea2207265c5161a08d1370e1ddddb01e73afaf4","tests/css.rs":"b13466eb6a0831f98ede83ffdd752ba821f7d03db724fd92b5bfbc0b9f804a65","tests/custom_errors.rs":"3d2511f8a8d0eb20d9efc19f29ae4ab34389bdd33214a421989d0c47b540b7fd","tests/escaped.rs":"03ecb10828472e4de2ace05a12cb49997b47a113b6a3b0eea3d56bc2bafd8446","tests/float.rs":"92947cc112a6b865f5e19d80edbf300ddc0d0ca4b4e4543eda15337b5c60eedf","tests/inference.rs":"fe476d1367fce9f0baf82295dc037c79321ededf12b9bcc0c5acdc7cefff4720","tests/ini.rs":"04ebf3ead0008974b3bedc387e889bab5942efd0c9c8563fe47e056a9b90bbab","tests/ini_str.rs":"2831a4ee26b37734dba8862cc2972a3a1433abf4fcab253b6cf4fb43f120301d","tests/issues.rs":"142c8d206089b04cf2fd0cbd90f87421ded435ce300516c029294b056354e00f","tests/json.rs":"25476ec2daca19295f5f99b621eecc859a5db5789ac35be381eaf8703a70bce8","tests/mp4.rs":"d0e61bfc93ff40676ca7e9d7813a5ad7c73b1db874599d8f3ea784115bfcab87","tests/multiline.rs":"6a5321cb53c7f88778fa100499533abfa602bada7a6b1d0fbba7ef77b9c110f5","tests/named_args.rs":"bd8095c3abc6fb806c9181c6025c0111d1e7f3b7269ea89ae122bf3bb8ed7e7d","tests/overflow.rs":"d1d6d8ce9b34ed47b42a5f7250ce711805a397691dc6cad3cc8945ec230da161","tests/reborrow_fold.rs":"9328deafc2143c2a2d1a0be86e2448b644cffcb5f0935c8b24eb469f1f9477c0","tests/test1.rs":"06fc9e52638f16bfc3ef69cd26b927e0cf55706d6f132ab7c0f1072208475853"},"package":"0b471253da97532da4b61552249c521e01e736071f71c1a4f7ebbfbf0a06aad6"} \ No newline at end of file diff --git a/third_party/rust/nom/.travis.yml b/third_party/rust/nom/.travis.yml new file mode 100644 index 0000000000000..e18b14079ddde --- /dev/null +++ b/third_party/rust/nom/.travis.yml @@ -0,0 +1,101 @@ +language: rust +# sudo is required to enable kcov to use the personality syscall +sudo: required +dist: trusty +cache: cargo + +rust: + - nightly + - beta + - stable + - 1.31.0 + +env: + matrix: + - FEATURES='--features "regexp regexp_macros"' + +before_script: + - eval git pull --rebase https://github.com/Geal/nom master + - eval git log --pretty=oneline HEAD~5..HEAD + +matrix: + include: + - rust: nightly + env: FEATURES='--no-default-features' + - rust: nightly + env: FEATURES='--no-default-features --features "alloc"' + - rust: stable + env: FEATURES='' + - rust: nightly + env: DOC_FEATURES='--features "std lexical regexp regexp_macros" --no-default-features' + before_script: + - export PATH=$HOME/.cargo/bin:$PATH + script: + - eval cargo doc --verbose $DOC_FEATURES + - rust: nightly + env: FEATURES='' + before_script: + - export PATH=$HOME/.cargo/bin:$PATH + - cargo install cargo-update || echo "cargo-update already installed" + - cargo install cargo-travis || echo "cargo-travis already installed" + - cargo install-update -a + - mkdir -p target/kcov-master + script: + cargo coveralls --verbose --all-features + allow_failures: + - rust: stable + env: FEATURES='' + before_script: + - export PATH=$HOME/.cargo/bin:$PATH + - rustup component add rustfmt-preview + script: + - eval cargo fmt -- --write-mode=diff + +notifications: + webhooks: + urls: + - https://webhooks.gitter.im/e/9c035a194ac4fd4cc061 + on_success: change + on_failure: always + on_start: false + + +addons: + apt: + packages: + - libcurl4-openssl-dev + - libelf-dev + - libdw-dev + - binutils-dev + - cmake + sources: + - kalakris-cmake + +cache: + directories: + - /home/travis/.cargo + +before_cache: + - rm -rf /home/travis/.cargo/registry + +script: + - eval cargo build --verbose $FEATURES + - eval cargo test --verbose $FEATURES + +after_success: | + case "$TRAVIS_RUST_VERSION" in + nightly) + if [ "${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}" != "master" ]; then + git fetch && + git checkout master && + cargo bench --verbose + fi + + if [ "$FEATURES" == '--features "regexp regexp_macros"' ]; then + cargo bench --verbose + fi + ;; + + *) + ;; + esac diff --git a/toolkit/library/rust/shared/Cargo.toml b/toolkit/library/rust/shared/Cargo.toml index 8f0d6f219fce9..85e0a223662db 100644 --- a/toolkit/library/rust/shared/Cargo.toml +++ b/toolkit/library/rust/shared/Cargo.toml @@ -19,7 +19,7 @@ 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", optional = true } -cubeb-coreaudio = { git = "https://github.com/ChunMinChang/cubeb-coreaudio-rs", rev = "4acd80233efa645ac79769f37b07d495c1b42070", optional = true } +cubeb-coreaudio = { git = "https://github.com/ChunMinChang/cubeb-coreaudio-rs", rev = "799518a033a0c780cfdb82a4eaabfd9681cb7f3b", optional = true } cubeb-pulse = { git = "https://github.com/djg/cubeb-pulse-rs", rev="8069f8f4189982e0b38fa6dc8993dd4fab41f728", optional = true, features=["pulse-dlopen"] } cubeb-sys = { version = "0.6", optional = true, features=["gecko-in-tree"] } encoding_glue = { path = "../../../../intl/encoding_glue" }