amstream: Increase parent IAMMediaStream refcount in IDirectDrawMediaStream::CreateSample().

Signed-off-by: Gijs Vermeulen <gijsvrm@gmail.com>
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Gijs Vermeulen 2020-08-05 16:31:27 +02:00 committed by Alexandre Julliard
parent a4ddb5a1e6
commit a518975663
2 changed files with 7 additions and 4 deletions

View File

@ -1048,6 +1048,8 @@ static ULONG WINAPI ddraw_sample_Release(IDirectDrawStreamSample *iface)
--sample->parent->sample_refs;
LeaveCriticalSection(&sample->parent->cs);
IAMMediaStream_Release(&sample->parent->IAMMediaStream_iface);
if (sample->surface)
IDirectDrawSurface_Release(sample->surface);
HeapFree(GetProcessHeap(), 0, sample);
@ -1163,6 +1165,7 @@ static HRESULT ddrawstreamsample_create(struct ddraw_stream *parent, IDirectDraw
object->IDirectDrawStreamSample_iface.lpVtbl = &DirectDrawStreamSample_Vtbl;
object->ref = 1;
object->parent = parent;
IAMMediaStream_AddRef(&parent->IAMMediaStream_iface);
++parent->sample_refs;
if (surface)

View File

@ -5670,7 +5670,7 @@ static void test_ddrawstream_create_sample(void)
EXPECT_REF(stream, 3);
hr = IDirectDrawMediaStream_CreateSample(ddraw_stream, NULL, NULL, 0, &sample);
ok(hr == S_OK, "Got hr %#x.\n", hr);
todo_wine EXPECT_REF(stream, 4);
EXPECT_REF(stream, 4);
hr = IDirectDrawStreamSample_GetSurface(sample, NULL, NULL);
ok(hr == S_OK, "Got hr %#x.\n", hr);
@ -5773,13 +5773,13 @@ static void test_ddrawstreamsample_get_media_stream(void)
ok(hr == E_POINTER, "Got hr %#x.\n", hr);
}
todo_wine EXPECT_REF(stream, 4);
EXPECT_REF(stream, 4);
hr = IDirectDrawStreamSample_GetMediaStream(sample, &stream2);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(stream2 == stream, "Expected stream %p, got %p.\n", stream, stream2);
todo_wine EXPECT_REF(stream, 5);
EXPECT_REF(stream, 5);
IMediaStream_Release(stream2);
todo_wine EXPECT_REF(stream, 4);
EXPECT_REF(stream, 4);
IDirectDrawMediaStream_Release(ddraw_stream);
ref = IDirectDrawStreamSample_Release(sample);