Fix some TODOs
This commit is contained in:
parent
4c09eabfd2
commit
b4ad4bf93e
@ -92,9 +92,6 @@ impl AlsaCard {
|
|||||||
cb: cb,
|
cb: cb,
|
||||||
});
|
});
|
||||||
|
|
||||||
/* TODO: callback is registered here, which must be unregistered
|
|
||||||
* when the card is destroyed!!
|
|
||||||
* poll descriptors must be unwatched too */
|
|
||||||
let watch_ids = AlsaCard::watch_poll_descriptors(vec_pollfd,
|
let watch_ids = AlsaCard::watch_poll_descriptors(vec_pollfd,
|
||||||
acard.as_ref());
|
acard.as_ref());
|
||||||
acard.watch_ids.set(watch_ids);
|
acard.watch_ids.set(watch_ids);
|
||||||
@ -199,7 +196,6 @@ impl AlsaCard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO: test that this is actually triggered when switching cards
|
|
||||||
impl Drop for AlsaCard {
|
impl Drop for AlsaCard {
|
||||||
// call Box::new(x), transmute the Box into a raw pointer, and then
|
// call Box::new(x), transmute the Box into a raw pointer, and then
|
||||||
// std::mem::forget
|
// std::mem::forget
|
||||||
@ -258,7 +254,6 @@ extern "C" fn watch_cb(chan: *mut glib_sys::GIOChannel,
|
|||||||
debug!("G_IO_STATUS_AGAIN");
|
debug!("G_IO_STATUS_AGAIN");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// TODO: handle these failure cases
|
|
||||||
glib_sys::G_IO_STATUS_NORMAL => {
|
glib_sys::G_IO_STATUS_NORMAL => {
|
||||||
error!("Alsa failed to clear the channel");
|
error!("Alsa failed to clear the channel");
|
||||||
cb(AlsaEvent::AlsaCardError);
|
cb(AlsaEvent::AlsaCardError);
|
||||||
|
20
src/audio.rs
20
src/audio.rs
@ -181,6 +181,21 @@ impl Audio {
|
|||||||
*rc = glib::get_monotonic_time();
|
*rc = glib::get_monotonic_time();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let alsa_vol = percent_to_vol(new_vol,
|
||||||
|
self.acard.borrow().get_volume_range(),
|
||||||
|
dir)?;
|
||||||
|
|
||||||
|
/* only invoke handlers etc. if volume did actually change */
|
||||||
|
{
|
||||||
|
let old_alsa_vol = percent_to_vol(self.vol()?,
|
||||||
|
self.acard.borrow().get_volume_range(),
|
||||||
|
dir)?;
|
||||||
|
|
||||||
|
if old_alsa_vol == alsa_vol {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* auto-unmute */
|
/* auto-unmute */
|
||||||
if self.has_mute() && self.get_mute()? {
|
if self.has_mute() && self.get_mute()? {
|
||||||
self.set_mute(false, user)?;
|
self.set_mute(false, user)?;
|
||||||
@ -198,14 +213,10 @@ impl Audio {
|
|||||||
new_vol,
|
new_vol,
|
||||||
user);
|
user);
|
||||||
|
|
||||||
let alsa_vol = percent_to_vol(new_vol,
|
|
||||||
self.acard.borrow().get_volume_range(),
|
|
||||||
dir)?;
|
|
||||||
self.acard
|
self.acard
|
||||||
.borrow()
|
.borrow()
|
||||||
.set_vol(alsa_vol)?;
|
.set_vol(alsa_vol)?;
|
||||||
|
|
||||||
// TODO: only invoke handlers if volume did not change
|
|
||||||
invoke_handlers(&self.handlers.borrow(),
|
invoke_handlers(&self.handlers.borrow(),
|
||||||
AudioSignal::ValuesChanged,
|
AudioSignal::ValuesChanged,
|
||||||
user);
|
user);
|
||||||
@ -313,7 +324,6 @@ fn on_alsa_event(last_action_timestamp: &mut i64,
|
|||||||
|
|
||||||
/* external change */
|
/* external change */
|
||||||
match alsa_event {
|
match alsa_event {
|
||||||
// TODO: invoke handlers with AudioUserUnknown
|
|
||||||
AlsaEvent::AlsaCardError => {
|
AlsaEvent::AlsaCardError => {
|
||||||
invoke_handlers(handlers,
|
invoke_handlers(handlers,
|
||||||
self::AudioSignal::CardError,
|
self::AudioSignal::CardError,
|
||||||
|
12
src/prefs.rs
12
src/prefs.rs
@ -101,17 +101,17 @@ impl Default for ViewPrefs {
|
|||||||
#[derive(Deserialize, Debug, Serialize)]
|
#[derive(Deserialize, Debug, Serialize)]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub struct VolColor {
|
pub struct VolColor {
|
||||||
pub red: u8,
|
pub red: f64,
|
||||||
pub green: u8,
|
pub green: f64,
|
||||||
pub blue: u8,
|
pub blue: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for VolColor {
|
impl Default for VolColor {
|
||||||
fn default() -> VolColor {
|
fn default() -> VolColor {
|
||||||
return VolColor {
|
return VolColor {
|
||||||
red: 245,
|
red: 0.960784313725,
|
||||||
green: 180,
|
green: 0.705882352941,
|
||||||
blue: 0,
|
blue: 0.0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ use errors::*;
|
|||||||
use prefs::*;
|
use prefs::*;
|
||||||
|
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug)]
|
||||||
pub enum VolDir {
|
pub enum VolDir {
|
||||||
Up,
|
Up,
|
||||||
Down,
|
Down,
|
||||||
|
@ -111,11 +111,10 @@ impl PrefsDialog {
|
|||||||
self.vol_meter_pos_spin.set_value(prefs.view_prefs.vol_meter_offset as
|
self.vol_meter_pos_spin.set_value(prefs.view_prefs.vol_meter_offset as
|
||||||
f64);
|
f64);
|
||||||
|
|
||||||
// TODO don't convert like that
|
|
||||||
let rgba = gdk::RGBA {
|
let rgba = gdk::RGBA {
|
||||||
red: prefs.view_prefs.vol_meter_color.red as f64 / 255.0,
|
red: prefs.view_prefs.vol_meter_color.red,
|
||||||
green: prefs.view_prefs.vol_meter_color.green as f64 / 255.0,
|
green: prefs.view_prefs.vol_meter_color.green,
|
||||||
blue: prefs.view_prefs.vol_meter_color.blue as f64 / 255.0,
|
blue: prefs.view_prefs.vol_meter_color.blue,
|
||||||
alpha: 1.0,
|
alpha: 1.0,
|
||||||
};
|
};
|
||||||
self.vol_meter_color_button.set_rgba(&rgba);
|
self.vol_meter_color_button.set_rgba(&rgba);
|
||||||
@ -162,22 +161,27 @@ impl PrefsDialog {
|
|||||||
|
|
||||||
|
|
||||||
fn to_prefs(&self) -> Prefs {
|
fn to_prefs(&self) -> Prefs {
|
||||||
// TODO: remove duplication with default instance
|
let card = self.card_combo.get_active_text();
|
||||||
|
let channel = self.chan_combo.get_active_text();
|
||||||
|
|
||||||
|
if card.is_none() || channel.is_none() {
|
||||||
|
return Prefs::default();
|
||||||
|
}
|
||||||
|
|
||||||
let device_prefs =
|
let device_prefs =
|
||||||
DevicePrefs {
|
DevicePrefs {
|
||||||
card: self.card_combo
|
card: self.card_combo
|
||||||
.get_active_text()
|
.get_active_text()
|
||||||
.unwrap_or(String::from("(default)")),
|
.unwrap(),
|
||||||
channel: self.chan_combo
|
channel: self.chan_combo
|
||||||
.get_active_text()
|
.get_active_text()
|
||||||
.unwrap_or(String::from("Master")),
|
.unwrap(),
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO save raw values?
|
|
||||||
let vol_meter_color = VolColor {
|
let vol_meter_color = VolColor {
|
||||||
red: (self.vol_meter_color_button.get_rgba().red * 255.0) as u8,
|
red: (self.vol_meter_color_button.get_rgba().red),
|
||||||
green: (self.vol_meter_color_button.get_rgba().green * 255.0) as u8,
|
green: (self.vol_meter_color_button.get_rgba().green),
|
||||||
blue: (self.vol_meter_color_button.get_rgba().blue * 255.0) as u8,
|
blue: (self.vol_meter_color_button.get_rgba().blue),
|
||||||
};
|
};
|
||||||
|
|
||||||
let view_prefs = ViewPrefs {
|
let view_prefs = ViewPrefs {
|
||||||
|
@ -159,9 +159,9 @@ pub struct VolMeter {
|
|||||||
impl VolMeter {
|
impl VolMeter {
|
||||||
fn new(prefs: &Prefs) -> VolMeter {
|
fn new(prefs: &Prefs) -> VolMeter {
|
||||||
return VolMeter {
|
return VolMeter {
|
||||||
red: prefs.view_prefs.vol_meter_color.red,
|
red: (prefs.view_prefs.vol_meter_color.red * 255.0) as u8,
|
||||||
green: prefs.view_prefs.vol_meter_color.green,
|
green: (prefs.view_prefs.vol_meter_color.green * 255.0) as u8,
|
||||||
blue: prefs.view_prefs.vol_meter_color.blue,
|
blue: (prefs.view_prefs.vol_meter_color.blue * 255.0) as u8,
|
||||||
x_offset_pct: prefs.view_prefs.vol_meter_offset as i64,
|
x_offset_pct: prefs.view_prefs.vol_meter_offset as i64,
|
||||||
y_offset_pct: 10,
|
y_offset_pct: 10,
|
||||||
/* dynamic */
|
/* dynamic */
|
||||||
|
Loading…
Reference in New Issue
Block a user