From eb0b1d55e41f24f0159ed0582b182bb415e0c23a Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Mon, 22 Jun 2015 23:52:08 +0300 Subject: [PATCH] amstream: Implement GetDirectDraw(). --- dlls/amstream/Makefile.in | 2 +- dlls/amstream/mediastream.c | 21 ++++++++++++++++++--- dlls/amstream/tests/amstream.c | 16 ++++++++++++++++ 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/dlls/amstream/Makefile.in b/dlls/amstream/Makefile.in index 1107223aa09..c00822b2de1 100644 --- a/dlls/amstream/Makefile.in +++ b/dlls/amstream/Makefile.in @@ -1,5 +1,5 @@ MODULE = amstream.dll -IMPORTS = strmiids strmbase uuid ole32 advapi32 +IMPORTS = strmiids strmbase uuid ole32 advapi32 ddraw C_SRCS = \ amstream.c \ diff --git a/dlls/amstream/mediastream.c b/dlls/amstream/mediastream.c index 4a8c19beee4..1a31706a697 100644 --- a/dlls/amstream/mediastream.c +++ b/dlls/amstream/mediastream.c @@ -42,6 +42,7 @@ typedef struct { IMultiMediaStream* parent; MSPID purpose_id; STREAM_TYPE stream_type; + IDirectDraw7 *ddraw; } DirectDrawMediaStreamImpl; static inline DirectDrawMediaStreamImpl *impl_from_DirectDrawMediaStream_IAMMediaStream(IAMMediaStream *iface) @@ -94,7 +95,11 @@ static ULONG WINAPI DirectDrawMediaStreamImpl_IAMMediaStream_Release(IAMMediaStr TRACE("(%p/%p)->(): new ref = %u\n", iface, This, ref); if (!ref) + { + if (This->ddraw) + IDirectDraw7_Release(This->ddraw); HeapFree(GetProcessHeap(), 0, This); + } return ref; } @@ -373,11 +378,21 @@ static HRESULT WINAPI DirectDrawMediaStreamImpl_IDirectDrawMediaStream_SetFormat } static HRESULT WINAPI DirectDrawMediaStreamImpl_IDirectDrawMediaStream_GetDirectDraw(IDirectDrawMediaStream *iface, - IDirectDraw **ppDirectDraw) + IDirectDraw **ddraw) { - FIXME("(%p)->(%p) stub!\n", iface, ppDirectDraw); + DirectDrawMediaStreamImpl *This = impl_from_IDirectDrawMediaStream(iface); - return E_NOTIMPL; + TRACE("(%p)->(%p)\n", iface, ddraw); + + *ddraw = NULL; + if (!This->ddraw) + { + HRESULT hr = DirectDrawCreateEx(NULL, (void**)&This->ddraw, &IID_IDirectDraw7, NULL); + if (FAILED(hr)) + return hr; + } + + return IDirectDraw7_QueryInterface(This->ddraw, &IID_IDirectDraw, (void**)ddraw); } static HRESULT WINAPI DirectDrawMediaStreamImpl_IDirectDrawMediaStream_SetDirectDraw(IDirectDrawMediaStream *iface, diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index a8986a6bb47..b961084fb7d 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -458,6 +458,8 @@ static void test_IDirectDrawStreamSample(void) IDirectDrawMediaStream *pddstream = NULL; IDirectDrawStreamSample *pddsample = NULL; IDirectDrawSurface *surface, *surface2; + IDirectDraw *ddraw, *ddraw2; + IDirectDraw7 *ddraw7; RECT rect; if (!(pams = create_ammultimediastream())) @@ -482,6 +484,20 @@ static void test_IDirectDrawStreamSample(void) ok(hr == S_OK, "got 0x%08x\n", hr); if (FAILED(hr)) goto error; + hr = IDirectDrawMediaStream_GetDirectDraw(pddstream, &ddraw); + ok(hr == S_OK, "got 0x%08x\n", hr); + + hr = IDirectDrawMediaStream_GetDirectDraw(pddstream, &ddraw2); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(ddraw == ddraw2, "got %p, %p\n", ddraw, ddraw2); + + hr = IDirectDraw_QueryInterface(ddraw, &IID_IDirectDraw7, (void**)&ddraw7); + ok(hr == S_OK, "got 0x%08x\n", hr); + IDirectDraw7_Release(ddraw7); + + IDirectDraw_Release(ddraw2); + IDirectDraw_Release(ddraw); + hr = IDirectDrawMediaStream_CreateSample(pddstream, NULL, NULL, 0, &pddsample); ok(hr == S_OK, "got 0x%08x\n", hr);