smourier / DirectN

Direct interop Code for .NET Framework, .NET Core and .NET 5+ : DXGI, WIC, DirectX 9 to 12, Direct2D, Direct Write, Direct Composition, Media Foundation, WASAPI, CodecAPI, GDI, Spatial Audio, DVD, Windows Media Player, UWP DXInterop, WinUI3, etc.
MIT License
311 stars 28 forks source link

IMFSourceReader::SetCurrentMediaType has an invalid binding #55

Closed austinbhale closed 3 months ago

austinbhale commented 3 months ago

Similar to your solution in https://github.com/smourier/DirectN/issues/41#issuecomment-1636109286, I had to make a couple modifications

From: https://github.com/smourier/DirectN/blob/2f640df7f4fe8d69678debdba2043b8da11020f5/DirectN/DirectN/Generated/IMFSourceReader.cs#L23

To:

HRESULT SetCurrentMediaType(int dwStreamIndex, IntPtr pdwReserved, IMFMediaType pMediaType);

The IntPtr is a logical change, but I'm not sure why specifying a uint for the first parameter was not allowed since int resolved it. This is using DirectNStandard v1.16.0 for x64

smourier commented 3 months ago

This is a different case for IMFSourceReader since it's properly annotated (old interfaces like DirectX9 are not).

But the current generated code didn't honor the _Reserved_ annotation which means it must be 0 for an int or null pointer for a pointer.

I've fixed it with this commit, https://github.com/smourier/DirectN/commit/ed373f79675dcca57f91e91bf41df41a3b245af9 It's a breaking change but it wasn't possible to run it as it was anyway.

As for int vs uint, the generator is based on native C/C++ header file so this is dependent on what the native headers define. DWORD ends up as uint. At binary level it's obviously equivalent for small positive numbers (like a stream index here).

Thanks.

austinbhale commented 3 months ago

Perfect thanks so much and for this super helpful project :)