mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
fix black screen issue when controlling the second screen on versions that lack multiple display support while using vram decoding (#7836)
* avoid create unnecessary video decoder Signed-off-by: 21pages <pages21@163.com> * controlled side uses the most frequent selected codec Signed-off-by: 21pages <pages21@163.com> * fix black screen when control old version's second screen For versions that do not support multiple displays, the display parameter is always 0, need set type of current display Signed-off-by: 21pages <pages21@163.com> --------- Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
@@ -221,7 +221,6 @@ impl Encoder {
|
||||
let h265_useable =
|
||||
_all_support_h265_decoding && (h265vram_encoding || h265hw_encoding.is_some());
|
||||
let mut name = ENCODE_CODEC_NAME.lock().unwrap();
|
||||
let mut preference = PreferCodec::Auto;
|
||||
let preferences: Vec<_> = decodings
|
||||
.iter()
|
||||
.filter(|(_, s)| {
|
||||
@@ -233,9 +232,20 @@ impl Encoder {
|
||||
})
|
||||
.map(|(_, s)| s.prefer)
|
||||
.collect();
|
||||
if preferences.len() > 0 && preferences.iter().all(|&p| p == preferences[0]) {
|
||||
preference = preferences[0].enum_value_or(PreferCodec::Auto);
|
||||
// find the most frequent preference
|
||||
let mut counts = Vec::new();
|
||||
for pref in &preferences {
|
||||
match counts.iter_mut().find(|(p, _)| p == pref) {
|
||||
Some((_, count)) => *count += 1,
|
||||
None => counts.push((pref.clone(), 1)),
|
||||
}
|
||||
}
|
||||
let max_count = counts.iter().map(|(_, count)| *count).max().unwrap_or(0);
|
||||
let (most_frequent, _) = counts
|
||||
.into_iter()
|
||||
.find(|(_, count)| *count == max_count)
|
||||
.unwrap_or((PreferCodec::Auto.into(), 0));
|
||||
let preference = most_frequent.enum_value_or(PreferCodec::Auto);
|
||||
|
||||
#[allow(unused_mut)]
|
||||
let mut auto_codec = CodecName::VP9;
|
||||
|
||||
@@ -24,8 +24,6 @@ use hwcodec::{
|
||||
},
|
||||
};
|
||||
|
||||
const OUTPUT_SHARED_HANDLE: bool = false;
|
||||
|
||||
// https://www.reddit.com/r/buildapc/comments/d2m4ny/two_graphics_cards_two_monitors/
|
||||
// https://www.reddit.com/r/techsupport/comments/t2v9u6/dual_monitor_setup_with_dual_gpu/
|
||||
// https://cybersided.com/two-monitors-two-gpus/
|
||||
@@ -331,8 +329,8 @@ impl VRamDecoder {
|
||||
}
|
||||
|
||||
pub fn new(format: CodecFormat, luid: Option<i64>) -> ResultType<Self> {
|
||||
log::info!("try create {format:?} vram decoder, luid: {luid:?}");
|
||||
let ctx = Self::try_get(format, luid).ok_or(anyhow!("Failed to get decode context"))?;
|
||||
log::info!("try create vram decoder: {ctx:?}");
|
||||
match Decoder::new(ctx) {
|
||||
Ok(decoder) => Ok(Self { decoder }),
|
||||
Err(_) => {
|
||||
@@ -376,7 +374,7 @@ pub(crate) fn check_available_vram() -> String {
|
||||
gop: MAX_GOP as _,
|
||||
};
|
||||
let encoders = encode::available(d);
|
||||
let decoders = decode::available(OUTPUT_SHARED_HANDLE);
|
||||
let decoders = decode::available();
|
||||
let available = Available {
|
||||
e: encoders,
|
||||
d: decoders,
|
||||
|
||||
Reference in New Issue
Block a user