Closed oven425 closed 1 year ago
Hi,
It's because the parameter is defined in the SDK headers mfcaptureengine.h
as optional:
IMFCaptureSink : public IUnknown
{
...
virtual HRESULT STDMETHODCALLTYPE AddStream(
/* [annotation][in] */
_In_ DWORD dwSourceStreamIndex,
/* [annotation][in] */
_In_ IMFMediaType *pMediaType,
/* [annotation][in] */
_In_opt_ IMFAttributes *pAttributes,
/* [annotation][out] */
_Out_opt_ DWORD *pdwSinkStreamIndex) = 0;
...
};
_Out_opt_
means optional parameter https://learn.microsoft.com/en-us/cpp/code-quality/understanding-sal?view=msvc-170#sal-basics so you can pass IntPtr.Zero
when you don't need it.
With DirectN, you can use some helper that will allocate and free memory for you like this:
IMFCaptureSink sink ...
using var cm = new ComMemory(Marshal.SizeOf<uint>()); // size will be 4 obviously...
sink.AddStream(0, type, at, cm.Pointer);
// read back from pointer
var index = Marshal.ReadInt32(cm.Pointer);
Although according to msdn's instructions, it is possible to give IntPtr.Zero, but set IntPtr.Zero cause return E_POINTER Invalid pointer error. AddStream founction retrun streamindex is very import for after AddEffect function. so i recommend last agrument change to out uint
Hi,
The code is generated so no, I won't change this, I don't want to start adding too much exceptions to the ~10000 files in the project.
Report the wrong annotation to Microsoft and when they change it will be generated differently.
OK, I got it
IMFCaptureSink::AddStream last argumnt define out uint, and easy use more