rustfmt
This commit is contained in:
Родитель
53aba4ce63
Коммит
89a5ccaf1a
|
@ -435,7 +435,8 @@ fn test_aggregate_activate_clock_drift_compensation_for_a_blank_aggregate_device
|
|||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn test_aggregate_activate_clock_drift_compensation_for_an_aggregate_device_without_master_device() {
|
||||
fn test_aggregate_activate_clock_drift_compensation_for_an_aggregate_device_without_master_device()
|
||||
{
|
||||
let input_id = audiounit_get_default_device_id(DeviceType::INPUT);
|
||||
let output_id = audiounit_get_default_device_id(DeviceType::OUTPUT);
|
||||
if !valid_id(input_id) || !valid_id(output_id)
|
||||
|
|
|
@ -1819,7 +1819,10 @@ fn test_configure_input() {
|
|||
assert_eq!(description.mSampleRate, stream.input_hw_rate);
|
||||
}
|
||||
|
||||
fn check_linear_buffer<T: Any + Debug + PartialEq>(stream: &mut AudioUnitStream, array: &[T]) {
|
||||
fn check_linear_buffer<T: Any + Debug + PartialEq>(
|
||||
stream: &mut AudioUnitStream,
|
||||
array: &[T],
|
||||
) {
|
||||
assert!(stream.input_linear_buffer.is_some());
|
||||
let buffer_ref = stream.input_linear_buffer.as_mut().unwrap();
|
||||
buffer_ref.push(array.as_ptr() as *const c_void, array.len());
|
||||
|
@ -1855,12 +1858,16 @@ fn test_configure_input_with_zero_latency_frames() {
|
|||
params.channels = 1;
|
||||
params.layout = ffi::CUBEB_LAYOUT_MONO;
|
||||
params.prefs = ffi::CUBEB_STREAM_PREF_NONE;
|
||||
test_configure_scope_with_zero_latency_frames(Scope::Input, StreamParams::from(params), |stream| {
|
||||
test_configure_scope_with_zero_latency_frames(
|
||||
Scope::Input,
|
||||
StreamParams::from(params),
|
||||
|stream| {
|
||||
// TODO: The buffer frames size won't be 0 even it's ok to set that!
|
||||
check_buffer_frame_size(stream, Scope::Input);
|
||||
// TODO: The frames per slice won't be 0 even it's ok to set that!
|
||||
check_frames_per_slice(stream, Scope::Input);
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// configure_output
|
||||
|
@ -1926,22 +1933,35 @@ fn test_configure_output_with_zero_latency_frames() {
|
|||
params.channels = 2;
|
||||
params.layout = ffi::CUBEB_LAYOUT_STEREO;
|
||||
params.prefs = ffi::CUBEB_STREAM_PREF_NONE;
|
||||
test_configure_scope_with_zero_latency_frames(Scope::Output, StreamParams::from(params), |stream| {
|
||||
test_configure_scope_with_zero_latency_frames(
|
||||
Scope::Output,
|
||||
StreamParams::from(params),
|
||||
|stream| {
|
||||
// TODO: The buffer frames size won't be 0 even it's ok to set that!
|
||||
check_buffer_frame_size(stream, Scope::Output);
|
||||
// TODO: The frames per slice won't be 0 even it's ok to set that!
|
||||
check_frames_per_slice(stream, Scope::Output);
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// Utils for configure_{input, output}
|
||||
// ------------------------------------
|
||||
fn test_configure_scope<F>(scope: Scope, params: StreamParams, callback: F) where F: FnOnce(&mut AudioUnitStream) {
|
||||
fn test_configure_scope<F>(scope: Scope, params: StreamParams, callback: F)
|
||||
where
|
||||
F: FnOnce(&mut AudioUnitStream),
|
||||
{
|
||||
if let Some(unit) = test_get_default_audiounit(scope.clone()) {
|
||||
test_get_empty_stream(|stream| {
|
||||
match scope {
|
||||
Scope::Input => { stream.input_unit = unit.get_inner(); stream.input_stream_params = params; }
|
||||
Scope::Output => { stream.output_unit = unit.get_inner(); stream.output_stream_params = params; }
|
||||
Scope::Input => {
|
||||
stream.input_unit = unit.get_inner();
|
||||
stream.input_stream_params = params;
|
||||
}
|
||||
Scope::Output => {
|
||||
stream.output_unit = unit.get_inner();
|
||||
stream.output_stream_params = params;
|
||||
}
|
||||
}
|
||||
// Set the latency_frames to a valid value so `buffer frames size` and
|
||||
// `frames per slice` can be set correctly!
|
||||
|
@ -1966,12 +1986,21 @@ fn test_configure_scope<F>(scope: Scope, params: StreamParams, callback: F) wher
|
|||
}
|
||||
}
|
||||
|
||||
fn test_configure_scope_with_zero_latency_frames<F>(scope: Scope, params: StreamParams, callback: F) where F: FnOnce(&mut AudioUnitStream) {
|
||||
fn test_configure_scope_with_zero_latency_frames<F>(scope: Scope, params: StreamParams, callback: F)
|
||||
where
|
||||
F: FnOnce(&mut AudioUnitStream),
|
||||
{
|
||||
if let Some(unit) = test_get_default_audiounit(scope.clone()) {
|
||||
test_get_empty_stream(|stream| {
|
||||
match scope {
|
||||
Scope::Input => { stream.input_unit = unit.get_inner(); stream.input_stream_params = params; }
|
||||
Scope::Output => { stream.output_unit = unit.get_inner(); stream.output_stream_params = params; }
|
||||
Scope::Input => {
|
||||
stream.input_unit = unit.get_inner();
|
||||
stream.input_stream_params = params;
|
||||
}
|
||||
Scope::Output => {
|
||||
stream.output_unit = unit.get_inner();
|
||||
stream.output_stream_params = params;
|
||||
}
|
||||
}
|
||||
assert_eq!(stream.latency_frames, 0);
|
||||
let res = match scope {
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
use super::utils::{test_get_default_device, test_ops_stream_operation, Scope, test_get_devices_in_scope, test_set_default_device};
|
||||
use super::utils::{
|
||||
test_get_default_device, test_get_devices_in_scope, test_ops_stream_operation,
|
||||
test_set_default_device, Scope,
|
||||
};
|
||||
use super::*;
|
||||
|
||||
#[ignore]
|
||||
|
@ -62,7 +65,10 @@ fn test_switch_output_device() {
|
|||
return;
|
||||
}
|
||||
let current = test_get_default_device(Scope::Output).unwrap();
|
||||
let mut index = devices.iter().position(|device| *device == current).unwrap();
|
||||
let mut index = devices
|
||||
.iter()
|
||||
.position(|device| *device == current)
|
||||
.unwrap();
|
||||
println!("{:?}, {}, {}", devices, current, index);
|
||||
|
||||
// Make sure the parameters meet the requirements of AudioUnitContext::stream_init
|
||||
|
@ -107,4 +113,3 @@ fn test_switch_output_device() {
|
|||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -400,13 +400,16 @@ pub fn test_audiounit_scope_is_enabled(unit: AudioUnit, scope: Scope) -> bool {
|
|||
// 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.
|
||||
pub fn test_set_default_device(device: AudioObjectID, scope: Scope) -> std::result::Result<bool, OSStatus> {
|
||||
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()){
|
||||
if default == device || !test_device_in_scope(device, scope.clone()) {
|
||||
return Ok(false);
|
||||
}
|
||||
let address = AudioObjectPropertyAddress {
|
||||
|
|
Загрузка…
Ссылка в новой задаче