Struct Map

Source
#[repr(C)]
pub struct Map { /* private fields */ }
Expand description

A channel map which can be used to attach labels to specific channels of a stream.

These values are relevant for conversion and mixing of streams.

Implementations§

Source§

impl Map

Source

pub const CHANNELS_MAX: u8 = 32u8

Maximum number of allowed channels.

Source

pub fn new_from_string(s: &str) -> Result<Self, ()>

Parses a channel position list or well-known mapping name into a channel map structure.

This turns the output of print() and to_name() back into a Map.

Source

pub fn init(&mut self) -> &mut Self

Initializes the specified channel map and returns a pointer to it.

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

Source

pub fn init_mono(&mut self) -> &mut Self

Initializes the specified channel map for monaural audio and returns a pointer to it.

Source

pub fn init_stereo(&mut self) -> &mut Self

Initializes the specified channel map for stereophonic audio and returns a pointer to it.

Source

pub fn init_auto(&mut self, channels: u8, def: MapDef) -> Option<&mut Self>

Initializes the specified channel map for the specified number of channels using default labels and returns a pointer to it.

This call will fail (return None) if there is no default channel map known for this specific number of channels and mapping.

Source

pub fn init_extend(&mut self, channels: u8, def: MapDef) -> &mut Self

Similar to init_auto() but instead of failing if no default mapping is known with the specified parameters it will synthesize a mapping based on a known mapping with fewer channels and fill up the rest with AUX0…AUX31 channels.

Source

pub fn is_valid(&self) -> bool

Checks whether or not the map is considered valid.

Source

pub const fn len(&self) -> u8

Gets the number of active channels.

Source

pub fn set_len(&mut self, channels: u8)

Sets the number of active channels.

Positions for up to Self::CHANNELS_MAX channels can be held. This sets the portion of the internal array considered “active” and thus available for reading/writing (i.e. when borrowing self as a slice).

Panics if the number of channels specified is greater than Self::CHANNELS_MAX.

Source

pub fn get(&self) -> &[Position]

Gets an immutable slice of the set of “active” channels.

Source

pub fn get_mut(&mut self) -> &mut [Position]

Gets a mutable slice of the set of “active” channels.

Source

pub fn print(&self) -> String

Makes a human readable string from the map.

Source

pub fn is_compatible_with_sample_spec(&self, ss: &Spec) -> bool

Checks whether or not the specified map is compatible with the specified sample spec.

Source

pub fn is_superset_of(&self, of: &Self) -> bool

Checks whether every channel defined in of is also defined in self.

Source

pub fn can_balance(&self) -> bool

Checks whether or not it makes sense to apply a volume “balance” with this mapping, i.e. if there are left/right channels available.

Source

pub fn can_fade(&self) -> bool

Checks whether or not it makes sense to apply a volume “fade” (i.e. “balance” between front and rear) with this mapping, i.e. if there are front/rear channels available.

Source

pub fn can_lfe_balance(&self) -> bool

Available on crate feature pa_v8 only.

Checks whether or not it makes sense to apply a volume “LFE balance” (i.e. “balance” between LFE and non-LFE channels) with this mapping, i.e. if there are LFE and non-LFE channels available.

Source

pub fn to_name(&self) -> Option<Cow<'static, str>>

Tries to find a well-known channel mapping name for this channel mapping, i.e. “stereo”, “surround-71” and so on. This name can be parsed with new_from_string().

Source

pub fn to_pretty_name(&self) -> Option<String>

Similar to to_name(), but returning prettier, human readable text labels, i.e. “Stereo”, “Surround 7.1” and so on.

Source

pub fn has_position(&self, p: Position) -> bool

Checks whether or not the specified channel position is available at least once in the map.

Source

pub fn get_mask(&self) -> PositionMask

Generates a bit mask from a map.

Trait Implementations§

Source§

impl AsMut<pa_channel_map> for Map

Source§

fn as_mut(&mut self) -> &mut pa_channel_map

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<Map> for pa_channel_map

Source§

fn as_ref(&self) -> &Map

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<pa_channel_map> for Map

Source§

fn as_ref(&self) -> &pa_channel_map

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<[Position]> for Map

Source§

fn borrow(&self) -> &[Position]

Immutably borrows from an owned value. Read more
Source§

impl BorrowMut<[Position]> for Map

Source§

fn borrow_mut(&mut self) -> &mut [Position]

Mutably borrows from an owned value. Read more
Source§

impl Clone for Map

Source§

fn clone(&self) -> Map

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Map

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Map

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<pa_channel_map> for Map

Source§

fn from(m: pa_channel_map) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Map

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Map

Auto Trait Implementations§

§

impl Freeze for Map

§

impl RefUnwindSafe for Map

§

impl Send for Map

§

impl Sync for Map

§

impl Unpin for Map

§

impl UnwindSafe for Map

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.