Struct cpal::SupportedStreamConfigRange
source · 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 moresource§impl Debug for SupportedStreamConfigRange
impl Debug for SupportedStreamConfigRange
impl Copy for SupportedStreamConfigRange
impl Eq for SupportedStreamConfigRange
impl StructuralPartialEq for SupportedStreamConfigRange
Auto Trait Implementations§
impl Freeze for SupportedStreamConfigRange
impl RefUnwindSafe for SupportedStreamConfigRange
impl Send for SupportedStreamConfigRange
impl Sync for SupportedStreamConfigRange
impl Unpin for SupportedStreamConfigRange
impl UnwindSafe for SupportedStreamConfigRange
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)