diff --git a/src/audio.rs b/src/audio.rs index abb178057..93f18b170 100644 --- a/src/audio.rs +++ b/src/audio.rs @@ -129,19 +129,21 @@ pub fn watch_poll_descriptors( mixer: RefCell, ) -> Vec { let mut watch_ids: Vec = vec![]; - let mixer = unsafe { - mem::transmute::(mixer.into_inner()) + let mixer = mixer.into_inner(); + let mixer_ptr = unsafe { + mem::transmute::(mixer) }; for poll in polls { unsafe { - let gioc: *mut glib_sys::GIOChannel = glib_sys::g_io_channel_unix_new(poll.fd); + let gioc: *mut glib_sys::GIOChannel = + glib_sys::g_io_channel_unix_new(poll.fd); watch_ids.push(glib_sys::g_io_add_watch( gioc, glib_sys::GIOCondition::from_bits( glib_sys::G_IO_IN.bits() | glib_sys::G_IO_ERR.bits(), ).unwrap(), Some(watch_cb), - mixer as glib_sys::gpointer, + mixer_ptr as glib_sys::gpointer, )); } } @@ -149,15 +151,12 @@ pub fn watch_poll_descriptors( return watch_ids; } -extern "C" fn watch_cb( +extern fn watch_cb( chan: *mut glib_sys::GIOChannel, cond: glib_sys::GIOCondition, data: glib_sys::gpointer, ) -> glib_sys::gboolean { - // println!("Blah"); - // println!("GIOC: {:?}", chan); - let mixer = data as *mut alsa_sys::snd_mixer_t; unsafe { @@ -168,28 +167,28 @@ extern "C" fn watch_cb( return false as glib_sys::gboolean; } - // println!("GIOC (later): {:?}", chan); - let mut sread: usize = 1; + let mut sread: size_t = 1; let mut buf: u8 = 0; while sread > 0 { - let stat = unsafe { glib_sys::g_io_channel_read_chars(chan, - &mut buf as *mut u8, - 250, - &mut sread as *mut size_t, - ptr::null_mut()) + let stat: glib_sys::GIOStatus = unsafe { + glib_sys::g_io_channel_read_chars( + chan, + &mut buf as *mut u8, + 256, + &mut sread as *mut size_t, + ptr::null_mut(), + ) }; match stat { glib_sys::G_IO_STATUS_AGAIN => continue, - glib_sys::G_IO_STATUS_NORMAL => (), - glib_sys::G_IO_STATUS_ERROR => (), - glib_sys::G_IO_STATUS_EOF => (), - _ => (), + glib_sys::G_IO_STATUS_NORMAL => println!("G_IO_STATUS_NORMAL"), + glib_sys::G_IO_STATUS_ERROR => println!("G_IO_STATUS_ERROR"), + glib_sys::G_IO_STATUS_EOF => println!("G_IO_STATUS_EOF"), } return true as glib_sys::gboolean; - }; + } return true as glib_sys::gboolean; } - diff --git a/src/main.rs b/src/main.rs index 84eb97654..baf09eec9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,5 @@ +#![feature(alloc_system)] +extern crate alloc_system; extern crate flexi_logger; #[macro_use] @@ -34,11 +36,6 @@ mod app_state; fn main() { gtk::init().unwrap(); - - let x = 4 / 0; - - println!("Zero: {}", x); - let ref apps = AppS { status_icon: gtk::StatusIcon::new_from_icon_name("pnmixer"), builder_popup: gtk::Builder::new_from_string( @@ -47,10 +44,7 @@ fn main() { }; let acard = Rc::new(RefCell::new( - AlsaCard::new( - None, - Some(String::from("Master")), - ).unwrap(), + AlsaCard::new(None, Some(String::from("Master"))).unwrap(), )); flexi_logger::LogOptions::new()