Fix more Windows crate 0.58 API changes
- GetDesc now returns value instead of mutable param - CPUAccessFlags is u32, not flag wrapper - SetEvictionPriority takes enum directly - Fix encode_utf16 iteration - Rename display variable to avoid tracing conflict - Fix borrow issue in websocket receive
This commit is contained in:
@@ -13,7 +13,7 @@ use std::time::Instant;
|
||||
use windows::Win32::Graphics::Direct3D::D3D_DRIVER_TYPE_UNKNOWN;
|
||||
use windows::Win32::Graphics::Direct3D11::{
|
||||
D3D11CreateDevice, ID3D11Device, ID3D11DeviceContext, ID3D11Texture2D,
|
||||
D3D11_CPU_ACCESS_FLAG, D3D11_SDK_VERSION, D3D11_TEXTURE2D_DESC,
|
||||
D3D11_SDK_VERSION, D3D11_TEXTURE2D_DESC,
|
||||
D3D11_USAGE_STAGING, D3D11_MAPPED_SUBRESOURCE, D3D11_MAP_READ,
|
||||
};
|
||||
use windows::Win32::Graphics::Dxgi::{
|
||||
@@ -94,14 +94,13 @@ impl DxgiCapturer {
|
||||
.context("Failed to create output duplication")?;
|
||||
|
||||
// Get duplication description
|
||||
let mut desc = DXGI_OUTDUPL_DESC::default();
|
||||
duplication.GetDesc(&mut desc);
|
||||
let desc = duplication.GetDesc();
|
||||
|
||||
tracing::info!(
|
||||
"Created DXGI duplication: {}x{}, display: {}",
|
||||
desc.ModeDesc.Width,
|
||||
desc.ModeDesc.Height,
|
||||
display.name
|
||||
&display.name
|
||||
);
|
||||
|
||||
Ok((device, context, duplication, desc))
|
||||
@@ -133,8 +132,7 @@ impl DxgiCapturer {
|
||||
};
|
||||
|
||||
// Check if this is the display we want
|
||||
let mut desc = Default::default();
|
||||
output.GetDesc(&mut desc)?;
|
||||
let desc = output.GetDesc()?;
|
||||
|
||||
let name = String::from_utf16_lossy(
|
||||
&desc.DeviceName[..desc.DeviceName.iter().position(|&c| c == 0).unwrap_or(desc.DeviceName.len())]
|
||||
@@ -169,7 +167,7 @@ impl DxgiCapturer {
|
||||
|
||||
desc.Usage = D3D11_USAGE_STAGING;
|
||||
desc.BindFlags = Default::default();
|
||||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_FLAG(0x20000); // D3D11_CPU_ACCESS_READ
|
||||
desc.CPUAccessFlags = 0x20000; // D3D11_CPU_ACCESS_READ
|
||||
desc.MiscFlags = Default::default();
|
||||
|
||||
let mut staging: Option<ID3D11Texture2D> = None;
|
||||
@@ -180,7 +178,7 @@ impl DxgiCapturer {
|
||||
|
||||
// Set high priority
|
||||
let resource: IDXGIResource = staging.cast()?;
|
||||
resource.SetEvictionPriority(DXGI_RESOURCE_PRIORITY_MAXIMUM.0)?;
|
||||
resource.SetEvictionPriority(DXGI_RESOURCE_PRIORITY_MAXIMUM)?;
|
||||
|
||||
self.staging_texture = Some(staging);
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ impl KeyboardController {
|
||||
let encoded = ch.encode_utf16(&mut buf);
|
||||
|
||||
// For characters that fit in a single u16
|
||||
for &code_unit in encoded {
|
||||
for &code_unit in encoded.iter() {
|
||||
// Key down
|
||||
inputs.push(INPUT {
|
||||
r#type: INPUT_KEYBOARD,
|
||||
|
||||
@@ -65,12 +65,12 @@ impl SessionManager {
|
||||
self.state = SessionState::Active;
|
||||
|
||||
// Get primary display
|
||||
let display = capture::primary_display()?;
|
||||
tracing::info!("Using display: {} ({}x{})", display.name, display.width, display.height);
|
||||
let primary_display = capture::primary_display()?;
|
||||
tracing::info!("Using display: {} ({}x{})", primary_display.name, primary_display.width, primary_display.height);
|
||||
|
||||
// Create capturer
|
||||
let mut capturer = capture::create_capturer(
|
||||
display.clone(),
|
||||
primary_display.clone(),
|
||||
self.config.capture.use_dxgi,
|
||||
self.config.capture.gdi_fallback,
|
||||
)?;
|
||||
|
||||
@@ -122,9 +122,12 @@ impl WebSocketTransport {
|
||||
return Ok(Some(msg));
|
||||
}
|
||||
|
||||
let result = {
|
||||
let mut stream = self.stream.lock().await;
|
||||
stream.next().await
|
||||
};
|
||||
|
||||
match stream.next().await {
|
||||
match result {
|
||||
Some(Ok(ws_msg)) => self.parse_message(ws_msg),
|
||||
Some(Err(e)) => {
|
||||
self.connected = false;
|
||||
|
||||
Reference in New Issue
Block a user