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, self::AudioUser::Unknown,
); );
} }
AlsaEvent::AlsaCardReload => {
invoke_handlers(
handlers,
self::AudioSignal::CardReload,
self::AudioUser::Unknown,
);
}
} }
} }

View File

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

View File

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

View File

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