From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/amstream/ddrawstream.c | 35 ++++++++++++++--------------- dlls/amstream/tests/amstream.c | 40 +++++++++++++++------------------- 2 files changed, 34 insertions(+), 41 deletions(-)
diff --git a/dlls/amstream/ddrawstream.c b/dlls/amstream/ddrawstream.c index bd0ae962e36..a8974a786e7 100644 --- a/dlls/amstream/ddrawstream.c +++ b/dlls/amstream/ddrawstream.c @@ -2338,6 +2338,22 @@ static HRESULT ddrawstreamsample_create(struct ddraw_stream *parent, IDirectDraw
TRACE("(%p)\n", ddraw_stream_sample);
+ if (surface) + { + desc.dwSize = sizeof(desc); + if (FAILED(hr = IDirectDrawSurface_GetSurfaceDesc(surface, &desc))) + return hr; + + if (rect) + { + desc.dwWidth = rect->right - rect->left; + desc.dwHeight = rect->bottom - rect->top; + } + + if (FAILED(hr = IDirectDrawMediaStream_SetFormat(&parent->IDirectDrawMediaStream_iface, &desc, NULL))) + return hr; + } + if (!(object = calloc(1, sizeof(*object)))) return E_OUTOFMEMORY;
@@ -2357,29 +2373,10 @@ static HRESULT ddrawstreamsample_create(struct ddraw_stream *parent, IDirectDraw object->surface = surface; IDirectDrawSurface_AddRef(surface);
- desc.dwSize = sizeof(desc); - if (FAILED(hr = IDirectDrawSurface_GetSurfaceDesc(object->surface, &desc))) - { - IDirectDrawStreamSample_Release(&object->IDirectDrawStreamSample_iface); - return hr; - } - if (rect) - { object->rect = *rect; - desc.dwWidth = rect->right - rect->left; - desc.dwHeight = rect->bottom - rect->top; - } else - { SetRect(&object->rect, 0, 0, desc.dwWidth, desc.dwHeight); - } - - if (FAILED(hr = IDirectDrawMediaStream_SetFormat(&parent->IDirectDrawMediaStream_iface, &desc, NULL))) - { - IDirectDrawStreamSample_Release(&object->IDirectDrawStreamSample_iface); - return hr; - } } else { diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 6f628dea7b7..edc48b9d2ec 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -5871,7 +5871,7 @@ static void test_ddrawstream_set_format(void) hr = IDirectDraw_CreateSurface(ddraw, &format, &surface, NULL); ok(hr == S_OK, "Got hr %#lx.\n", hr); hr = IDirectDrawMediaStream_CreateSample(ddraw_stream, surface, NULL, 0, &sample); - todo_wine ok(hr == DDERR_INVALIDSURFACETYPE, "Got hr %#lx.\n", hr); + ok(hr == DDERR_INVALIDSURFACETYPE, "Got hr %#lx.\n", hr);
/* Offer RGB24, and now we can reconnect. */ video_info = rgb24_video_info; @@ -5882,29 +5882,27 @@ static void test_ddrawstream_set_format(void) source.preferred_mt = &mt;
hr = IDirectDrawMediaStream_CreateSample(ddraw_stream, surface, NULL, 0, &sample); - todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); - if (hr != S_OK) - sample = NULL; - todo_wine ok(IsEqualGUID(&source.source.pin.mt.subtype, &MEDIASUBTYPE_RGB24), + ok(hr == S_OK, "Got hr %#lx.\n", hr); + ok(IsEqualGUID(&source.source.pin.mt.subtype, &MEDIASUBTYPE_RGB24), "Got subtype %s.\n", wine_dbgstr_guid(&source.source.pin.mt.subtype)); - todo_wine ok(((VIDEOINFO *)source.source.pin.mt.pbFormat)->bmiHeader.biWidth == 333, + ok(((VIDEOINFO *)source.source.pin.mt.pbFormat)->bmiHeader.biWidth == 333, "Got width %ld.\n", ((VIDEOINFO *)source.source.pin.mt.pbFormat)->bmiHeader.biWidth); - todo_wine ok(((VIDEOINFO *)source.source.pin.mt.pbFormat)->bmiHeader.biHeight == -444, + ok(((VIDEOINFO *)source.source.pin.mt.pbFormat)->bmiHeader.biHeight == -444, "Got height %ld.\n", ((VIDEOINFO *)source.source.pin.mt.pbFormat)->bmiHeader.biHeight);
hr = IDirectDrawMediaStream_GetFormat(ddraw_stream, ¤t_format, NULL, &desired_format, NULL); ok(hr == S_OK, "Got hr %#lx.\n", hr); ok(current_format.dwFlags == (DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_PIXELFORMAT), "Got flags %#lx.\n", current_format.dwFlags); - todo_wine ok(current_format.dwWidth == 333, "Got width %ld.\n", current_format.dwWidth); - todo_wine ok(current_format.dwHeight == 444, "Got height %ld.\n", current_format.dwHeight); - todo_wine ok(current_format.ddpfPixelFormat.u1.dwRGBBitCount == 24, + ok(current_format.dwWidth == 333, "Got width %ld.\n", current_format.dwWidth); + ok(current_format.dwHeight == 444, "Got height %ld.\n", current_format.dwHeight); + ok(current_format.ddpfPixelFormat.u1.dwRGBBitCount == 24, "Got rgb bit count %lu.\n", current_format.ddpfPixelFormat.u1.dwRGBBitCount); ok(desired_format.dwFlags == (DDSD_WIDTH | DDSD_HEIGHT), "Got flags %#lx.\n", desired_format.dwFlags); - todo_wine ok(desired_format.dwWidth == 333, "Got width %ld.\n", desired_format.dwWidth); - todo_wine ok(desired_format.dwHeight == 444, "Got height %ld.\n", desired_format.dwHeight); - todo_wine ok(desired_format.ddpfPixelFormat.u1.dwRGBBitCount == 24, + ok(desired_format.dwWidth == 333, "Got width %ld.\n", desired_format.dwWidth); + ok(desired_format.dwHeight == 444, "Got height %ld.\n", desired_format.dwHeight); + ok(desired_format.ddpfPixelFormat.u1.dwRGBBitCount == 24, "Got rgb bit count %lu.\n", desired_format.ddpfPixelFormat.u1.dwRGBBitCount);
SetRect(&rect, 100, 200, 300, 400); @@ -5912,24 +5910,22 @@ static void test_ddrawstream_set_format(void) hr = IDirectDrawMediaStream_CreateSample(ddraw_stream, surface, &rect, 0, &sample2); ok(hr == MS_E_SAMPLEALLOC, "Got hr %#lx.\n", hr);
- if (sample) - IDirectDrawStreamSample_Release(sample); + IDirectDrawStreamSample_Release(sample);
hr = IDirectDrawMediaStream_CreateSample(ddraw_stream, surface, &rect, 0, &sample); - todo_wine ok(hr == DDERR_INVALIDSURFACETYPE, "Got hr %#lx.\n", hr); + ok(hr == DDERR_INVALIDSURFACETYPE, "Got hr %#lx.\n", hr);
video_info.bmiHeader.biWidth = 200; video_info.bmiHeader.biHeight = -200;
hr = IDirectDrawMediaStream_CreateSample(ddraw_stream, surface, &rect, 0, &sample); - todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); - if (hr == S_OK) - IDirectDrawStreamSample_Release(sample); - todo_wine ok(IsEqualGUID(&source.source.pin.mt.subtype, &MEDIASUBTYPE_RGB24), + ok(hr == S_OK, "Got hr %#lx.\n", hr); + IDirectDrawStreamSample_Release(sample); + ok(IsEqualGUID(&source.source.pin.mt.subtype, &MEDIASUBTYPE_RGB24), "Got subtype %s.\n", wine_dbgstr_guid(&source.source.pin.mt.subtype)); - todo_wine ok(((VIDEOINFO *)source.source.pin.mt.pbFormat)->bmiHeader.biWidth == 200, + ok(((VIDEOINFO *)source.source.pin.mt.pbFormat)->bmiHeader.biWidth == 200, "Got width %ld.\n", ((VIDEOINFO *)source.source.pin.mt.pbFormat)->bmiHeader.biWidth); - todo_wine ok(((VIDEOINFO *)source.source.pin.mt.pbFormat)->bmiHeader.biHeight == -200, + ok(((VIDEOINFO *)source.source.pin.mt.pbFormat)->bmiHeader.biHeight == -200, "Got height %ld.\n", ((VIDEOINFO *)source.source.pin.mt.pbFormat)->bmiHeader.biHeight);
IDirectDrawSurface_Release(surface);