[v2 PATCH] mfreadwrite/reader: Propagate resource sharing mode to the sample allocator.
Nikolay Sivov
nsivov at codeweavers.com
Tue May 17 07:30:47 CDT 2022
The issue found by Derek Lesho.
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
v2: dropped tests for now, until I figure out why it crashes on win7.
dlls/mfreadwrite/reader.c | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/dlls/mfreadwrite/reader.c b/dlls/mfreadwrite/reader.c
index 741ef93f367..b1175479dec 100644
--- a/dlls/mfreadwrite/reader.c
+++ b/dlls/mfreadwrite/reader.c
@@ -1651,9 +1651,30 @@ static HRESULT source_reader_set_compatible_media_type(struct source_reader *rea
return type_set ? S_OK : S_FALSE;
}
+static HRESULT source_reader_create_sample_allocator_attributes(const struct source_reader *reader,
+ IMFAttributes **attributes)
+{
+ UINT32 shared = 0, shared_without_mutex = 0;
+ HRESULT hr;
+
+ if (FAILED(hr = MFCreateAttributes(attributes, 1)))
+ return hr;
+
+ IMFAttributes_GetUINT32(reader->attributes, &MF_SA_D3D11_SHARED, &shared);
+ IMFAttributes_GetUINT32(reader->attributes, &MF_SA_D3D11_SHARED_WITHOUT_MUTEX, &shared_without_mutex);
+
+ if (shared_without_mutex)
+ hr = IMFAttributes_SetUINT32(*attributes, &MF_SA_D3D11_SHARED_WITHOUT_MUTEX, TRUE);
+ else if (shared)
+ hr = IMFAttributes_SetUINT32(*attributes, &MF_SA_D3D11_SHARED, TRUE);
+
+ return hr;
+}
+
static HRESULT source_reader_setup_sample_allocator(struct source_reader *reader, unsigned int index)
{
struct media_stream *stream = &reader->streams[index];
+ IMFAttributes *attributes = NULL;
GUID major = { 0 };
HRESULT hr;
@@ -1680,8 +1701,17 @@ 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 (FAILED(hr = source_reader_create_sample_allocator_attributes(reader, &attributes)))
+ WARN("Failed to create allocator attributes, hr %#lx.\n", hr);
+
+ if (FAILED(hr = IMFVideoSampleAllocatorEx_InitializeSampleAllocatorEx(stream->allocator, 2, 8,
+ attributes, stream->current)))
+ {
WARN("Failed to initialize sample allocator, hr %#lx.\n", hr);
+ }
+
+ if (attributes)
+ IMFAttributes_Release(attributes);
return hr;
}
--
2.35.1
More information about the wine-devel
mailing list