Add destructor for AlsaCard
This commit is contained in:
parent
f3fc6aca23
commit
92514a2fd0
67
src/audio.rs
67
src/audio.rs
@ -18,6 +18,34 @@ use std::u8;
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum AudioUser {
|
||||
AudioUserUnknown,
|
||||
AudioUserPopup,
|
||||
AudioUserTrayIcon,
|
||||
AudioUserHotkeys,
|
||||
}
|
||||
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum AudioSignal {
|
||||
AudioNoCard,
|
||||
AudioCardInitialized,
|
||||
AudioCardCleanedUp,
|
||||
AudioCardDisconnected,
|
||||
AudioCardError,
|
||||
AudioValuesChanged,
|
||||
}
|
||||
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum AlsaEvent {
|
||||
AlsaCardError,
|
||||
AlsaCardDiconnected,
|
||||
AlsaCardValuesChanged,
|
||||
}
|
||||
|
||||
|
||||
// TODO: implement free/destructor
|
||||
pub struct AlsaCard {
|
||||
_cannot_construct: (),
|
||||
@ -163,31 +191,11 @@ impl AlsaCard {
|
||||
}
|
||||
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum AudioUser {
|
||||
AudioUserUnknown,
|
||||
AudioUserPopup,
|
||||
AudioUserTrayIcon,
|
||||
AudioUserHotkeys,
|
||||
}
|
||||
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum AudioSignal {
|
||||
AudioNoCard,
|
||||
AudioCardInitialized,
|
||||
AudioCardCleanedUp,
|
||||
AudioCardDisconnected,
|
||||
AudioCardError,
|
||||
AudioValuesChanged,
|
||||
}
|
||||
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum AlsaEvent {
|
||||
AlsaCardError,
|
||||
AlsaCardDiconnected,
|
||||
AlsaCardValuesChanged,
|
||||
impl Drop for AlsaCard {
|
||||
fn drop (&mut self) {
|
||||
debug!("Destructing watch_ids: {:?}", self.watch_ids);
|
||||
unwatch_poll_descriptors(&self.watch_ids);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -218,6 +226,15 @@ fn watch_poll_descriptors(polls: Vec<pollfd>,
|
||||
}
|
||||
|
||||
|
||||
fn unwatch_poll_descriptors(watch_ids: &Vec<u32>) {
|
||||
for watch_id in watch_ids {
|
||||
unsafe {
|
||||
glib_sys::g_source_remove(*watch_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extern "C" fn watch_cb(chan: *mut glib_sys::GIOChannel,
|
||||
cond: glib_sys::GIOCondition,
|
||||
data: glib_sys::gpointer)
|
||||
|
Loading…
Reference in New Issue
Block a user