From 49b8fcc318b68ddbbceeacf316cdfd1cfc4fc2d2 Mon Sep 17 00:00:00 2001 From: Chun-Min Chang Date: Mon, 22 Apr 2019 14:32:26 -0700 Subject: [PATCH] Make layout_init become a member function --- src/backend/mod.rs | 24 ++++++++++++------------ src/backend/tests/api.rs | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/backend/mod.rs b/src/backend/mod.rs index 12e2434..d139130 100644 --- a/src/backend/mod.rs +++ b/src/backend/mod.rs @@ -1167,17 +1167,6 @@ fn audiounit_set_channel_layout(unit: AudioUnit, Ok(()) } -fn audiounit_layout_init(stm: &mut AudioUnitStream, side: io_side) -{ - // We currently don't support the input layout setting. - if side == io_side::INPUT { - return; - } - - stm.context.layout.store(audiounit_get_current_channel_layout(stm.output_unit), atomic::Ordering::SeqCst); - let _ = audiounit_set_channel_layout(stm.output_unit, io_side::OUTPUT, stm.context.layout.load(atomic::Ordering::SeqCst)); -} - fn audiounit_get_sub_devices(device_id: AudioDeviceID) -> Vec { // FIXIT: Add a check ? We will fail to get data size if `device_id` @@ -2228,7 +2217,7 @@ fn audiounit_configure_output(stm: &mut AudioUnitStream) -> Result<()> stm.context.channels = output_hw_desc.mChannelsPerFrame; // Set the input layout to match the output device layout. - audiounit_layout_init(stm, io_side::OUTPUT); + stm.layout_init(io_side::OUTPUT); if stm.context.channels != stm.output_stream_params.channels() || stm.context.layout.load(atomic::Ordering::SeqCst) != stm.output_stream_params.layout() { cubeb_log!("Incompatible channel layouts detected, setting up remixer"); @@ -3817,6 +3806,17 @@ impl<'ctx> AudioUnitStream<'ctx> { assert!(!self.mixer.as_mut_ptr().is_null()); } + // TODO: Rename to init_layout ? + fn layout_init(&mut self, side: io_side) { + // We currently don't support the input layout setting. + if side == io_side::INPUT { + return; + } + + self.context.layout.store(audiounit_get_current_channel_layout(self.output_unit), atomic::Ordering::SeqCst); + audiounit_set_channel_layout(self.output_unit, io_side::OUTPUT, self.context.layout.load(atomic::Ordering::SeqCst)); + } + fn close(&mut self) { self.mutex.assert_current_thread_owns(); diff --git a/src/backend/tests/api.rs b/src/backend/tests/api.rs index b4a37f7..2e699a3 100644 --- a/src/backend/tests/api.rs +++ b/src/backend/tests/api.rs @@ -1149,7 +1149,7 @@ fn test_layout_init() { let layout = audiounit_get_current_channel_layout(stream.output_unit); - audiounit_layout_init(stream, io_side::OUTPUT); + stream.layout_init(io_side::OUTPUT); assert_eq!(stream.context.layout.load(atomic::Ordering::SeqCst), layout); });