Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com --- dlls/amstream/ddrawstream.c | 22 +++++++++++++--------- dlls/amstream/tests/amstream.c | 3 +-- 2 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/dlls/amstream/ddrawstream.c b/dlls/amstream/ddrawstream.c index 7f42879254..debf75eaa2 100644 --- a/dlls/amstream/ddrawstream.c +++ b/dlls/amstream/ddrawstream.c @@ -218,6 +218,13 @@ static HRESULT WINAPI ddraw_IAMMediaStream_Initialize(IAMMediaStream *iface, IUn && FAILED(hr = IUnknown_QueryInterface(source_object, &IID_IDirectDraw7, (void **)&stream->ddraw))) FIXME("Stream object doesn't implement IDirectDraw7 interface, hr %#x.\n", hr);
+ if (!source_object) + { + if (FAILED(hr = DirectDrawCreateEx(NULL, (void **)&stream->ddraw, &IID_IDirectDraw7, NULL))) + return hr; + IDirectDraw7_SetCooperativeLevel(stream->ddraw, NULL, DDSCL_NORMAL); + } + return S_OK; }
@@ -374,23 +381,20 @@ static HRESULT WINAPI ddraw_IDirectDrawMediaStream_SetFormat(IDirectDrawMediaStr static HRESULT WINAPI ddraw_IDirectDrawMediaStream_GetDirectDraw(IDirectDrawMediaStream *iface, 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) return E_POINTER;
- *ddraw = NULL; - if (!This->ddraw) + if (!stream->ddraw) { - HRESULT hr = DirectDrawCreateEx(NULL, (void**)&This->ddraw, &IID_IDirectDraw7, NULL); - if (FAILED(hr)) - return hr; - IDirectDraw7_SetCooperativeLevel(This->ddraw, NULL, DDSCL_NORMAL); + *ddraw = NULL; + return S_OK; }
- return IDirectDraw7_QueryInterface(This->ddraw, &IID_IDirectDraw, (void**)ddraw); + return IDirectDraw7_QueryInterface(stream->ddraw, &IID_IDirectDraw, (void **)ddraw); }
static HRESULT WINAPI ddraw_IDirectDrawMediaStream_SetDirectDraw(IDirectDrawMediaStream *iface, diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 8f474215b5..25c914cb08 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -4803,8 +4803,7 @@ static void test_ddrawstream_getsetdirectdraw(void)
hr = IDirectDrawMediaStream_GetDirectDraw(ddraw_stream, &ddraw3); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(ddraw3 == NULL, "Expected NULL, got %p.\n", ddraw3); - if (ddraw3) IDirectDraw_Release(ddraw3); + ok(ddraw3 == NULL, "Expected NULL, got %p.\n", ddraw3);
hr = IDirectDrawMediaStream_SetDirectDraw(ddraw_stream, ddraw2); ok(hr == S_OK, "Got hr %#x.\n", hr);