mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Bug 1530715 - P17: Move get_volume out of AudioUnitStream. r=padenot
By moving get_volume out of AudioUnitStream, we can avoid unnecessary borrowing from the AudioUnitStream variable. This change will make the get_volume become symmetric to the set_volume. Differential Revision: https://phabricator.services.mozilla.com/D34050 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
bd24fd4b75
commit
907cf01736
@ -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 7b054f81e09ea9f825671e731785d96decd7c488 (2019-06-21 14:40:23 -0700)
|
||||
The git commit ID used was cc7ef2614d4cfb9c03811da76902ea776b3333e2 (2019-06-21 14:40:29 -0700)
|
||||
|
@ -274,6 +274,24 @@ fn set_volume(unit: AudioUnit, volume: f32) -> Result<()> {
|
||||
}
|
||||
}
|
||||
|
||||
fn get_volume(unit: AudioUnit) -> Result<f32> {
|
||||
assert!(!unit.is_null());
|
||||
let mut volume: f32 = 0.0;
|
||||
let r = audio_unit_get_parameter(
|
||||
unit,
|
||||
kHALOutputParam_Volume,
|
||||
kAudioUnitScope_Global,
|
||||
0,
|
||||
&mut volume,
|
||||
);
|
||||
if r == NO_ERR {
|
||||
Ok(volume)
|
||||
} else {
|
||||
cubeb_log!("AudioUnitGetParameter/kHALOutputParam_Volume rv={}", r);
|
||||
Err(Error::error())
|
||||
}
|
||||
}
|
||||
|
||||
fn audiounit_make_silent(io_data: &mut AudioBuffer) {
|
||||
assert!(!io_data.mData.is_null());
|
||||
let bytes = unsafe {
|
||||
@ -3092,7 +3110,7 @@ impl<'ctx> AudioUnitStream<'ctx> {
|
||||
let vol_rv = if self.output_unit.is_null() {
|
||||
Err(Error::error())
|
||||
} else {
|
||||
self.get_volume()
|
||||
get_volume(self.output_unit)
|
||||
};
|
||||
|
||||
self.close();
|
||||
@ -4269,23 +4287,6 @@ impl<'ctx> AudioUnitStream<'ctx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn get_volume(&self) -> Result<f32> {
|
||||
assert!(!self.output_unit.is_null());
|
||||
let mut volume: f32 = 0.0;
|
||||
let r = audio_unit_get_parameter(
|
||||
self.output_unit,
|
||||
kHALOutputParam_Volume,
|
||||
kAudioUnitScope_Global,
|
||||
0,
|
||||
&mut volume,
|
||||
);
|
||||
if r != NO_ERR {
|
||||
cubeb_log!("AudioUnitGetParameter/kHALOutputParam_Volume rv={}", r);
|
||||
return Err(Error::error());
|
||||
}
|
||||
Ok(volume)
|
||||
}
|
||||
|
||||
fn destroy(&mut self) {
|
||||
if !self.shutdown.load(Ordering::SeqCst) {
|
||||
self.stop_internal();
|
||||
|
Loading…
Reference in New Issue
Block a user