logo
#[repr(C)]
pub struct Spec { pub format: Format, pub rate: u32, pub channels: u8, }
Expand description

A sample format and attribute specification.

Fields

format: Format

The sample format.

rate: u32

The sample rate. (e.g. 44100).

channels: u8

Audio channels. (1 for mono, 2 for stereo, …).

Implementations

Maximum number of allowed channels.

Maximum allowed sample rate.

Initializes the specified sample spec.

The sample spec will have a defined state but is_valid() will fail for it.

Checks if the whole sample type specification is valid.

This is supported on crate feature pa_v5 only.

Checks only if the format attribute is valid.

Or in other words that the client library running on the end user system accepts it.

This is supported on crate feature pa_v5 only.

Checks only if the rate is within the supported range.

This is supported on crate feature pa_v5 only.

Checks only if the channel count is within the supported range.

Gets the amount of bytes that constitute playback of one second of audio, with the specified sample type.

Gets the size of a frame.

Gets the size of a sample.

Calculates the time it would take to play a buffer of the specified size.

The return value will always be rounded down for non-integral return values.

Note, the underlying calculation may overflow for very large values.

Calculates the size of a buffer required, for playback duration of the time specified.

The return value will always be rounded down for non-integral return values.

Note, the underlying calculation may overflow for very large values.

Pretty prints a sample type specification to a string.

Trait Implementations

Performs the conversion.

Performs the conversion.

Performs the conversion.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.