Skip to content

Commit

Permalink
- upgrade to windows 0.58.0 and fix errors in wmf and win32 backends
Browse files Browse the repository at this point in the history
  • Loading branch information
polymonster committed Jul 13, 2024
1 parent 535bc6b commit 235182a
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 85 deletions.
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ version = "0.9.0"
features = ["docking"]

[target.'cfg(windows)'.dependencies.windows]
version = "0.44.0"
version = "0.58.0"
features = [
"implement",
"Win32_Foundation",
Expand All @@ -56,6 +56,9 @@ features = [
"Win32_UI_WindowsAndMessaging",
]

[target.'cfg(windows)'.dependencies.windows-core]
version = "0.58.0"

[lib]
crate-type = ["rlib", "dylib"]

Expand Down
29 changes: 16 additions & 13 deletions src/av/wmf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,26 @@ impl NotifyEvents {

#[allow(unused_must_use)]
mod imp {
use windows::{core::*, Win32::Media::MediaFoundation::*};
#[implement(IMFMediaEngineNotify)]
use windows::Win32::Media::MediaFoundation::*;

#[windows_core::implement(IMFMediaEngineNotify)]
pub struct MediaEngineNotify {
pub notify: *mut super::NotifyEvents
}
}
pub use imp::*;

#[allow(non_snake_case)]
impl IMFMediaEngineNotify_Impl for MediaEngineNotify {
fn EventNotify(&self, event: u32, _param1: usize, _param2: u32) -> ::windows::core::Result<()> {
unsafe {
(*self.notify).event(event);
#[allow(non_snake_case)]
impl IMFMediaEngineNotify_Impl for MediaEngineNotify_Impl {
fn EventNotify(&self, event: u32, _param1: usize, _param2: u32) -> ::windows::core::Result<()> {
unsafe {
(*self.notify).event(event);
}
Ok(())
}
Ok(())
}
}
pub use imp::*;



fn new_notify_events() -> *mut NotifyEvents {
unsafe {
Expand Down Expand Up @@ -115,7 +118,7 @@ impl VideoPlayer {
let mut ext_str = "".to_string();
let ext = err.GetExtendedErrorCode();
if let Err(e) = &ext {
ext_str = e.message().to_string_lossy();
ext_str = e.message().to_string()
}

// error code with extended info
Expand All @@ -140,7 +143,7 @@ impl super::VideoPlayer<d3d12::Device> for VideoPlayer {
D3D11CreateDevice(
&adapter,
D3D_DRIVER_TYPE_UNKNOWN,
HINSTANCE(0),
HINSTANCE(std::ptr::null_mut() as *mut _),
D3D11_CREATE_DEVICE_VIDEO_SUPPORT | D3D11_CREATE_DEVICE_BGRA_SUPPORT,
None,
D3D11_SDK_VERSION,
Expand Down Expand Up @@ -171,7 +174,7 @@ impl super::VideoPlayer<d3d12::Device> for VideoPlayer {
attributes.SetUnknown(&MF_MEDIA_ENGINE_DXGI_MANAGER, &idxgi_manager)?;
}

attributes.SetUINT32(&MF_MEDIA_ENGINE_VIDEO_OUTPUT_FORMAT, DXGI_FORMAT_B8G8R8A8_UNORM.0)?;
attributes.SetUINT32(&MF_MEDIA_ENGINE_VIDEO_OUTPUT_FORMAT, DXGI_FORMAT_B8G8R8A8_UNORM.0 as u32)?;

// create event callback
let notify = new_notify_events();
Expand Down
1 change: 0 additions & 1 deletion src/gfx/d3d12.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use windows::{
Win32::Graphics::Direct3D12::*, Win32::Graphics::Dxgi::Common::*, Win32::Graphics::Dxgi::*,
Win32::System::LibraryLoader::*, Win32::System::Threading::*,
Win32::System::WindowsProgramming::*,
Win32::System::SystemServices::GENERIC_ALL
};

#[macro_export]
Expand Down
Loading

0 comments on commit 235182a

Please sign in to comment.