Skip to content

Commit a5b8ca3

Browse files
changed the way to collect supported samplerate range
1 parent 582e93c commit a5b8ca3

File tree

1 file changed

+3
-7
lines changed
  • src/host/coreaudio/macos

1 file changed

+3
-7
lines changed

src/host/coreaudio/macos/mod.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -300,19 +300,15 @@ impl Device {
300300
let buffer_size = get_io_buffer_frame_size_range(&audio_unit)?;
301301

302302
// Collect the supported formats for the device.
303-
let mut fmts = vec![];
304-
for range in ranges {
305303
let fmt = SupportedStreamConfigRange {
306304
channels: n_channels as ChannelCount,
307-
min_sample_rate: SampleRate(range.mMinimum as _),
308-
max_sample_rate: SampleRate(range.mMaximum as _),
305+
min_sample_rate: SampleRate(ranges.iter().map(|v| v.mMinimum as u32).min().unwrap()),
306+
max_sample_rate: SampleRate(ranges.iter().map(|v| v.mMaximum as u32).max().unwrap()),
309307
buffer_size,
310308
sample_format,
311309
};
312-
fmts.push(fmt);
313-
}
314310

315-
Ok(fmts.into_iter())
311+
Ok(vec![fmt].into_iter())
316312
}
317313
}
318314

0 commit comments

Comments
 (0)