mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
@@ -2,7 +2,7 @@ use docopt::Docopt;
|
||||
use hbb_common::env_logger::{init_from_env, Env, DEFAULT_FILTER_ENV};
|
||||
use scrap::{
|
||||
aom::{AomDecoder, AomEncoder, AomEncoderConfig},
|
||||
codec::{codec_thread_num, EncoderApi, EncoderCfg, Quality as Q},
|
||||
codec::{EncoderApi, EncoderCfg, Quality as Q},
|
||||
Capturer, Display, TraitCapturer, VpxDecoder, VpxDecoderConfig, VpxEncoder, VpxEncoderConfig,
|
||||
VpxVideoCodecId::{self, *},
|
||||
STRIDE_ALIGN,
|
||||
@@ -202,6 +202,7 @@ mod hw {
|
||||
RateControl::*,
|
||||
};
|
||||
use scrap::{
|
||||
codec::codec_thread_num,
|
||||
convert::{
|
||||
hw::{hw_bgra_to_i420, hw_bgra_to_nv12},
|
||||
i420_to_bgra,
|
||||
|
||||
@@ -514,10 +514,11 @@ pub fn base_bitrate(width: u32, height: u32) -> u32 {
|
||||
|
||||
pub fn codec_thread_num() -> usize {
|
||||
let max: usize = num_cpus::get();
|
||||
let mut res = 0;
|
||||
let mut res;
|
||||
let info;
|
||||
#[cfg(windows)]
|
||||
{
|
||||
res = 0;
|
||||
let percent = hbb_common::platform::windows::cpu_uage_one_minute();
|
||||
info = format!("cpu usage:{:?}", percent);
|
||||
if let Some(pecent) = percent {
|
||||
@@ -545,7 +546,7 @@ pub fn codec_thread_num() -> usize {
|
||||
None => true,
|
||||
};
|
||||
if log {
|
||||
log::info!("cpu num: {max}, {info}, codec thread: {res}");
|
||||
log::info!("cpu num:{max}, {info}, codec thread:{res}");
|
||||
*THREAD_LOG_TIME.lock().unwrap() = Some(Instant::now());
|
||||
}
|
||||
res
|
||||
|
||||
@@ -364,8 +364,8 @@ pub fn check_config() {
|
||||
|
||||
pub fn check_config_process() {
|
||||
use hbb_common::sysinfo::{ProcessExt, System, SystemExt};
|
||||
|
||||
std::thread::spawn(move || {
|
||||
use std::sync::Once;
|
||||
let f = || {
|
||||
// Clear to avoid checking process errors
|
||||
// But when the program is just started, the configuration file has not been updated, and the new connection will read an empty configuration
|
||||
HwCodecConfig::clear();
|
||||
@@ -393,7 +393,9 @@ pub fn check_config_process() {
|
||||
allow_err!(child.kill());
|
||||
std::thread::sleep(std::time::Duration::from_millis(30));
|
||||
match child.try_wait() {
|
||||
Ok(Some(status)) => log::info!("Check hwcodec config, exit with: {status}"),
|
||||
Ok(Some(status)) => {
|
||||
log::info!("Check hwcodec config, exit with: {status}")
|
||||
}
|
||||
Ok(None) => {
|
||||
log::info!(
|
||||
"Check hwcodec config, status not ready yet, let's really wait"
|
||||
@@ -409,5 +411,9 @@ pub fn check_config_process() {
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
static ONCE: Once = Once::new();
|
||||
ONCE.call_once(|| {
|
||||
std::thread::spawn(f);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user