fixed coreaudio buffersize errors

This commit is contained in:
JoshuaBatty 2020-05-27 13:15:15 +02:00
parent 9c85eecb59
commit 10599ac826
1 changed files with 29 additions and 19 deletions

View File

@ -380,7 +380,7 @@ impl Device {
}
};
let mut audio_unit = audio_unit_from_device(self, true)?;
let audio_unit = audio_unit_from_device(self, true)?;
let buffer_size = get_io_buffer_frame_size_range(&audio_unit)?;
let config = SupportedStreamConfig {
@ -688,7 +688,9 @@ impl Device {
match config.buffer_size {
BufferSize::Fixed(v) => {
let buffer_size_range = get_io_buffer_frame_size_range(&audio_unit)?;
if v >= buffer_size_range.min && v <= buffer_size_range.max {
match buffer_size_range {
SupportedBufferSize::Range{min, max} => {
if v >= min && v <= max {
audio_unit.set_property(
kAudioDevicePropertyBufferFrameSize,
scope,
@ -698,6 +700,9 @@ impl Device {
} else {
return Err(BuildStreamError::StreamConfigNotSupported);
}
},
SupportedBufferSize::Unknown => (),
}
}
BufferSize::Default => (),
}
@ -777,7 +782,9 @@ impl Device {
match config.buffer_size {
BufferSize::Fixed(v) => {
let buffer_size_range = get_io_buffer_frame_size_range(&audio_unit)?;
if v >= buffer_size_range.min && v <= buffer_size_range.max {
match buffer_size_range {
SupportedBufferSize::Range{min, max} => {
if v >= min && v <= max {
audio_unit.set_property(
kAudioDevicePropertyBufferFrameSize,
scope,
@ -787,6 +794,9 @@ impl Device {
} else {
return Err(BuildStreamError::StreamConfigNotSupported);
}
},
SupportedBufferSize::Unknown => (),
}
}
BufferSize::Default => (),
}