amstream: Use IDirectDraw instead of IDirectDraw7 internally.

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-06-25 20:56:58 +02:00 committed by Alexandre Julliard
parent 117e13e05e
commit 84566a0cc1
2 changed files with 25 additions and 22 deletions

View File

@ -39,7 +39,7 @@ struct ddraw_stream
IMultiMediaStream* parent; IMultiMediaStream* parent;
MSPID purpose_id; MSPID purpose_id;
STREAM_TYPE stream_type; STREAM_TYPE stream_type;
IDirectDraw7 *ddraw; IDirectDraw *ddraw;
CRITICAL_SECTION cs; CRITICAL_SECTION cs;
IMediaStreamFilter *filter; IMediaStreamFilter *filter;
@ -107,17 +107,17 @@ static ULONG WINAPI ddraw_IAMMediaStream_AddRef(IAMMediaStream *iface)
static ULONG WINAPI ddraw_IAMMediaStream_Release(IAMMediaStream *iface) static ULONG WINAPI ddraw_IAMMediaStream_Release(IAMMediaStream *iface)
{ {
struct ddraw_stream *This = impl_from_IAMMediaStream(iface); struct ddraw_stream *stream = impl_from_IAMMediaStream(iface);
ULONG ref = InterlockedDecrement(&This->ref); ULONG ref = InterlockedDecrement(&stream->ref);
TRACE("(%p/%p)->(): new ref = %u\n", iface, This, ref); TRACE("%p decreasing refcount to %u.\n", stream, ref);
if (!ref) if (!ref)
{ {
DeleteCriticalSection(&This->cs); DeleteCriticalSection(&stream->cs);
if (This->ddraw) if (stream->ddraw)
IDirectDraw7_Release(This->ddraw); IDirectDraw_Release(stream->ddraw);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, stream);
} }
return ref; return ref;
@ -214,8 +214,8 @@ static HRESULT WINAPI ddraw_IAMMediaStream_Initialize(IAMMediaStream *iface, IUn
stream->stream_type = stream_type; stream->stream_type = stream_type;
if (source_object if (source_object
&& FAILED(hr = IUnknown_QueryInterface(source_object, &IID_IDirectDraw7, (void **)&stream->ddraw))) && FAILED(hr = IUnknown_QueryInterface(source_object, &IID_IDirectDraw, (void **)&stream->ddraw)))
FIXME("Stream object doesn't implement IDirectDraw7 interface, hr %#x.\n", hr); FIXME("Stream object doesn't implement IDirectDraw interface, hr %#x.\n", hr);
return S_OK; return S_OK;
} }
@ -373,23 +373,26 @@ static HRESULT WINAPI ddraw_IDirectDrawMediaStream_SetFormat(IDirectDrawMediaStr
static HRESULT WINAPI ddraw_IDirectDrawMediaStream_GetDirectDraw(IDirectDrawMediaStream *iface, static HRESULT WINAPI ddraw_IDirectDrawMediaStream_GetDirectDraw(IDirectDrawMediaStream *iface,
IDirectDraw **ddraw) IDirectDraw **ddraw)
{ {
struct ddraw_stream *This = impl_from_IDirectDrawMediaStream(iface); struct ddraw_stream *stream = impl_from_IDirectDrawMediaStream(iface);
TRACE("(%p)->(%p)\n", iface, ddraw); TRACE("stream %p, ddraw %p.\n", stream, ddraw);
if (!ddraw) if (!ddraw)
return E_POINTER; return E_POINTER;
*ddraw = NULL; *ddraw = NULL;
if (!This->ddraw) if (!stream->ddraw)
{ {
HRESULT hr = DirectDrawCreateEx(NULL, (void**)&This->ddraw, &IID_IDirectDraw7, NULL); HRESULT hr = DirectDrawCreate(NULL, &stream->ddraw, NULL);
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
IDirectDraw7_SetCooperativeLevel(This->ddraw, NULL, DDSCL_NORMAL); IDirectDraw_SetCooperativeLevel(stream->ddraw, NULL, DDSCL_NORMAL);
} }
return IDirectDraw7_QueryInterface(This->ddraw, &IID_IDirectDraw, (void**)ddraw); IDirectDraw_AddRef(stream->ddraw);
*ddraw = stream->ddraw;
return S_OK;
} }
static HRESULT WINAPI ddraw_IDirectDrawMediaStream_SetDirectDraw(IDirectDrawMediaStream *iface, static HRESULT WINAPI ddraw_IDirectDrawMediaStream_SetDirectDraw(IDirectDrawMediaStream *iface,

View File

@ -4776,7 +4776,7 @@ static void test_ddrawstream_getsetdirectdraw(void)
hr = IAMMultiMediaStream_AddMediaStream(mmstream, (IUnknown *)ddraw7, &MSPID_PrimaryVideo, 0, &stream); hr = IAMMultiMediaStream_AddMediaStream(mmstream, (IUnknown *)ddraw7, &MSPID_PrimaryVideo, 0, &stream);
ok(hr == S_OK, "Got hr %#x.\n", hr); ok(hr == S_OK, "Got hr %#x.\n", hr);
todo_wine EXPECT_REF(ddraw, 2); EXPECT_REF(ddraw, 2);
hr = IMediaStream_QueryInterface(stream, &IID_IDirectDrawMediaStream, (void **)&ddraw_stream); hr = IMediaStream_QueryInterface(stream, &IID_IDirectDrawMediaStream, (void **)&ddraw_stream);
ok(hr == S_OK, "Got hr %#x.\n", hr); ok(hr == S_OK, "Got hr %#x.\n", hr);
@ -4787,19 +4787,19 @@ static void test_ddrawstream_getsetdirectdraw(void)
hr = IDirectDrawMediaStream_GetDirectDraw(ddraw_stream, &ddraw2); hr = IDirectDrawMediaStream_GetDirectDraw(ddraw_stream, &ddraw2);
ok(hr == S_OK, "Got hr %#x.\n", hr); ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(ddraw2 == ddraw, "Expected ddraw %p, got %p.\n", ddraw, ddraw2); ok(ddraw2 == ddraw, "Expected ddraw %p, got %p.\n", ddraw, ddraw2);
todo_wine EXPECT_REF(ddraw, 3); EXPECT_REF(ddraw, 3);
hr = IDirectDrawMediaStream_GetDirectDraw(ddraw_stream, &ddraw3); hr = IDirectDrawMediaStream_GetDirectDraw(ddraw_stream, &ddraw3);
ok(hr == S_OK, "Got hr %#x.\n", hr); ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(ddraw3 == ddraw2, "Expected ddraw %p, got %p.\n", ddraw2, ddraw3); ok(ddraw3 == ddraw2, "Expected ddraw %p, got %p.\n", ddraw2, ddraw3);
todo_wine EXPECT_REF(ddraw, 4); EXPECT_REF(ddraw, 4);
IDirectDraw_Release(ddraw3); IDirectDraw_Release(ddraw3);
todo_wine EXPECT_REF(ddraw, 3); EXPECT_REF(ddraw, 3);
/* The current ddraw is released when SetDirectDraw() is called. */ /* The current ddraw is released when SetDirectDraw() is called. */
hr = IDirectDrawMediaStream_SetDirectDraw(ddraw_stream, NULL); hr = IDirectDrawMediaStream_SetDirectDraw(ddraw_stream, NULL);
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
EXPECT_REF(ddraw, 2); todo_wine EXPECT_REF(ddraw, 2);
hr = IDirectDrawMediaStream_GetDirectDraw(ddraw_stream, &ddraw3); hr = IDirectDrawMediaStream_GetDirectDraw(ddraw_stream, &ddraw3);
ok(hr == S_OK, "Got hr %#x.\n", hr); ok(hr == S_OK, "Got hr %#x.\n", hr);
@ -4808,7 +4808,7 @@ static void test_ddrawstream_getsetdirectdraw(void)
hr = IDirectDrawMediaStream_SetDirectDraw(ddraw_stream, ddraw2); hr = IDirectDrawMediaStream_SetDirectDraw(ddraw_stream, ddraw2);
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
todo_wine EXPECT_REF(ddraw, 3); EXPECT_REF(ddraw, 3);
if (hr == S_OK) if (hr == S_OK)
{ {