global HW_CODEC_CONFIG

This commit is contained in:
csf 2022-09-16 19:41:04 +08:00
parent 723f731a20
commit e3a5218eb1
2 changed files with 14 additions and 2 deletions

View File

@ -50,6 +50,7 @@ lazy_static::lazy_static! {
pub static ref PROD_RENDEZVOUS_SERVER: Arc<RwLock<String>> = Default::default();
pub static ref APP_NAME: Arc<RwLock<String>> = Arc::new(RwLock::new("RustDesk".to_owned()));
static ref KEY_PAIR: Arc<Mutex<Option<(Vec<u8>, Vec<u8>)>>> = Default::default();
static ref HW_CODEC_CONFIG: Arc<RwLock<HwCodecConfig>> = Arc::new(RwLock::new(HwCodecConfig::load()));
}
// #[cfg(any(target_os = "android", target_os = "ios"))]
@ -1023,6 +1024,16 @@ impl HwCodecConfig {
pub fn remove() {
std::fs::remove_file(Config::file_("_hwcodec")).ok();
}
/// refresh current global HW_CODEC_CONFIG, usually uesd after HwCodecConfig::remove()
pub fn refresh() {
*HW_CODEC_CONFIG.write().unwrap() = HwCodecConfig::load();
log::debug!("HW_CODEC_CONFIG refreshed successfully");
}
pub fn get() -> HwCodecConfig {
return HW_CODEC_CONFIG.read().unwrap().clone();
}
}
#[cfg(test)]

View File

@ -267,7 +267,7 @@ impl HwDecoderImage<'_> {
}
fn get_config(k: &str) -> ResultType<CodecInfos> {
let v = HwCodecConfig::load()
let v = HwCodecConfig::get()
.options
.get(k)
.unwrap_or(&"".to_owned())
@ -323,7 +323,8 @@ pub fn check_config_process(force_reset: bool) {
std::process::Command::new(exe)
.arg("--check-hwcodec-config")
.status()
.ok()
.ok();
HwCodecConfig::refresh();
});
};
}