Some applications set the output attribute MF_SA_D3D11_SHARED_WITHOUT_MUTEX on the source reader's transform, seemingly expecting that it will be picked up by IMFVideoSampleAllocatorEx::InitializeSampleAllocator(), so that the generated samples will be shareable.
With this commit we try to emulate the same behavior.
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- I am not completely sure that this is what's happening on Windows, but unfortunately I see it rather hard to check. In principle I can create a custom test transform with a custom IMFAttributes object and then trace the calls to it, but it seems a lot of work for a rather fragile result. --- dlls/mfreadwrite/reader.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/dlls/mfreadwrite/reader.c b/dlls/mfreadwrite/reader.c index 2aaaf013da1..2ff56f6e978 100644 --- a/dlls/mfreadwrite/reader.c +++ b/dlls/mfreadwrite/reader.c @@ -2120,6 +2120,7 @@ static HRESULT source_reader_set_compatible_media_type(struct source_reader *rea static HRESULT source_reader_setup_sample_allocator(struct source_reader *reader, unsigned int index) { struct media_stream *stream = &reader->streams[index]; + IMFAttributes *attributes = NULL; IMFVideoSampleAllocatorCallback *callback; GUID major = { 0 }; HRESULT hr; @@ -2147,7 +2148,16 @@ static HRESULT source_reader_setup_sample_allocator(struct source_reader *reader return hr; }
- if (FAILED(hr = IMFVideoSampleAllocatorEx_InitializeSampleAllocatorEx(stream->allocator, 2, 8, NULL, stream->current))) + if (stream->decoder.transform) + { + if (FAILED(hr = IMFTransform_GetOutputStreamAttributes(stream->decoder.transform, 0, &attributes))) + { + WARN("Failed to get output stream attributes, hr %#x.\n", hr); + return hr; + } + } + + if (FAILED(hr = IMFVideoSampleAllocatorEx_InitializeSampleAllocatorEx(stream->allocator, 2, 8, attributes, stream->current))) WARN("Failed to initialize sample allocator, hr %#lx.\n", hr);
if (SUCCEEDED(IMFVideoSampleAllocatorEx_QueryInterface(stream->allocator, &IID_IMFVideoSampleAllocatorCallback, (void **)&callback)))