#[cfg(feature = "alsa")]
use crate::_alsa_raw;
use crate::{_impl_init, impl_trait};
#[doc = crate::_tags!(audio layout)]
#[doc = crate::_doc_meta!{
location("media/audio"),
test_size_of(PcmLayout = 1|8),
}]
#[must_use]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum PcmLayout {
#[default]
Interleaved,
Planar,
}
_impl_init![Self::Interleaved => PcmLayout];
impl PcmLayout {
#[must_use]
pub const fn as_code(self) -> &'static str {
match self {
Self::Interleaved => "interleaved",
Self::Planar => "planar",
}
}
#[must_use]
pub const fn as_name(self) -> &'static str {
match self {
Self::Interleaved => "Interleaved",
Self::Planar => "Planar",
}
}
#[must_use]
pub const fn is_interleaved(self) -> bool {
matches!(self, Self::Interleaved)
}
#[must_use]
pub const fn is_planar(self) -> bool {
matches!(self, Self::Planar)
}
#[cfg(feature = "alsa")]
#[cfg_attr(not(ffi_alsa··), allow(dead_code))]
pub(crate) const fn to_alsa(self) -> _alsa_raw::snd_pcm_access_t {
match self {
Self::Interleaved => _alsa_raw::SND_PCM_ACCESS_RW_INTERLEAVED,
Self::Planar => _alsa_raw::SND_PCM_ACCESS_RW_NONINTERLEAVED,
}
}
}
impl_trait![fmt::Display for PcmLayout |self, f| f.write_str(self.as_code())];