pub struct SupportedStreamConfigRange { /* private fields */ }
Expand description
Describes a range of supported stream configurations, retrieved via the
Device::supported_input/output_configs
method.
Implementations§
Source§impl SupportedStreamConfigRange
impl SupportedStreamConfigRange
pub fn new( channels: ChannelCount, min_sample_rate: SampleRate, max_sample_rate: SampleRate, buffer_size: SupportedBufferSize, sample_format: SampleFormat, ) -> Self
pub fn channels(&self) -> ChannelCount
pub fn min_sample_rate(&self) -> SampleRate
pub fn max_sample_rate(&self) -> SampleRate
pub fn buffer_size(&self) -> &SupportedBufferSize
pub fn sample_format(&self) -> SampleFormat
Sourcepub fn with_sample_rate(self, sample_rate: SampleRate) -> SupportedStreamConfig
pub fn with_sample_rate(self, sample_rate: SampleRate) -> SupportedStreamConfig
Retrieve a SupportedStreamConfig
with the given sample rate and buffer size.
§Panics
Panics if the given sample_rate
is outside the range specified within
this SupportedStreamConfigRange
instance. For a non-panicking
variant, use try_with_sample_rate
.
Sourcepub fn try_with_sample_rate(
self,
sample_rate: SampleRate,
) -> Option<SupportedStreamConfig>
pub fn try_with_sample_rate( self, sample_rate: SampleRate, ) -> Option<SupportedStreamConfig>
Retrieve a SupportedStreamConfig
with the given sample rate and buffer size.
Returns None
if the given sample rate is outside the range specified
within this SupportedStreamConfigRange
instance.
Sourcepub fn with_max_sample_rate(self) -> SupportedStreamConfig
pub fn with_max_sample_rate(self) -> SupportedStreamConfig
Turns this SupportedStreamConfigRange
into a SupportedStreamConfig
corresponding to the maximum samples rate.
Sourcepub fn cmp_default_heuristics(&self, other: &Self) -> Ordering
pub fn cmp_default_heuristics(&self, other: &Self) -> Ordering
A comparison function which compares two SupportedStreamConfigRange
s in terms of their priority of
use as a default stream format.
Some backends do not provide a default stream format for their audio devices. In these cases, CPAL attempts to decide on a reasonable default format for the user. To do this we use the “greatest” of all supported stream formats when compared with this method.
SupportedStreamConfigs are prioritised by the following heuristics:
Channels:
- Stereo
- Mono
- Max available channels
Sample format:
- f32
- i16
- u16
Sample rate:
- 44100 (cd quality)
- Max sample rate
Trait Implementations§
Source§impl Clone for SupportedStreamConfigRange
impl Clone for SupportedStreamConfigRange
Source§fn clone(&self) -> SupportedStreamConfigRange
fn clone(&self) -> SupportedStreamConfigRange
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more