disable hwcodec if causing crash

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages 2023-04-04 20:35:04 +08:00
parent 8b78510ea7
commit f2aeff974c
3 changed files with 24 additions and 11 deletions

View File

@ -29,6 +29,16 @@ extern "C" fn breakdown_signal_handler(sig: i32) {
info = "Always use software rendering will be set.".to_string();
log::info!("{}", info);
}
if stack.iter().any(|s| {
s.to_lowercase().contains("nvidia")
|| s.to_lowercase().contains("amf")
|| s.to_lowercase().contains("mfx")
|| s.contains("cuProfilerStop")
}) {
Config::set_option("enable-hwcodec".to_string(), "N".to_string());
info = "Perhaps hwcodec causing the crash, disable it first".to_string();
log::info!("{}", info);
}
log::error!(
"Got signal {} and exit. stack:\n{}",
sig,

View File

@ -109,6 +109,7 @@ impl Encoder {
}),
Err(e) => {
check_config_process(true);
*CODEC_NAME.lock().unwrap() = CodecName::VP9;
Err(e)
}
},
@ -144,16 +145,18 @@ impl Encoder {
let mut h265_name = None;
#[cfg(feature = "hwcodec")]
{
let best = HwEncoder::best();
let h264_useable =
decodings.len() > 0 && decodings.iter().all(|(_, s)| s.ability_h264 > 0);
let h265_useable =
decodings.len() > 0 && decodings.iter().all(|(_, s)| s.ability_h265 > 0);
if h264_useable {
h264_name = best.h264.map_or(None, |c| Some(c.name));
}
if h265_useable {
h265_name = best.h265.map_or(None, |c| Some(c.name));
if enable_hwcodec_option() {
let best = HwEncoder::best();
let h264_useable =
decodings.len() > 0 && decodings.iter().all(|(_, s)| s.ability_h264 > 0);
let h265_useable =
decodings.len() > 0 && decodings.iter().all(|(_, s)| s.ability_h265 > 0);
if h264_useable {
h264_name = best.h264.map_or(None, |c| Some(c.name));
}
if h265_useable {
h265_name = best.h265.map_or(None, |c| Some(c.name));
}
}
}

View File

@ -544,7 +544,7 @@ impl<T: InvokeUiSession> Session<T> {
let key = rdev::key_from_code(position_code) as rdev::Key;
// Windows requires special handling
#[cfg(target_os = "windows")]
let key = rdev::get_win_key(keycode, scancode);
let key = rdev::get_win_key(platform_code, position_code);
let event_type = if down_or_up {
KeyPress(key)