зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1530715 - P5: Remove the unused code when clamping latency frames. r=padenot
The clamp_latency function is only called when the cubeb context has one stream only. In that case, clamp_latency will clamp the stream latency frames in a safe range and then return the clamped value directly. The code in clamp_latency for more than one streams doesn't be executed since clamp_latency isn't called when there are more than one streams within cubeb context. It's easier to read the code if the unused code is removed. Differential Revision: https://phabricator.services.mozilla.com/D29011 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
fd26b68633
Коммит
d6be3795fa
|
@ -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 9a78b6e739eb73911b77ae83e73456ad9586ba2d (2019-06-21 14:09:49 -0700)
|
||||
The git commit ID used was 1cff8dc305051f568b6866c42279faf97b35dd5b (2019-06-21 14:09:49 -0700)
|
||||
|
|
|
@ -3366,89 +3366,9 @@ impl<'ctx> AudioUnitStream<'ctx> {
|
|||
|
||||
fn clamp_latency(&mut self, latency_frames: u32) -> u32 {
|
||||
// For the 1st stream set anything within safe min-max
|
||||
assert!(self.context.active_streams() > 0);
|
||||
if self.context.active_streams() == 1 {
|
||||
return cmp::max(
|
||||
cmp::min(latency_frames, SAFE_MAX_LATENCY_FRAMES),
|
||||
SAFE_MIN_LATENCY_FRAMES,
|
||||
);
|
||||
}
|
||||
// TODO: Should we check this even for 1 stream case ?
|
||||
// Do we need to set latency if there is no output unit ?
|
||||
assert!(!self.output_unit.is_null());
|
||||
|
||||
// If more than one stream operates in parallel
|
||||
// allow only lower values of latency
|
||||
let mut r = NO_ERR;
|
||||
let mut output_buffer_size: UInt32 = 0;
|
||||
let mut size = mem::size_of_val(&output_buffer_size);
|
||||
assert_eq!(size, mem::size_of::<UInt32>());
|
||||
// TODO: Why we check `output_unit` here? We already have an assertions above!
|
||||
if !self.output_unit.is_null() {
|
||||
r = audio_unit_get_property(
|
||||
self.output_unit,
|
||||
kAudioDevicePropertyBufferFrameSize,
|
||||
kAudioUnitScope_Output,
|
||||
AU_OUT_BUS,
|
||||
&mut output_buffer_size,
|
||||
&mut size,
|
||||
);
|
||||
if r != NO_ERR {
|
||||
// Hit this when there is no output device.
|
||||
cubeb_log!(
|
||||
"AudioUnitGetProperty/output/kAudioDevicePropertyBufferFrameSize rv={}",
|
||||
r
|
||||
);
|
||||
// TODO: Shouldn't it return something in range between
|
||||
// SAFE_MIN_LATENCY_FRAMES and SAFE_MAX_LATENCY_FRAMES ?
|
||||
return 0;
|
||||
}
|
||||
|
||||
output_buffer_size = cmp::max(
|
||||
cmp::min(output_buffer_size, SAFE_MAX_LATENCY_FRAMES),
|
||||
SAFE_MIN_LATENCY_FRAMES,
|
||||
);
|
||||
}
|
||||
|
||||
let mut input_buffer_size: UInt32 = 0;
|
||||
if !self.input_unit.is_null() {
|
||||
r = audio_unit_get_property(
|
||||
self.input_unit,
|
||||
kAudioDevicePropertyBufferFrameSize,
|
||||
kAudioUnitScope_Input,
|
||||
AU_IN_BUS,
|
||||
&mut input_buffer_size,
|
||||
&mut size,
|
||||
);
|
||||
if r != NO_ERR {
|
||||
cubeb_log!(
|
||||
"AudioUnitGetProperty/input/kAudioDevicePropertyBufferFrameSize rv={}",
|
||||
r
|
||||
);
|
||||
// TODO: Shouldn't it return something in range between
|
||||
// SAFE_MIN_LATENCY_FRAMES and SAFE_MAX_LATENCY_FRAMES ?
|
||||
return 0;
|
||||
}
|
||||
|
||||
input_buffer_size = cmp::max(
|
||||
cmp::min(input_buffer_size, SAFE_MAX_LATENCY_FRAMES),
|
||||
SAFE_MIN_LATENCY_FRAMES,
|
||||
);
|
||||
}
|
||||
|
||||
// Every following active streams can only set smaller latency
|
||||
let upper_latency_limit = if input_buffer_size != 0 && output_buffer_size != 0 {
|
||||
cmp::min(input_buffer_size, output_buffer_size)
|
||||
} else if input_buffer_size != 0 {
|
||||
input_buffer_size
|
||||
} else if output_buffer_size != 0 {
|
||||
output_buffer_size
|
||||
} else {
|
||||
SAFE_MAX_LATENCY_FRAMES
|
||||
};
|
||||
|
||||
assert_eq!(self.context.active_streams(), 1);
|
||||
cmp::max(
|
||||
cmp::min(latency_frames, upper_latency_limit),
|
||||
cmp::min(latency_frames, SAFE_MAX_LATENCY_FRAMES),
|
||||
SAFE_MIN_LATENCY_FRAMES,
|
||||
)
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче