use mpdclient_sys::{mpd_run_change_volume, mpd_run_get_volume, mpd_run_set_volume};
use crate::{Connection, error::Result};
pub struct Mixer<'a> {
connection: &'a Connection,
}
impl<'a> Mixer<'a> {
pub(crate) fn new(connection: &'a Connection) -> Self {
Self { connection }
}
pub fn get_volume(&self) -> Result<i32> {
self.connection
.get_error(|| unsafe { mpd_run_get_volume(self.connection.connection()) })
}
pub fn set_volume(&self, volume: u32) -> Result<()> {
self.connection
.get_bool_error(|| unsafe { mpd_run_set_volume(self.connection.connection(), volume) })
}
pub fn change_volume(&self, relative_volume: i32) -> Result<()> {
self.connection.get_bool_error(|| unsafe {
mpd_run_change_volume(self.connection.connection(), relative_volume)
})
}
}