From e20280cfce754287bab2af368da6a86dacd39c27 Mon Sep 17 00:00:00 2001 From: Chun-Min Chang Date: Tue, 9 Jul 2019 19:57:06 +0000 Subject: [PATCH] Bug 1530715 - P34: Merge layout_init into configure_output. r=padenot 1. Avoid calling layout_init by wrong AudioUnit value 2. Avoid calling layout getting/setting APIs by borrowing the AudioUnitStream as a mutable. It will help to avoid the potential borrowing-twice issues in the later mutex replacement. Differential Revision: https://phabricator.services.mozilla.com/D34067 --HG-- extra : moz-landing-system : lando --- .../cubeb-coreaudio-rs/README_MOZILLA | 2 +- .../cubeb-coreaudio-rs/src/backend/mod.rs | 27 +++++++------------ 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/media/libcubeb/cubeb-coreaudio-rs/README_MOZILLA b/media/libcubeb/cubeb-coreaudio-rs/README_MOZILLA index 15fd79ee5915..4d86211e3823 100644 --- a/media/libcubeb/cubeb-coreaudio-rs/README_MOZILLA +++ b/media/libcubeb/cubeb-coreaudio-rs/README_MOZILLA @@ -3,4 +3,4 @@ git repository using the update.sh script. The cubeb-coreaudio-rs git repository is: https://github.com/ChunMinChang/cubeb-coreaudio-rs -The git commit ID used was e4ca148920d86a15f2a8dc0f09e60fec480860cd (2019-06-25 11:32:22 -0700) +The git commit ID used was d23565b1fd9342681f4e7eafc49a2aa1df4f7da0 (2019-06-25 11:32:22 -0700) diff --git a/media/libcubeb/cubeb-coreaudio-rs/src/backend/mod.rs b/media/libcubeb/cubeb-coreaudio-rs/src/backend/mod.rs index 759d73ddbad8..780ebf204e0f 100644 --- a/media/libcubeb/cubeb-coreaudio-rs/src/backend/mod.rs +++ b/media/libcubeb/cubeb-coreaudio-rs/src/backend/mod.rs @@ -2948,23 +2948,6 @@ impl<'ctx> AudioUnitStream<'ctx> { Ok(()) } - 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 configure_input(&mut self) -> Result<()> { assert!(!self.input_unit.is_null()); @@ -3160,7 +3143,15 @@ impl<'ctx> AudioUnitStream<'ctx> { self.context.channels = output_hw_desc.mChannelsPerFrame; // Set the input layout to match the output device layout. - self.layout_init(io_side::OUTPUT); + 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), + ); cubeb_log!( "({:p}) Output hardware layout: {:?}", self,