Rémi Bernon (@rbernon) commented about dlls/winegstreamer/h264_decoder.c:
+static HRESULT initialize_allocator(struct h264_decoder *decoder) +{ + IMFAttributes *attributes = NULL; + HRESULT hr; + + if (FAILED(hr = MFCreateVideoSampleAllocatorEx(&IID_IMFVideoSampleAllocatorEx, (void **)&decoder->allocator))) + return hr; + if (FAILED(hr = IMFVideoSampleAllocatorEx_SetDirectXManager(decoder->allocator, (IUnknown *)decoder->dxgi_manager))) + goto done; + if (FAILED(hr = MFCreateAttributes(&attributes, 0))) + goto done; + hr = IMFVideoSampleAllocatorEx_InitializeSampleAllocatorEx(decoder->allocator, 10, 10, attributes, decoder->output_type); +done: + if (attributes) + IMFAttributes_Release(attributes);
You can probably use NULL if you don't need attributes, according to the implementation, or at least you don't need the `if (attributes)` check. Also, I'm thinking that instead of keeping a dxgi_manager reference in the decoder you could have a `IMFVideoSampleAllocatorEx` allocated right on decoder creation, which would save the logic to release and re-create it, and the potential failures. Then, changing the media type would be calling `UninitializeSampleAllocator` / `InitializeSampleAllocatorEx` and processing the `MFT_MESSAGE_SET_D3D_MANAGER` message would be calling `SetDirectXManager`, which would even save you the `QueryInterface` and the question whether it needs to be done, as it's done internally already. Of course, I'd appreciate this being split in separate changes ;) -- https://gitlab.winehq.org/wine/wine/-/merge_requests/2587#note_29041