From 8e0d869e38019b0e69ee0604d920f12749462e71 Mon Sep 17 00:00:00 2001 From: Chun-Min Chang Date: Wed, 18 Dec 2019 09:55:30 -0800 Subject: [PATCH] Remove the test_set_channel_layout_input Calling audiounit_get_current_channel_layout by input-only (microphone-only) AudioUnit is prone to cause crash intermittently. The test_set_channel_layout_input is likely to cause intermittent crash since it calls audiounit_get_current_channel_layout by a input-only AudioUnit. Removing this test can avoid the random crashes when running `cargo test` (#31). The cubeb implementation has no need to get the channel-layout on input side, so the test_set_channel_layout_input is unnecessary anyway. --- src/backend/mod.rs | 2 ++ src/backend/tests/api.rs | 17 ----------------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/src/backend/mod.rs b/src/backend/mod.rs index 69058219..f9221277 100644 --- a/src/backend/mod.rs +++ b/src/backend/mod.rs @@ -1001,6 +1001,8 @@ fn audiounit_get_preferred_channel_layout(output_unit: AudioUnit) -> ChannelLayo audiounit_convert_channel_layout(layout.as_ref()) } +// This is for output AudioUnit only. Calling this by input-only AudioUnit is prone +// to crash intermittently. fn audiounit_get_current_channel_layout(output_unit: AudioUnit) -> ChannelLayout { let mut rv = NO_ERR; let mut size: usize = 0; diff --git a/src/backend/tests/api.rs b/src/backend/tests/api.rs index 71343e26..27d4f473 100644 --- a/src/backend/tests/api.rs +++ b/src/backend/tests/api.rs @@ -980,23 +980,6 @@ fn test_set_channel_layout_output_undefind() { } } -#[test] -fn test_set_channel_layout_input() { - if let Some(unit) = test_get_default_audiounit(Scope::Input) { - // Get original layout. - let original_layout = audiounit_get_current_channel_layout(unit.get_inner()); - // Leave layout as it is. - assert!(audiounit_set_channel_layout(unit.get_inner(), ChannelLayout::UNDEFINED).is_ok()); - // Check the layout is same as the original one. - assert_eq!( - audiounit_get_current_channel_layout(unit.get_inner()), - original_layout - ); - } else { - println!("No input audiounit."); - } -} - #[test] #[should_panic] fn test_set_channel_layout_with_null_unit() {