зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1530715 - P16: Implement an internal set_volume API. r=padenot
By narrowing down the parameters that set_volume API needs, we can avoid the unnecessary mutual borrowing from the AudioUnitStream variable. This will help to avoid potential borrowing-twice issues in the later mutex replacement. Differential Revision: https://phabricator.services.mozilla.com/D34049 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
2f4e0d4bf9
Коммит
64146dd614
|
@ -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 698edefc09a85a27f1abe1419610533104e64e0a (2019-06-21 14:40:13 -0700)
|
||||
The git commit ID used was 7b054f81e09ea9f825671e731785d96decd7c488 (2019-06-21 14:40:23 -0700)
|
||||
|
|
|
@ -256,6 +256,24 @@ fn create_device_info(id: AudioDeviceID, devtype: DeviceType) -> Result<device_i
|
|||
Ok(info)
|
||||
}
|
||||
|
||||
fn set_volume(unit: AudioUnit, volume: f32) -> Result<()> {
|
||||
assert!(!unit.is_null());
|
||||
let r = audio_unit_set_parameter(
|
||||
unit,
|
||||
kHALOutputParam_Volume,
|
||||
kAudioUnitScope_Global,
|
||||
0,
|
||||
volume,
|
||||
0,
|
||||
);
|
||||
if r == NO_ERR {
|
||||
Ok(())
|
||||
} else {
|
||||
cubeb_log!("AudioUnitSetParameter/kHALOutputParam_Volume rv={}", r);
|
||||
Err(Error::error())
|
||||
}
|
||||
}
|
||||
|
||||
fn audiounit_make_silent(io_data: &mut AudioBuffer) {
|
||||
assert!(!io_data.mData.is_null());
|
||||
let bytes = unsafe {
|
||||
|
@ -3141,7 +3159,7 @@ impl<'ctx> AudioUnitStream<'ctx> {
|
|||
}
|
||||
|
||||
if vol_rv.is_ok() {
|
||||
self.set_volume(vol_rv.unwrap());
|
||||
set_volume(self.output_unit, vol_rv.unwrap());
|
||||
}
|
||||
|
||||
// If the stream was running, start it again.
|
||||
|
@ -4348,21 +4366,7 @@ impl<'ctx> StreamOps for AudioUnitStream<'ctx> {
|
|||
Ok(self.current_latency_frames.load(Ordering::SeqCst))
|
||||
}
|
||||
fn set_volume(&mut self, volume: f32) -> Result<()> {
|
||||
assert!(!self.output_unit.is_null());
|
||||
let mut r = NO_ERR;
|
||||
r = audio_unit_set_parameter(
|
||||
self.output_unit,
|
||||
kHALOutputParam_Volume,
|
||||
kAudioUnitScope_Global,
|
||||
0,
|
||||
volume,
|
||||
0,
|
||||
);
|
||||
if r != NO_ERR {
|
||||
cubeb_log!("AudioUnitSetParameter/kHALOutputParam_Volume rv={}", r);
|
||||
return Err(Error::error());
|
||||
}
|
||||
Ok(())
|
||||
set_volume(self.output_unit, volume)
|
||||
}
|
||||
fn set_panning(&mut self, panning: f32) -> Result<()> {
|
||||
if self.output_desc.mChannelsPerFrame > 2 {
|
||||
|
|
Загрузка…
Ссылка в новой задаче