mfreadwrite/reader: Keep a reference to configuration attributes.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2021-02-10 13:32:29 +03:00 committed by Alexandre Julliard
parent 14f6c09508
commit cf4fe13a41
2 changed files with 21 additions and 1 deletions

View File

@ -169,6 +169,7 @@ struct source_reader
IMFMediaSource *source;
IMFPresentationDescriptor *descriptor;
IMFSourceReaderCallback *async_callback;
IMFAttributes *attributes;
unsigned int first_audio_stream_index;
unsigned int first_video_stream_index;
unsigned int last_read_index;
@ -1268,6 +1269,8 @@ static ULONG WINAPI src_reader_Release(IMFSourceReader *iface)
IMFMediaSource_Shutdown(reader->source);
if (reader->descriptor)
IMFPresentationDescriptor_Release(reader->descriptor);
if (reader->attributes)
IMFAttributes_Release(reader->attributes);
IMFMediaSource_Release(reader->source);
for (i = 0; i < reader->stream_count; ++i)
@ -2162,6 +2165,9 @@ static HRESULT create_source_reader_from_source(IMFMediaSource *source, IMFAttri
if (attributes)
{
object->attributes = attributes;
IMFAttributes_AddRef(object->attributes);
IMFAttributes_GetUnknown(attributes, &MF_SOURCE_READER_ASYNC_CALLBACK, &IID_IMFSourceReaderCallback,
(void **)&object->async_callback);
if (object->async_callback)

View File

@ -41,6 +41,13 @@ DEFINE_GUID(GUID_NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
#include "wine/heap.h"
#include "wine/test.h"
static ULONG get_refcount(void *iface)
{
IUnknown *unknown = iface;
IUnknown_AddRef(unknown);
return IUnknown_Release(unknown);
}
static HRESULT (WINAPI *pMFCreateMFByteStreamOnStream)(IStream *stream, IMFByteStream **bytestream);
static void init_functions(void)
@ -620,6 +627,7 @@ static void test_source_reader(void)
IMFByteStream *stream;
LONGLONG timestamp;
IMFSample *sample;
ULONG refcount;
BOOL selected;
HRESULT hr;
@ -836,9 +844,12 @@ skip_read_sample:
ok(hr == S_OK, "Failed to set attribute value, hr %#x.\n", hr);
IMFSourceReaderCallback_Release(&callback->IMFSourceReaderCallback_iface);
refcount = get_refcount(attributes);
hr = MFCreateSourceReaderFromByteStream(stream, attributes, &reader);
todo_wine
todo_wine {
ok(hr == S_OK, "Failed to create source reader, hr %#x.\n", hr);
ok(get_refcount(attributes) > refcount, "Unexpected refcount.\n");
}
IMFAttributes_Release(attributes);
if (hr == S_OK)
IMFSourceReader_Release(reader);
@ -856,6 +867,7 @@ static void test_source_reader_from_media_source(void)
IMFSample *sample;
LONGLONG timestamp;
IMFAttributes *attributes;
ULONG refcount;
int i;
source = create_test_source();
@ -967,8 +979,10 @@ static void test_source_reader_from_media_source(void)
ok(hr == S_OK, "Failed to set attribute value, hr %#x.\n", hr);
IMFSourceReaderCallback_Release(&callback->IMFSourceReaderCallback_iface);
refcount = get_refcount(attributes);
hr = MFCreateSourceReaderFromMediaSource(source, attributes, &reader);
ok(hr == S_OK, "Failed to create source reader, hr %#x.\n", hr);
ok(get_refcount(attributes) > refcount, "Unexpected refcount.\n");
hr = IMFSourceReader_SetStreamSelection(reader, 0, TRUE);
ok(hr == S_OK, "Failed to select a stream, hr %#x.\n", hr);