Automatically reload sound system when alsa channel is skewed

Bug report: https://github.com/nicklan/pnmixer/issues/182
This commit is contained in:
Julian Ospald 2018-06-20 19:28:58 +02:00
parent c7a200085b
commit 0a39aa82b6
No known key found for this signature in database
GPG Key ID: 511B62C09D50CD28
4 changed files with 22 additions and 4 deletions

View File

@ -352,5 +352,12 @@ fn on_alsa_event(
self::AudioUser::Unknown,
);
}
AlsaEvent::AlsaCardReload => {
invoke_handlers(
handlers,
self::AudioSignal::CardReload,
self::AudioUser::Unknown,
);
}
}
}

View File

@ -32,6 +32,8 @@ pub enum AlsaEvent {
AlsaCardDiconnected,
/// The values of the mixer changed, including mute state.
AlsaCardValuesChanged,
/// Alsa needs to be reloaded due to recoverable error.
AlsaCardReload,
}
@ -236,8 +238,9 @@ extern "C" fn watch_cb(
continue;
}
glib_sys::G_IO_STATUS_NORMAL => {
error!("Alsa failed to clear the channel");
cb(AlsaEvent::AlsaCardError);
// BUG: https://github.com/nicklan/pnmixer/issues/182
warn!("Alsa failed to clear the channel");
cb(AlsaEvent::AlsaCardReload);
}
glib_sys::G_IO_STATUS_ERROR => (),
glib_sys::G_IO_STATUS_EOF => {

View File

@ -49,6 +49,7 @@ pub enum AudioSignal {
CardDisconnected,
CardError,
ValuesChanged,
CardReload,
}

View File

@ -72,7 +72,7 @@ where
&apps.prefs.borrow(),
AudioUser::Unknown,
));
}
},
(AudioSignal::CardError, _) => {
if run_audio_error_dialog(
&apps.gui.popup_menu.menu_window,
@ -84,7 +84,14 @@ where
AudioUser::Unknown,
));
}
}
},
(AudioSignal::CardReload, _) => {
try_w!(audio_reload(
apps.audio.as_ref(),
&apps.prefs.borrow(),
AudioUser::Unknown,
));
},
_ => (),
}),
);