impl fmt::Display for Chmap { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { letmut buf: Vec<libc::c_char> = vec![0; 512];
acheck!(snd_pcm_chmap_print(self.0, buf.len() as libc::size_t, buf.as_mut_ptr()))?; let s = from_const("snd_pcm_chmap_print", buf.as_mut_ptr())?;
write!(f, "{}", s)
}
}
impl<'a> From<&'a [ChmapPosition]> for Chmap { fn from(a: &'a [ChmapPosition]) -> Chmap { let p = unsafe { libc::malloc((mem::size_of::<alsa::snd_pcm_chmap_t>() + mem::size_of::<libc::c_uint>() * a.len()) as libc::size_t) }; if p.is_null() { panic!("Out of memory") } letmut r = Chmap(p as *mut alsa::snd_pcm_chmap_t, true);
r.set_channels(a.len() as libc::c_uint); for (i,v) in r.as_slice_mut().iter_mut().enumerate() { *v = a[i] as libc::c_uint }
r
}
}
impl<'a> From<&'a Chmap> for Vec<ChmapPosition> { fn from(a: &'a Chmap) -> Vec<ChmapPosition> {
a.as_slice().iter().map(|&v| ChmapPosition::from_c_int(v as libc::c_int, "").unwrap()).collect()
}
}
impl Iterator for ChmapsQuery { type Item = (ChmapType, Chmap); fn next(&mutself) -> Option<Self::Item> { ifself.0.is_null() { return None; } let p = unsafe { *self.0.offset(self.1) }; if p.is_null() { return None; } self.1 += 1; let t = ChmapType::from_c_int(unsafe { (*p).type_ } as libc::c_int, "snd_pcm_query_chmaps").unwrap(); let m = Chmap(unsafe { &mut (*p).map }, false);
Some((t, m))
}
}
#[test] fn chmap_for_first_pcm() { usesuper::*; use std::ffi::CString; usecrate::device_name::HintIter; let i = HintIter::new(None, &*CString::new("pcm").unwrap()).unwrap(); for p in i.map(|n| n.name.unwrap()) {
println!("Chmaps for {:?}:", p); match PCM::open(&CString::new(p).unwrap(), Direction::Playback, false) {
Ok(a) => for c in a.query_chmaps() {
println!(" {:?}, {}", c.0, c.1);
},
Err(a) => println!(" {}", a) // It's okay to have entries in the name hint array that can't be opened
}
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.9 Sekunden
(vorverarbeitet am 2026-06-18)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.