1use crate::{alsa};
7use super::error::*;
8use super::Output;
9use core::ptr;
10
11pub fn update() -> Result<bool> {
12 acheck!(snd_config_update()).map(|x| x != 0)
13}
14
15pub fn update_free_global() -> Result<()> {
16 acheck!(snd_config_update_free_global()).map(|_| ())
17}
18
19#[derive(Debug)]
21pub struct Config(*mut alsa::snd_config_t);
22
23impl Drop for Config {
24 fn drop(&mut self) { unsafe { alsa::snd_config_unref(self.0) }; }
25}
26
27pub fn update_ref() -> Result<Config> {
28 let mut top = ptr::null_mut();
29 acheck!(snd_config_update_ref(&mut top)).map(|_| Config(top))
30}
31
32impl Config {
33 pub fn save(&self, o: &mut Output) -> Result<()> {
34 acheck!(snd_config_save(self.0, super::io::output_handle(o))).map(|_| ())
35 }
36}
37
38#[test]
39fn config_save() {
40 extern crate std;
41 let c = update_ref().unwrap();
42 let mut outp = Output::buffer_open().unwrap();
43 c.save(&mut outp).unwrap();
44 std::println!("== Config save ==\n{}", outp);
45}