mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1721496 - P2: mach vendor rust r=cubeb-reviewers,kinetik
Run `cargo update -p cubeb-coreaudio && ./mach vendor rust --ignore-modified` to update `cubeb-coreaudio` Differential Revision: https://phabricator.services.mozilla.com/D121121
This commit is contained in:
parent
c3bf16d054
commit
d162ad4e76
@ -30,7 +30,7 @@ rev = "c87b50aebfa088c1ad30c74819d4e9829f88b2e3"
|
||||
[source."https://github.com/mozilla/cubeb-coreaudio-rs"]
|
||||
git = "https://github.com/mozilla/cubeb-coreaudio-rs"
|
||||
replace-with = "vendored-sources"
|
||||
rev = "ad56ea14ac915f1e7ecbcf6ac38182443b0dd29e"
|
||||
rev = "8ae48c16b637d6d9a841cf4d01de06c16b1318b0"
|
||||
|
||||
[source."https://github.com/mozilla/audioipc-2"]
|
||||
git = "https://github.com/mozilla/audioipc-2"
|
||||
|
@ -1 +1 @@
|
||||
{"files":{"Cargo.toml":"561897801935609ec7bb9936e40ed969072067c7c9102303e65e27f664b38596","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}
|
||||
{"files":{"Cargo.toml":"561897801935609ec7bb9936e40ed969072067c7c9102303e65e27f664b38596","src/aggregate_device.rs":"7d2bd5f5fd7f3d008ebb69ad81f522ca0cb73db6d7b3e50ed1a63ea26ff721f4","src/audio_object.rs":"df10160d9fd83a2c23a49e69b78d39db3a9d6389607df6acfc05821293b6af5f","src/audio_unit.rs":"d783878930df4923b57ad230138c0f3fd6b0b9bb80a39725092ff4c6615162d8","src/cf_mutable_dict.rs":"fc42edd270c6dfb02f123214d2d8e487bbd62b5bd923b71eec13190fd0104d2a","src/dispatch.rs":"82ca429be8f930db730c7c571d6f2246e59e82ecb220b5290a3cf4a53e997053","src/lib.rs":"bcc559d69ef6ed0cbea5b2a36fec89d8c011eb9da70e2f26c00f881ad97a2546","src/string.rs":"28f88b816c768bcfcc674a60d962b93f1c94e5e0f4cc8ed2a1301138b91039e7"},"package":null}
|
@ -162,7 +162,7 @@ fn run_tasks_in_order() {
|
||||
fn visit(v: u32, visited_ptr: usize) {
|
||||
let visited = unsafe { &mut *(visited_ptr as *mut Vec<u32>) };
|
||||
visited.push(v);
|
||||
};
|
||||
}
|
||||
|
||||
let queue = Queue::new("Run tasks in order");
|
||||
|
||||
@ -189,7 +189,7 @@ fn run_final_task() {
|
||||
fn visit(v: u32, visited_ptr: usize) {
|
||||
let visited = unsafe { &mut *(visited_ptr as *mut Vec<u32>) };
|
||||
visited.push(v);
|
||||
};
|
||||
}
|
||||
|
||||
let queue = Queue::new("Task after run_final will be cancelled");
|
||||
|
||||
|
@ -1 +1 @@
|
||||
{"files":{".editorconfig":"4e53b182bcc78b83d7e1b5c03efa14d22d4955c4ed2514d1ba4e99c1eb1a50ba",".githooks/pre-push":"8b8b26544cd56f54c0c33812551f786bb25cb08c86dbfeb6bf3daad881c826a1",".travis.yml":"dc07bac53f70f16c9bdf52264bdc58500ae6018c1b4c567bc7642f6b4ca3cc35","Cargo.toml":"6170d7b1c191efee92f0b43c024633cd12addfddaa57babdda23af846e1cb06c","LICENSE":"6e6f56aff5bbf3cbc60747e152fb1a719bd0716aaf6d711c554f57d92e96297c","README.md":"ab4db97d4be44b905ac136d6da83c6c2f50fa0d1e4f447e99de9184b85c6111a","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":"2aaaa721506d3c15007809336c973f7ed465d2239a82171a4dc9463fc5ca294e","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":"4331745812a2bfb848af59a9502bdc60645985c53ae97aa8f821e5975fef96ca","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":{".circleci/config.yml":"d4cc7b4bb63184850b8e472884bf867f462024da7aac0dcb9d6f056ea77ccc08",".editorconfig":"4e53b182bcc78b83d7e1b5c03efa14d22d4955c4ed2514d1ba4e99c1eb1a50ba",".githooks/pre-push":"8b8b26544cd56f54c0c33812551f786bb25cb08c86dbfeb6bf3daad881c826a1",".github/workflows/test.yml":"aa1998a3b104ad131805ca3513832cef3f65300192824f8b1efc9a5a0cc108f6",".travis.yml":"dc07bac53f70f16c9bdf52264bdc58500ae6018c1b4c567bc7642f6b4ca3cc35","Cargo.toml":"6170d7b1c191efee92f0b43c024633cd12addfddaa57babdda23af846e1cb06c","LICENSE":"6e6f56aff5bbf3cbc60747e152fb1a719bd0716aaf6d711c554f57d92e96297c","README.md":"910d2d7abf59658060651ad0e762ec812e3bc14f562d974f330696c5fd23d5fd","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":"8828c73439dfd540cd21fc713c4a1011ec05baca6f282f285743f310ace39563","run_tests.sh":"916a7ae4a406d2274417d6eca939a878db5adcb6144e5680d9d148bf90178f1c","src/backend/aggregate_device.rs":"e153a39c4c4884951e3fe70566b891f1bf96fe0d3d7567b33b4027043c54148c","src/backend/auto_release.rs":"050fdcee74cf46b9a8a85a877e166d72a853d33220f59cf734cbb6ea09daa441","src/backend/buffer_manager.rs":"fc3998116b8734debe2a0ffe90f89271cb7e9e1b49e4d1ec62d99a67e18f956c","src/backend/device_property.rs":"d43642ea6e5f40e29c2a59ec7d81b42c154134685e417585045785359aa31686","src/backend/mixer.rs":"949c34927ba72b3365bc733a63b2f7950aef707ee08363f97242a4de6b7d4818","src/backend/mod.rs":"89b4b2281a4d708d47f5957f919bda530a8e7d7a8d88519df2c003a046988718","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":"f1202b36b04b05a2720c7006b3f09c52e4e84a0f2f876e368c208b81174e2ed9","src/backend/tests/device_property.rs":"373f76d3bee83b263db3f02be3b94b408bdf852d84e4b5153273fda34b11a374","src/backend/tests/interfaces.rs":"b48d646b6ea06ca1bf7ce4b0ada59a164bc094e40b0cd66bb63b269f9032b022","src/backend/tests/manual.rs":"4331745812a2bfb848af59a9502bdc60645985c53ae97aa8f821e5975fef96ca","src/backend/tests/mod.rs":"8dba770023d7f9c4228f0e11915347f0e07da5fd818e3ee4478c4b197af9aa2a","src/backend/tests/parallel.rs":"f9e1883660d6146b6e5075806561f5f689810e25c5e7764dfd28c9b939821a49","src/backend/tests/tone.rs":"779cc14fc2a362bf7f26ce66ad70c0639501176175655a99b7fefb3c59d56c7a","src/backend/tests/utils.rs":"90ea06453b213dc431b58fbe7a94dde62ae1c0a1a71de782393f5dd64f1a3ed6","src/backend/utils.rs":"6c3ffbcd602e6cc9f56deb9ecb07b2eef2e6f074ef924178e466f380aae5c595","src/capi.rs":"21b66b70545bf04ec719928004d1d9adb45b24ced51288f5b2993d79aaf78f5f","src/lib.rs":"5e586d45cd6b3722f0a6736d9252593299269817a153eef1930a5fb9bfbb56f5","todo.md":"3a537412b5f27cbaad0b37c35d0f460ef6084030804a2910a3c67d37908a44fc"},"package":null}
|
20
third_party/rust/cubeb-coreaudio/.circleci/config.yml
vendored
Normal file
20
third_party/rust/cubeb-coreaudio/.circleci/config.yml
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
# See lastest version from: https://circleci.com/docs/2.0/configuration-reference
|
||||
version: 2.1
|
||||
|
||||
jobs:
|
||||
regular_test:
|
||||
macos: # indicate that we are using the macOS executor
|
||||
xcode: 11.3.0 # indicate our selected version of Xcode
|
||||
steps:
|
||||
- checkout
|
||||
- run: brew install cmake # for libcubeb in cubeb-sys crate
|
||||
- run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
||||
- run: rustc --version
|
||||
- run: cargo --version
|
||||
- run: cargo build --verbose
|
||||
- run: sh run_tests.sh
|
||||
workflows:
|
||||
version: 2
|
||||
build_and_test:
|
||||
jobs:
|
||||
- regular_test
|
42
third_party/rust/cubeb-coreaudio/.github/workflows/test.yml
vendored
Normal file
42
third_party/rust/cubeb-coreaudio/.github/workflows/test.yml
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
name: Build & Test
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: macOS-latest
|
||||
continue-on-error: ${{ matrix.experimental }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
rust: [stable]
|
||||
experimental: [false]
|
||||
include:
|
||||
- rust: nightly
|
||||
experimental: true
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Install Rust
|
||||
run: rustup toolchain install ${{ matrix.rust }} --profile minimal --component rustfmt clippy
|
||||
|
||||
- name: Setup
|
||||
run: |
|
||||
rustup default ${{ matrix.rust }}
|
||||
toolchain=$(rustup default)
|
||||
echo "Use Rust toolchain: $toolchain"
|
||||
rustc --version
|
||||
cargo --version
|
||||
|
||||
- name: Build
|
||||
run: cargo build --verbose
|
||||
|
||||
- name: Regular Test
|
||||
run: sh run_tests.sh
|
||||
|
||||
- name: Sanitizer Test
|
||||
if: ${{ matrix.rust == 'nightly' }}
|
||||
run: sh run_sanitizers.sh
|
3
third_party/rust/cubeb-coreaudio/README.md
vendored
3
third_party/rust/cubeb-coreaudio/README.md
vendored
@ -1,6 +1,7 @@
|
||||
# cubeb-coreaudio-rs
|
||||
|
||||
[![Build Status](https://travis-ci.com/ChunMinChang/cubeb-coreaudio-rs.svg?branch=trailblazer)](https://travis-ci.com/ChunMinChang/cubeb-coreaudio-rs)
|
||||
[![CircleCI](https://circleci.com/gh/mozilla/cubeb-coreaudio-rs.svg?style=svg)](https://circleci.com/gh/mozilla/cubeb-coreaudio-rs)
|
||||
[![Build & Test](https://github.com/mozilla/cubeb-coreaudio-rs/actions/workflows/test.yml/badge.svg)](https://github.com/mozilla/cubeb-coreaudio-rs/actions/workflows/test.yml)
|
||||
|
||||
*Rust* implementation of [Cubeb][cubeb] on [the MacOS platform][cubeb-au].
|
||||
|
||||
|
@ -11,7 +11,12 @@ if [[ $toolchain != nightly* ]]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
sanitizers=("address" "leak" "memory" "thread")
|
||||
# Ideally, sanitizers should be ("address" "leak" "memory" "thread") but
|
||||
# - `memory`: It doesn't works with target x86_64-apple-darwin
|
||||
# - `leak`: Get some errors that are out of our control. See:
|
||||
# https://github.com/mozilla/cubeb-coreaudio-rs/issues/45#issuecomment-591642931
|
||||
# - `thread`: It's blocked by #129
|
||||
sanitizers=("address")
|
||||
for san in "${sanitizers[@]}"
|
||||
do
|
||||
San="$(tr '[:lower:]' '[:upper:]' <<< ${san:0:1})${san:1}"
|
||||
|
@ -139,7 +139,7 @@ impl BufferManager {
|
||||
let available = c.len();
|
||||
assert!(available >= final_size);
|
||||
let to_pop = available - final_size;
|
||||
let mut buffer = [0 as i16; INPUT_BUFFER_CAPACITY];
|
||||
let mut buffer = [0_i16; INPUT_BUFFER_CAPACITY];
|
||||
let mut slice_to_pop = buffer.split_at_mut(to_pop);
|
||||
c.pop_slice(&mut slice_to_pop.0);
|
||||
}
|
||||
|
@ -136,10 +136,10 @@ impl device_property_listener {
|
||||
#[derive(Debug, PartialEq)]
|
||||
struct CAChannelLabel(AudioChannelLabel);
|
||||
|
||||
impl Into<mixer::Channel> for CAChannelLabel {
|
||||
fn into(self) -> mixer::Channel {
|
||||
impl From<CAChannelLabel> for mixer::Channel {
|
||||
fn from(label: CAChannelLabel) -> mixer::Channel {
|
||||
use self::coreaudio_sys_utils::sys;
|
||||
match self.0 {
|
||||
match label.0 {
|
||||
sys::kAudioChannelLabel_Left => mixer::Channel::FrontLeft,
|
||||
sys::kAudioChannelLabel_Right => mixer::Channel::FrontRight,
|
||||
sys::kAudioChannelLabel_Center | sys::kAudioChannelLabel_Mono => {
|
||||
@ -336,7 +336,7 @@ extern "C" fn audiounit_input_callback(
|
||||
enum ErrorHandle {
|
||||
Return(OSStatus),
|
||||
Reinit,
|
||||
};
|
||||
}
|
||||
|
||||
assert!(input_frames > 0);
|
||||
assert_eq!(bus, AU_IN_BUS);
|
||||
@ -346,7 +346,7 @@ extern "C" fn audiounit_input_callback(
|
||||
|
||||
if unsafe { *flags | kAudioTimeStampHostTimeValid } != 0 {
|
||||
let now = unsafe { mach_absolute_time() };
|
||||
let input_latency_frames = compute_input_latency(&stm, unsafe { (*tstamp).mHostTime }, now);
|
||||
let input_latency_frames = compute_input_latency(stm, unsafe { (*tstamp).mHostTime }, now);
|
||||
stm.total_input_latency_frames
|
||||
.store(input_latency_frames, Ordering::SeqCst);
|
||||
}
|
||||
@ -419,10 +419,6 @@ extern "C" fn audiounit_input_callback(
|
||||
ErrorHandle::Return(status)
|
||||
};
|
||||
|
||||
// Advance input frame counter.
|
||||
stm.frames_read
|
||||
.fetch_add(input_frames as usize, atomic::Ordering::SeqCst);
|
||||
|
||||
cubeb_logv!(
|
||||
"({:p}) input: buffers {}, size {}, channels {}, rendered frames {}, total frames {}.",
|
||||
stm.core_stream_data.stm_ptr,
|
||||
@ -445,7 +441,10 @@ extern "C" fn audiounit_input_callback(
|
||||
/ stm.core_stream_data.input_desc.mChannelsPerFrame as usize)
|
||||
as i64;
|
||||
assert!(input_frames as i64 <= total_input_frames);
|
||||
let input_buffer = input_buffer_manager.get_linear_data(total_input_frames as usize);
|
||||
stm.frames_read
|
||||
.fetch_add(total_input_frames as usize, atomic::Ordering::SeqCst);
|
||||
let input_buffer =
|
||||
input_buffer_manager.get_linear_data(input_buffer_manager.available_samples());
|
||||
let outframes = stm.core_stream_data.resampler.fill(
|
||||
input_buffer,
|
||||
&mut total_input_frames,
|
||||
@ -562,7 +561,7 @@ extern "C" fn audiounit_output_callback(
|
||||
|
||||
if unsafe { *flags | kAudioTimeStampHostTimeValid } != 0 {
|
||||
let output_latency_frames =
|
||||
compute_output_latency(&stm, unsafe { (*tstamp).mHostTime }, now);
|
||||
compute_output_latency(stm, unsafe { (*tstamp).mHostTime }, now);
|
||||
stm.total_output_latency_frames
|
||||
.store(output_latency_frames, Ordering::SeqCst);
|
||||
}
|
||||
@ -613,36 +612,33 @@ extern "C" fn audiounit_output_callback(
|
||||
if prev_frames_written == 0 && buffered_input_frames > input_frames_needed as usize {
|
||||
input_buffer_manager.trim(input_frames_needed * input_channels);
|
||||
let popped_frames = buffered_input_frames - input_frames_needed as usize;
|
||||
stm.frames_read.fetch_sub(popped_frames, Ordering::SeqCst);
|
||||
|
||||
cubeb_log!("Dropping {} frames in input buffer.", popped_frames);
|
||||
}
|
||||
|
||||
let input_frames = if input_frames_needed > buffered_input_frames
|
||||
&& (stm.switching_device.load(Ordering::SeqCst)
|
||||
|| stm.frames_read.load(Ordering::SeqCst) == 0)
|
||||
{
|
||||
let input_frames = if input_frames_needed > buffered_input_frames {
|
||||
// The silent frames will be inserted in `get_linear_data` below.
|
||||
let silent_frames_to_push = input_frames_needed - buffered_input_frames;
|
||||
cubeb_log!(
|
||||
"({:p}) Missing Frames: {} will append {} frames of input silence.",
|
||||
"({:p}) Missing Frames: {}, will append {} frames of input silence.",
|
||||
stm.core_stream_data.stm_ptr,
|
||||
if stm.frames_read.load(Ordering::SeqCst) == 0 {
|
||||
"input hasn't started,"
|
||||
"input hasn't started"
|
||||
} else if stm.switching_device.load(Ordering::SeqCst) {
|
||||
"device switching"
|
||||
} else if stm.reinit_pending.load(Ordering::SeqCst) {
|
||||
"reinit pending"
|
||||
} else {
|
||||
assert!(stm.switching_device.load(Ordering::SeqCst));
|
||||
"device switching,"
|
||||
"not enough buffered frames"
|
||||
},
|
||||
silent_frames_to_push
|
||||
);
|
||||
stm.frames_read
|
||||
.fetch_add(input_frames_needed, Ordering::SeqCst);
|
||||
input_frames_needed
|
||||
} else {
|
||||
buffered_input_frames
|
||||
};
|
||||
|
||||
let input_samples_needed = input_frames * input_channels;
|
||||
stm.frames_read.fetch_add(input_frames, Ordering::SeqCst);
|
||||
(
|
||||
input_buffer_manager.get_linear_data(input_samples_needed),
|
||||
input_frames as i64,
|
||||
@ -651,6 +647,9 @@ extern "C" fn audiounit_output_callback(
|
||||
(ptr::null_mut::<c_void>(), 0)
|
||||
};
|
||||
|
||||
// If `input_buffer` is non-null but `input_frames` is zero and this is the first call to
|
||||
// resampler, then we will hit an assertion in resampler code since no internal buffer will be
|
||||
// allocated in the resampler due to zero `input_frames`
|
||||
let outframes = stm.core_stream_data.resampler.fill(
|
||||
input_buffer,
|
||||
if input_buffer.is_null() {
|
||||
@ -1489,8 +1488,10 @@ fn create_cubeb_device_info(
|
||||
return Err(Error::error());
|
||||
}
|
||||
|
||||
let mut dev_info = ffi::cubeb_device_info::default();
|
||||
dev_info.max_channels = channels;
|
||||
let mut dev_info = ffi::cubeb_device_info {
|
||||
max_channels: channels,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
assert!(
|
||||
mem::size_of::<ffi::cubeb_devid>() >= mem::size_of_val(&devid),
|
||||
@ -1630,7 +1631,7 @@ fn is_aggregate_device(device_info: &ffi::cubeb_device_info) -> bool {
|
||||
libc::strncmp(
|
||||
device_info.friendly_name,
|
||||
private_name.as_ptr(),
|
||||
libc::strlen(private_name.as_ptr()),
|
||||
private_name.as_bytes().len(),
|
||||
) == 0
|
||||
}
|
||||
}
|
||||
|
@ -523,11 +523,46 @@ fn test_unplug_a_device_on_an_active_stream(
|
||||
return;
|
||||
}
|
||||
|
||||
let default_device_before_plugging = test_get_default_device(device_scope.clone()).unwrap();
|
||||
println!(
|
||||
"Before plugging, default {:?} device is {}",
|
||||
device_scope, default_device_before_plugging
|
||||
);
|
||||
|
||||
let mut plugger = TestDevicePlugger::new(device_scope.clone()).unwrap();
|
||||
assert!(plugger.plug().is_ok());
|
||||
assert_ne!(plugger.get_device_id(), kAudioObjectUnknown);
|
||||
println!(
|
||||
"Create plugger device: {} for {:?}",
|
||||
plugger.get_device_id(),
|
||||
device_scope
|
||||
);
|
||||
|
||||
let default_device_after_plugging = test_get_default_device(device_scope.clone()).unwrap();
|
||||
println!(
|
||||
"After plugging, default {:?} device is {}",
|
||||
device_scope, default_device_after_plugging
|
||||
);
|
||||
|
||||
// The new device, plugger, is possible to be set to the default device.
|
||||
// Before running the test, we need to set the default device to the correct one.
|
||||
if set_device_to_default {
|
||||
assert!(test_set_default_device(plugger.get_device_id(), device_scope.clone()).unwrap());
|
||||
// plugger should be the default device for the test.
|
||||
// If it's not, then set it to the default device.
|
||||
if default_device_after_plugging != plugger.get_device_id() {
|
||||
let prev_def_dev =
|
||||
test_set_default_device(plugger.get_device_id(), device_scope.clone()).unwrap();
|
||||
assert_eq!(prev_def_dev, default_device_after_plugging);
|
||||
}
|
||||
} else {
|
||||
// plugger should NOT be the default device for the test.
|
||||
// If it is, reset the default device to another one.
|
||||
if default_device_after_plugging == plugger.get_device_id() {
|
||||
let prev_def_dev =
|
||||
test_set_default_device(default_device_before_plugging, device_scope.clone())
|
||||
.unwrap();
|
||||
assert_eq!(prev_def_dev, default_device_after_plugging);
|
||||
}
|
||||
}
|
||||
|
||||
let (input_device, output_device) = match device_scope {
|
||||
@ -552,12 +587,25 @@ fn test_unplug_a_device_on_an_active_stream(
|
||||
stream.start();
|
||||
// Wait for stream data callback.
|
||||
thread::sleep(Duration::from_millis(200));
|
||||
println!(
|
||||
"Stream runs on the device {} for {:?}",
|
||||
plugger.get_device_id(),
|
||||
device_scope
|
||||
);
|
||||
let dev = plugger.get_device_id();
|
||||
assert!(plugger.unplug().is_ok());
|
||||
changed_watcher.wait_for_change();
|
||||
// Wait for stream re-initialization or destroy stream directly.
|
||||
if wait_for_reinit_millis > 0 {
|
||||
thread::sleep(Duration::from_millis(wait_for_reinit_millis));
|
||||
}
|
||||
println!(
|
||||
"Device {} for {:?} is unplugged. The default {:?} device now is {}",
|
||||
dev,
|
||||
device_scope,
|
||||
device_scope,
|
||||
test_get_default_device(device_scope.clone()).unwrap()
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -28,7 +28,7 @@ fn test_dial_tone() {
|
||||
struct Closure {
|
||||
buffer_size: AtomicI64,
|
||||
phase: i64,
|
||||
};
|
||||
}
|
||||
let mut closure = Closure {
|
||||
buffer_size: AtomicI64::new(0),
|
||||
phase: 0,
|
||||
@ -55,7 +55,7 @@ fn test_dial_tone() {
|
||||
Paused,
|
||||
Resumed,
|
||||
End,
|
||||
};
|
||||
}
|
||||
let mut state = State::WaitingForStart;
|
||||
let mut position: u64 = 0;
|
||||
let mut prev_position: u64 = 0;
|
||||
|
@ -555,18 +555,19 @@ pub fn test_audiounit_get_buffer_frame_size(
|
||||
// 2. a non-input/non-output device
|
||||
// 3. the current default input/output device
|
||||
// as the new default input/output device by apple's API. We need to check the above things by ourselves.
|
||||
// This function returns an Ok containing the previous default device id on success.
|
||||
// Otherwise, it returns an Err containing the error code with OSStatus type
|
||||
pub fn test_set_default_device(
|
||||
device: AudioObjectID,
|
||||
scope: Scope,
|
||||
) -> std::result::Result<bool, OSStatus> {
|
||||
let default = test_get_default_device(scope.clone());
|
||||
if default.is_none() {
|
||||
return Ok(false);
|
||||
}
|
||||
let default = default.unwrap();
|
||||
if default == device || !test_device_in_scope(device, scope.clone()) {
|
||||
return Ok(false);
|
||||
) -> std::result::Result<AudioObjectID, OSStatus> {
|
||||
assert!(test_device_in_scope(device, scope.clone()));
|
||||
let default = test_get_default_device(scope.clone()).unwrap();
|
||||
if default == device {
|
||||
// Do nothing if device is already the default device
|
||||
return Ok(device);
|
||||
}
|
||||
|
||||
let address = AudioObjectPropertyAddress {
|
||||
mSelector: match scope {
|
||||
Scope::Input => kAudioHardwarePropertyDefaultInputDevice,
|
||||
@ -587,7 +588,7 @@ pub fn test_set_default_device(
|
||||
)
|
||||
};
|
||||
if status == NO_ERR {
|
||||
Ok(true)
|
||||
Ok(default)
|
||||
} else {
|
||||
Err(status)
|
||||
}
|
||||
@ -623,11 +624,12 @@ impl TestDeviceSwitcher {
|
||||
"Switch device for {:?}: {} -> {}",
|
||||
self.scope, current, next
|
||||
);
|
||||
assert!(self.set_device(next).unwrap());
|
||||
let prev = self.set_device(next).unwrap();
|
||||
assert_eq!(prev, current);
|
||||
self.current_device_index = next_index;
|
||||
}
|
||||
|
||||
fn set_device(&self, device: AudioObjectID) -> std::result::Result<bool, OSStatus> {
|
||||
fn set_device(&self, device: AudioObjectID) -> std::result::Result<AudioObjectID, OSStatus> {
|
||||
test_set_default_device(device, self.scope.clone())
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user