Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com --- dlls/amstream/ddrawstream.c | 73 +++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 36 deletions(-)
diff --git a/dlls/amstream/ddrawstream.c b/dlls/amstream/ddrawstream.c index 1c924e40a2..e2f24c3b4c 100644 --- a/dlls/amstream/ddrawstream.c +++ b/dlls/amstream/ddrawstream.c @@ -952,21 +952,22 @@ HRESULT ddraw_stream_create(IUnknown *outer, void **out) return S_OK; }
-typedef struct { +struct ddraw_sample +{ IDirectDrawStreamSample IDirectDrawStreamSample_iface; LONG ref; IMediaStream *parent; IDirectDrawSurface *surface; RECT rect; -} IDirectDrawStreamSampleImpl; +};
-static inline IDirectDrawStreamSampleImpl *impl_from_IDirectDrawStreamSample(IDirectDrawStreamSample *iface) +static inline struct ddraw_sample *impl_from_IDirectDrawStreamSample(IDirectDrawStreamSample *iface) { - return CONTAINING_RECORD(iface, IDirectDrawStreamSampleImpl, IDirectDrawStreamSample_iface); + return CONTAINING_RECORD(iface, struct ddraw_sample, IDirectDrawStreamSample_iface); }
/*** IUnknown methods ***/ -static HRESULT WINAPI IDirectDrawStreamSampleImpl_QueryInterface(IDirectDrawStreamSample *iface, +static HRESULT WINAPI ddraw_sample_QueryInterface(IDirectDrawStreamSample *iface, REFIID riid, void **ret_iface) { TRACE("(%p)->(%s,%p)\n", iface, debugstr_guid(riid), ret_iface); @@ -986,43 +987,43 @@ static HRESULT WINAPI IDirectDrawStreamSampleImpl_QueryInterface(IDirectDrawStre return E_NOINTERFACE; }
-static ULONG WINAPI IDirectDrawStreamSampleImpl_AddRef(IDirectDrawStreamSample *iface) +static ULONG WINAPI ddraw_sample_AddRef(IDirectDrawStreamSample *iface) { - IDirectDrawStreamSampleImpl *This = impl_from_IDirectDrawStreamSample(iface); - ULONG ref = InterlockedIncrement(&This->ref); + struct ddraw_sample *sample = impl_from_IDirectDrawStreamSample(iface); + ULONG ref = InterlockedIncrement(&sample->ref);
TRACE("(%p)->(): new ref = %u\n", iface, ref);
return ref; }
-static ULONG WINAPI IDirectDrawStreamSampleImpl_Release(IDirectDrawStreamSample *iface) +static ULONG WINAPI ddraw_sample_Release(IDirectDrawStreamSample *iface) { - IDirectDrawStreamSampleImpl *This = impl_from_IDirectDrawStreamSample(iface); - ULONG ref = InterlockedDecrement(&This->ref); + struct ddraw_sample *sample = impl_from_IDirectDrawStreamSample(iface); + ULONG ref = InterlockedDecrement(&sample->ref);
TRACE("(%p)->(): new ref = %u\n", iface, ref);
if (!ref) { - if (This->surface) - IDirectDrawSurface_Release(This->surface); - IMediaStream_Release(This->parent); - HeapFree(GetProcessHeap(), 0, This); + if (sample->surface) + IDirectDrawSurface_Release(sample->surface); + IMediaStream_Release(sample->parent); + HeapFree(GetProcessHeap(), 0, sample); }
return ref; }
/*** IStreamSample methods ***/ -static HRESULT WINAPI IDirectDrawStreamSampleImpl_GetMediaStream(IDirectDrawStreamSample *iface, IMediaStream **media_stream) +static HRESULT WINAPI ddraw_sample_GetMediaStream(IDirectDrawStreamSample *iface, IMediaStream **media_stream) { FIXME("(%p)->(%p): stub\n", iface, media_stream);
return E_NOTIMPL; }
-static HRESULT WINAPI IDirectDrawStreamSampleImpl_GetSampleTimes(IDirectDrawStreamSample *iface, STREAM_TIME *start_time, +static HRESULT WINAPI ddraw_sample_GetSampleTimes(IDirectDrawStreamSample *iface, STREAM_TIME *start_time, STREAM_TIME *end_time, STREAM_TIME *current_time) { FIXME("(%p)->(%p,%p,%p): stub\n", iface, start_time, end_time, current_time); @@ -1030,7 +1031,7 @@ static HRESULT WINAPI IDirectDrawStreamSampleImpl_GetSampleTimes(IDirectDrawStre return E_NOTIMPL; }
-static HRESULT WINAPI IDirectDrawStreamSampleImpl_SetSampleTimes(IDirectDrawStreamSample *iface, const STREAM_TIME *start_time, +static HRESULT WINAPI ddraw_sample_SetSampleTimes(IDirectDrawStreamSample *iface, const STREAM_TIME *start_time, const STREAM_TIME *end_time) { FIXME("(%p)->(%p,%p): stub\n", iface, start_time, end_time); @@ -1038,7 +1039,7 @@ static HRESULT WINAPI IDirectDrawStreamSampleImpl_SetSampleTimes(IDirectDrawStre return E_NOTIMPL; }
-static HRESULT WINAPI IDirectDrawStreamSampleImpl_Update(IDirectDrawStreamSample *iface, DWORD flags, HANDLE event, +static HRESULT WINAPI ddraw_sample_Update(IDirectDrawStreamSample *iface, DWORD flags, HANDLE event, PAPCFUNC func_APC, DWORD APC_data) { FIXME("(%p)->(%x,%p,%p,%u): stub\n", iface, flags, event, func_APC, APC_data); @@ -1046,7 +1047,7 @@ static HRESULT WINAPI IDirectDrawStreamSampleImpl_Update(IDirectDrawStreamSample return S_OK; }
-static HRESULT WINAPI IDirectDrawStreamSampleImpl_CompletionStatus(IDirectDrawStreamSample *iface, DWORD flags, DWORD milliseconds) +static HRESULT WINAPI ddraw_sample_CompletionStatus(IDirectDrawStreamSample *iface, DWORD flags, DWORD milliseconds) { FIXME("(%p)->(%x,%u): stub\n", iface, flags, milliseconds);
@@ -1054,27 +1055,27 @@ static HRESULT WINAPI IDirectDrawStreamSampleImpl_CompletionStatus(IDirectDrawSt }
/*** IDirectDrawStreamSample methods ***/ -static HRESULT WINAPI IDirectDrawStreamSampleImpl_GetSurface(IDirectDrawStreamSample *iface, IDirectDrawSurface **ddraw_surface, +static HRESULT WINAPI ddraw_sample_GetSurface(IDirectDrawStreamSample *iface, IDirectDrawSurface **ddraw_surface, RECT *rect) { - IDirectDrawStreamSampleImpl *This = impl_from_IDirectDrawStreamSample(iface); + struct ddraw_sample *sample = impl_from_IDirectDrawStreamSample(iface);
TRACE("(%p)->(%p,%p)\n", iface, ddraw_surface, rect);
if (ddraw_surface) { - *ddraw_surface = This->surface; + *ddraw_surface = sample->surface; if (*ddraw_surface) IDirectDrawSurface_AddRef(*ddraw_surface); }
if (rect) - *rect = This->rect; + *rect = sample->rect;
return S_OK; }
-static HRESULT WINAPI IDirectDrawStreamSampleImpl_SetRect(IDirectDrawStreamSample *iface, const RECT *rect) +static HRESULT WINAPI ddraw_sample_SetRect(IDirectDrawStreamSample *iface, const RECT *rect) { FIXME("(%p)->(%p): stub\n", iface, rect);
@@ -1084,24 +1085,24 @@ static HRESULT WINAPI IDirectDrawStreamSampleImpl_SetRect(IDirectDrawStreamSampl static const struct IDirectDrawStreamSampleVtbl DirectDrawStreamSample_Vtbl = { /*** IUnknown methods ***/ - IDirectDrawStreamSampleImpl_QueryInterface, - IDirectDrawStreamSampleImpl_AddRef, - IDirectDrawStreamSampleImpl_Release, + ddraw_sample_QueryInterface, + ddraw_sample_AddRef, + ddraw_sample_Release, /*** IStreamSample methods ***/ - IDirectDrawStreamSampleImpl_GetMediaStream, - IDirectDrawStreamSampleImpl_GetSampleTimes, - IDirectDrawStreamSampleImpl_SetSampleTimes, - IDirectDrawStreamSampleImpl_Update, - IDirectDrawStreamSampleImpl_CompletionStatus, + ddraw_sample_GetMediaStream, + ddraw_sample_GetSampleTimes, + ddraw_sample_SetSampleTimes, + ddraw_sample_Update, + ddraw_sample_CompletionStatus, /*** IDirectDrawStreamSample methods ***/ - IDirectDrawStreamSampleImpl_GetSurface, - IDirectDrawStreamSampleImpl_SetRect + ddraw_sample_GetSurface, + ddraw_sample_SetRect };
static HRESULT ddrawstreamsample_create(IDirectDrawMediaStream *parent, IDirectDrawSurface *surface, const RECT *rect, IDirectDrawStreamSample **ddraw_stream_sample) { - IDirectDrawStreamSampleImpl *object; + struct ddraw_sample *object; HRESULT hr;
TRACE("(%p)\n", ddraw_stream_sample);
Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com --- dlls/amstream/tests/amstream.c | 64 ++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 26 deletions(-)
diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index e1f6a15ad3..72ef7912aa 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -2006,44 +2006,44 @@ static void test_media_types(void)
static void test_IDirectDrawStreamSample(void) { + IDirectDrawMediaStream *ddraw_stream = NULL; + IDirectDrawStreamSample *sample = NULL; + IDirectDrawSurface *surface, *surface2; + IMediaStream *stream2, *stream = NULL; DDSURFACEDESC desc = { sizeof(desc) }; - IAMMultiMediaStream *pams; - HRESULT hr; - IMediaStream *pvidstream = NULL; - IDirectDrawMediaStream *pddstream = NULL; - IDirectDrawStreamSample *pddsample = NULL; + IAMMultiMediaStream *mmstream; IDirectDrawSurface7 *surface7; - IDirectDrawSurface *surface, *surface2; IDirectDraw *ddraw, *ddraw2; IDirectDraw7 *ddraw7; + HRESULT hr; RECT rect;
- if (!(pams = create_ammultimediastream())) + if (!(mmstream = create_ammultimediastream())) return; if (!create_directdraw()) { - IAMMultiMediaStream_Release(pams); + IAMMultiMediaStream_Release(mmstream); return; }
- hr = IAMMultiMediaStream_Initialize(pams, STREAMTYPE_READ, 0, NULL); + hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL); ok(hr == S_OK, "got 0x%08x\n", hr);
- hr = IAMMultiMediaStream_AddMediaStream(pams, (IUnknown*)pdd7, &MSPID_PrimaryVideo, 0, NULL); + hr = IAMMultiMediaStream_AddMediaStream(mmstream, (IUnknown*)pdd7, &MSPID_PrimaryVideo, 0, NULL); ok(hr == S_OK, "got 0x%08x\n", hr);
- hr = IAMMultiMediaStream_GetMediaStream(pams, &MSPID_PrimaryVideo, &pvidstream); + hr = IAMMultiMediaStream_GetMediaStream(mmstream, &MSPID_PrimaryVideo, &stream); ok(hr == S_OK, "got 0x%08x\n", hr); if (FAILED(hr)) goto error;
- hr = IMediaStream_QueryInterface(pvidstream, &IID_IDirectDrawMediaStream, (LPVOID*)&pddstream); + hr = IMediaStream_QueryInterface(stream, &IID_IDirectDrawMediaStream, (LPVOID*)&ddraw_stream); ok(hr == S_OK, "got 0x%08x\n", hr); if (FAILED(hr)) goto error;
- hr = IDirectDrawMediaStream_GetDirectDraw(pddstream, &ddraw); + hr = IDirectDrawMediaStream_GetDirectDraw(ddraw_stream, &ddraw); ok(hr == S_OK, "got 0x%08x\n", hr);
- hr = IDirectDrawMediaStream_GetDirectDraw(pddstream, &ddraw2); + hr = IDirectDrawMediaStream_GetDirectDraw(ddraw_stream, &ddraw2); ok(hr == S_OK, "got 0x%08x\n", hr); ok(ddraw == ddraw2, "got %p, %p\n", ddraw, ddraw2);
@@ -2055,14 +2055,26 @@ static void test_IDirectDrawStreamSample(void) IDirectDraw_Release(ddraw2); IDirectDraw_Release(ddraw);
- hr = IDirectDrawMediaStream_CreateSample(pddstream, NULL, NULL, 0, &pddsample); + hr = IDirectDrawMediaStream_CreateSample(ddraw_stream, NULL, NULL, 0, &sample); ok(hr == S_OK, "got 0x%08x\n", hr);
surface = NULL; - hr = IDirectDrawStreamSample_GetSurface(pddsample, &surface, &rect); + hr = IDirectDrawStreamSample_GetSurface(sample, &surface, &rect); ok(hr == S_OK, "got 0x%08x\n", hr); ok(surface != NULL, "got %p\n", surface);
+ /* Crashes on native. */ + if (0) + { + hr = IDirectDrawStreamSample_GetMediaStream(sample, NULL); + ok(hr == E_POINTER, "got 0x%08x\n", hr); + } + + hr = IDirectDrawStreamSample_GetMediaStream(sample, &stream2); + todo_wine ok(hr == S_OK, "got 0x%08x\n", hr); + todo_wine ok(stream2 == stream, "Expected stream %p, got %p.\n", stream, stream2); + if (hr == S_OK) IMediaStream_Release(stream2); + hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirectDrawSurface7, (void **)&surface7); ok(hr == S_OK, "got 0x%08x\n", hr); IDirectDrawSurface7_Release(surface7); @@ -2074,39 +2086,39 @@ static void test_IDirectDrawStreamSample(void) ok(desc.ddpfPixelFormat.dwFlags == DDPF_RGB, "format flags %08x\n", desc.ddpfPixelFormat.dwFlags); ok(desc.ddpfPixelFormat.dwRGBBitCount, "dwRGBBitCount %d\n", desc.ddpfPixelFormat.dwRGBBitCount); IDirectDrawSurface_Release(surface); - IDirectDrawStreamSample_Release(pddsample); + IDirectDrawStreamSample_Release(sample);
hr = IDirectDrawSurface7_QueryInterface(pdds7, &IID_IDirectDrawSurface, (void **)&surface); ok(hr == S_OK, "got 0x%08x\n", hr);
EXPECT_REF(surface, 1); - hr = IDirectDrawMediaStream_CreateSample(pddstream, surface, NULL, 0, &pddsample); + hr = IDirectDrawMediaStream_CreateSample(ddraw_stream, surface, NULL, 0, &sample); ok(hr == S_OK, "got 0x%08x\n", hr); EXPECT_REF(surface, 2);
surface2 = NULL; SetRectEmpty(&rect); - hr = IDirectDrawStreamSample_GetSurface(pddsample, &surface2, &rect); + hr = IDirectDrawStreamSample_GetSurface(sample, &surface2, &rect); ok(hr == S_OK, "got 0x%08x\n", hr); ok(surface == surface2, "got %p\n", surface2); ok(rect.right > 0 && rect.bottom > 0, "got %d, %d\n", rect.right, rect.bottom); EXPECT_REF(surface, 3); IDirectDrawSurface_Release(surface2);
- hr = IDirectDrawStreamSample_GetSurface(pddsample, NULL, NULL); + hr = IDirectDrawStreamSample_GetSurface(sample, NULL, NULL); ok(hr == S_OK, "got 0x%08x\n", hr);
- IDirectDrawStreamSample_Release(pddsample); + IDirectDrawStreamSample_Release(sample); IDirectDrawSurface_Release(surface);
error: - if (pddstream) - IDirectDrawMediaStream_Release(pddstream); - if (pvidstream) - IMediaStream_Release(pvidstream); + if (ddraw_stream) + IDirectDrawMediaStream_Release(ddraw_stream); + if (stream) + IMediaStream_Release(stream);
release_directdraw(); - IAMMultiMediaStream_Release(pams); + IAMMultiMediaStream_Release(mmstream); }
static IUnknown *create_audio_data(void)
Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com --- dlls/amstream/tests/amstream.c | 79 ++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+)
diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 72ef7912aa..b0d12d895f 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -4478,6 +4478,84 @@ static void test_mediastreamfilter_get_current_stream_time(void) ok(!ref, "Got outstanding refcount %d.\n", ref); }
+static void test_ddrawstream_getsetdirectdraw(void) +{ + IDirectDrawMediaStream *ddraw_stream; + IDirectDraw *ddraw, *ddraw2, *ddraw3; + IDirectDrawStreamSample *sample; + IAMMediaStream *stream; + HRESULT hr; + + hr = DirectDrawCreate(NULL, &ddraw, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IDirectDraw_SetCooperativeLevel(ddraw, GetDesktopWindow(), DDSCL_NORMAL); + ok(hr == DD_OK, "Got hr %#x.\n", hr); + + hr = DirectDrawCreate(NULL, &ddraw2, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = CoCreateInstance(&CLSID_AMDirectDrawStream, NULL, CLSCTX_INPROC_SERVER, &IID_IAMMediaStream, (void **)&stream); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAMMediaStream_QueryInterface(stream, &IID_IDirectDrawMediaStream, (void **)&ddraw_stream); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAMMediaStream_Initialize(stream, (IUnknown *)ddraw2, 0, &MSPID_PrimaryAudio, STREAMTYPE_READ); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IDirectDrawMediaStream_GetDirectDraw(ddraw_stream, &ddraw3); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(ddraw3 == ddraw2, "Expected ddraw %p, got %p.\n", ddraw2, ddraw3); + IDirectDraw_Release(ddraw3); + + hr = IDirectDrawMediaStream_SetDirectDraw(ddraw_stream, NULL); + todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + + 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); + + hr = IDirectDrawMediaStream_SetDirectDraw(ddraw_stream, ddraw); + todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + + if (hr == S_OK) + { + hr = IDirectDrawMediaStream_GetDirectDraw(ddraw_stream, &ddraw3); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(ddraw3 == ddraw, "Expected ddraw %p, got %p.\n", ddraw, ddraw3); + IDirectDraw_Release(ddraw3); + + hr = IDirectDrawMediaStream_CreateSample(ddraw_stream, NULL, NULL, 0, &sample); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IDirectDrawMediaStream_SetDirectDraw(ddraw_stream, ddraw); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IDirectDrawMediaStream_SetDirectDraw(ddraw_stream, ddraw2); + ok(hr == MS_E_SAMPLEALLOC, "Got hr %#x.\n", hr); + + hr = IDirectDrawMediaStream_GetDirectDraw(ddraw_stream, &ddraw3); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(ddraw3 == ddraw, "Expected ddraw %p, got %p.\n", ddraw, ddraw3); + IDirectDraw_Release(ddraw3); + + IDirectDrawStreamSample_Release(sample); + + hr = IDirectDrawMediaStream_SetDirectDraw(ddraw_stream, ddraw2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IDirectDrawMediaStream_GetDirectDraw(ddraw_stream, &ddraw3); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(ddraw3 == ddraw2, "Expected ddraw %p, got %p.\n", ddraw2, ddraw3); + IDirectDraw_Release(ddraw3); + } + + IDirectDrawMediaStream_Release(ddraw_stream); + IAMMediaStream_Release(stream); + IDirectDraw_Release(ddraw2); + IDirectDraw_Release(ddraw); +} + START_TEST(amstream) { HANDLE file; @@ -4524,6 +4602,7 @@ START_TEST(amstream) test_audiostreamsample_completion_status();
test_ddrawstream_initialize(); + test_ddrawstream_getsetdirectdraw();
test_ammediastream_join_am_multi_media_stream();