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
This commit is contained in:
Chun-Min Chang 2019-07-09 19:57:06 +00:00
Родитель 7392d55799
Коммит e20280cfce
2 изменённых файлов: 10 добавлений и 19 удалений

Просмотреть файл

@ -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)

Просмотреть файл

@ -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,