in src/backend/mod.rs [1461:1488]
fn set_buffer_size(
unit: AudioUnit,
devtype: DeviceType,
frames: u32,
) -> std::result::Result<(), OSStatus> {
assert!(!unit.is_null());
let (scope, element) = match devtype {
DeviceType::INPUT => (kAudioUnitScope_Output, AU_IN_BUS),
DeviceType::OUTPUT => (kAudioUnitScope_Input, AU_OUT_BUS),
_ => panic!(
"Set buffer size of AudioUnit {:?} with unsupported type: {:?}",
unit, devtype
),
};
let status = audio_unit_set_property(
unit,
kAudioDevicePropertyBufferFrameSize,
scope,
element,
&frames,
mem::size_of_val(&frames),
);
if status == NO_ERR {
Ok(())
} else {
Err(status)
}
}