[PATCH 0/8] MR10643: amstream: Test and fix QueryAccept on ddraw stream.
This MR adds a number of new tests for the `IPin::QueryAccept` function on the Direct Draw media stream. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10643
From: Brendan McGrath <bmcgrath@codeweavers.com> --- dlls/amstream/tests/amstream.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 2f01a2b7688..0006cfd12b2 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -3020,11 +3020,12 @@ static void test_media_types(void) .cbSize = 0, }; IAMMultiMediaStream *mmstream = create_ammultimediastream(); + struct testfilter source; IEnumMediaTypes *enummt; IMediaStream *stream; AM_MEDIA_TYPE *pmt; + unsigned int i, j; ULONG ref, count; - unsigned int i; HRESULT hr; IPin *pin; @@ -3047,12 +3048,12 @@ static void test_media_types(void) static const GUID *rejected_subtypes[] = { - &MEDIASUBTYPE_RGB1, - &MEDIASUBTYPE_RGB4, &MEDIASUBTYPE_RGB565, &MEDIASUBTYPE_RGB555, &MEDIASUBTYPE_RGB24, &MEDIASUBTYPE_RGB32, + &MEDIASUBTYPE_RGB1, + &MEDIASUBTYPE_RGB4, &MEDIASUBTYPE_ARGB32, &MEDIASUBTYPE_ARGB1555, &MEDIASUBTYPE_ARGB4444, @@ -3118,12 +3119,30 @@ static void test_media_types(void) ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr); pmt->majortype = MEDIATYPE_Video; + testfilter_init(&source); + for (i = 0; i < ARRAY_SIZE(rejected_subtypes); ++i) { pmt->subtype = *rejected_subtypes[i]; hr = IPin_QueryAccept(pin, pmt); ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx for subtype %s.\n", hr, wine_dbgstr_guid(rejected_subtypes[i])); + if (i < 4) + { + hr = IPin_ReceiveConnection(pin, &source.source.pin.IPin_iface, pmt); + ok(hr == S_OK, "Got hr %#lx on ReceiveConnection for subtype %s.\n", hr, + wine_dbgstr_guid(rejected_subtypes[i])); + for (j = 0; j < ARRAY_SIZE(rejected_subtypes); ++j) + { + pmt->subtype = *rejected_subtypes[j]; + hr = IPin_QueryAccept(pin, pmt); + todo_wine_if(j < 4) + ok(hr == (j < 4 ? S_OK : VFW_E_TYPE_NOT_ACCEPTED), "Got hr %#lx for subtype %s whilst connected.\n", + hr, wine_dbgstr_guid(rejected_subtypes[j])); + } + hr = IPin_Disconnect(pin); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + } } CoTaskMemFree(pmt); @@ -3177,6 +3196,9 @@ static void test_media_types(void) ref = IAMMultiMediaStream_Release(mmstream); ok(!ref, "Got outstanding refcount %ld.\n", ref); + + ref = IBaseFilter_Release(&source.filter.IBaseFilter_iface); + ok(!ref, "Got outstanding refcount %ld.\n", ref); } static void test_get_end_of_stream_event_handle(void) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10643
From: Brendan McGrath <bmcgrath@codeweavers.com> --- dlls/amstream/tests/amstream.c | 42 ++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 0006cfd12b2..12d0145c1c3 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -3022,8 +3022,9 @@ static void test_media_types(void) IAMMultiMediaStream *mmstream = create_ammultimediastream(); struct testfilter source; IEnumMediaTypes *enummt; + AM_MEDIA_TYPE *pmt, mt; + VIDEOINFOHEADER *vih; IMediaStream *stream; - AM_MEDIA_TYPE *pmt; unsigned int i, j; ULONG ref, count; HRESULT hr; @@ -3121,31 +3122,58 @@ static void test_media_types(void) testfilter_init(&source); + /* Make a copy of the media type so we can manipulate the VIDEOINFOHEADER */ + CopyMediaType(&mt, pmt); + CoTaskMemFree(pmt); + vih = (VIDEOINFOHEADER *)mt.pbFormat; + + hr = IPin_QueryAccept(pin, &mt); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + /* A negative height is never accepted */ + vih->bmiHeader.biHeight = -1; + hr = IPin_QueryAccept(pin, &mt); + todo_wine + ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr); + for (i = 0; i < ARRAY_SIZE(rejected_subtypes); ++i) { - pmt->subtype = *rejected_subtypes[i]; - hr = IPin_QueryAccept(pin, pmt); + mt.subtype = *rejected_subtypes[i]; + vih->bmiHeader.biHeight = 0; + hr = IPin_QueryAccept(pin, &mt); ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx for subtype %s.\n", hr, wine_dbgstr_guid(rejected_subtypes[i])); if (i < 4) { - hr = IPin_ReceiveConnection(pin, &source.source.pin.IPin_iface, pmt); + hr = IPin_ReceiveConnection(pin, &source.source.pin.IPin_iface, &mt); ok(hr == S_OK, "Got hr %#lx on ReceiveConnection for subtype %s.\n", hr, wine_dbgstr_guid(rejected_subtypes[i])); for (j = 0; j < ARRAY_SIZE(rejected_subtypes); ++j) { - pmt->subtype = *rejected_subtypes[j]; - hr = IPin_QueryAccept(pin, pmt); + mt.subtype = *rejected_subtypes[j]; + hr = IPin_QueryAccept(pin, &mt); todo_wine_if(j < 4) ok(hr == (j < 4 ? S_OK : VFW_E_TYPE_NOT_ACCEPTED), "Got hr %#lx for subtype %s whilst connected.\n", hr, wine_dbgstr_guid(rejected_subtypes[j])); } + + /* A negative height is never accepted */ + vih->bmiHeader.biHeight = -1; + for (j = 0; j < ARRAY_SIZE(rejected_subtypes); ++j) + { + mt.subtype = *rejected_subtypes[j]; + hr = IPin_QueryAccept(pin, &mt); + ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx for subtype %s using negative height.\n", + hr, wine_dbgstr_guid(rejected_subtypes[j])); + } + hr = IPin_Disconnect(pin); ok(hr == S_OK, "Got hr %#lx.\n", hr); } + } - CoTaskMemFree(pmt); + FreeMediaType(&mt); hr = IEnumMediaTypes_Next(enummt, 1, &pmt, &count); ok(hr == S_FALSE, "Got hr %#lx.\n", hr); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10643
From: Brendan McGrath <bmcgrath@codeweavers.com> --- dlls/amstream/ddrawstream.c | 3 ++- dlls/amstream/tests/amstream.c | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dlls/amstream/ddrawstream.c b/dlls/amstream/ddrawstream.c index 846814b8fd4..fb17ff9a9c7 100644 --- a/dlls/amstream/ddrawstream.c +++ b/dlls/amstream/ddrawstream.c @@ -1280,7 +1280,8 @@ static HRESULT WINAPI ddraw_sink_QueryAccept(IPin *iface, const AM_MEDIA_TYPE *m if (IsEqualGUID(&mt->majortype, &MEDIATYPE_Video) && IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_RGB8) - && IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo)) + && IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo) + && ((VIDEOINFOHEADER *)mt->pbFormat)->bmiHeader.biHeight >= 0) return S_OK; return VFW_E_TYPE_NOT_ACCEPTED; diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 12d0145c1c3..059b0ddc92e 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -3133,7 +3133,6 @@ static void test_media_types(void) /* A negative height is never accepted */ vih->bmiHeader.biHeight = -1; hr = IPin_QueryAccept(pin, &mt); - todo_wine ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr); for (i = 0; i < ARRAY_SIZE(rejected_subtypes); ++i) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10643
From: Brendan McGrath <bmcgrath@codeweavers.com> --- dlls/amstream/ddrawstream.c | 21 +++++++++++++++++---- dlls/amstream/tests/amstream.c | 1 - 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/dlls/amstream/ddrawstream.c b/dlls/amstream/ddrawstream.c index fb17ff9a9c7..f33656aa130 100644 --- a/dlls/amstream/ddrawstream.c +++ b/dlls/amstream/ddrawstream.c @@ -1276,12 +1276,25 @@ static HRESULT WINAPI ddraw_sink_QueryId(IPin *iface, WCHAR **id) static HRESULT WINAPI ddraw_sink_QueryAccept(IPin *iface, const AM_MEDIA_TYPE *mt) { + struct ddraw_stream *stream = impl_from_IPin(iface); + TRACE("iface %p, mt %p.\n", iface, mt); - if (IsEqualGUID(&mt->majortype, &MEDIATYPE_Video) - && IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_RGB8) - && IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo) - && ((VIDEOINFOHEADER *)mt->pbFormat)->bmiHeader.biHeight >= 0) + if (!IsEqualGUID(&mt->majortype, &MEDIATYPE_Video) + || !IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo) + || ((VIDEOINFOHEADER *)mt->pbFormat)->bmiHeader.biHeight < 0) + return VFW_E_TYPE_NOT_ACCEPTED; + + if (IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_RGB8)) + return S_OK; + + if (!stream->peer) + return VFW_E_TYPE_NOT_ACCEPTED; + + if (IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_RGB555) + || IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_RGB565) + || IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_RGB24) + || IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_RGB32)) return S_OK; return VFW_E_TYPE_NOT_ACCEPTED; diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 059b0ddc92e..024cd1029a9 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -3151,7 +3151,6 @@ static void test_media_types(void) { mt.subtype = *rejected_subtypes[j]; hr = IPin_QueryAccept(pin, &mt); - todo_wine_if(j < 4) ok(hr == (j < 4 ? S_OK : VFW_E_TYPE_NOT_ACCEPTED), "Got hr %#lx for subtype %s whilst connected.\n", hr, wine_dbgstr_guid(rejected_subtypes[j])); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10643
From: Brendan McGrath <bmcgrath@codeweavers.com> --- dlls/amstream/tests/amstream.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 024cd1029a9..c567b7598d5 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -4205,11 +4205,27 @@ static void test_ddrawstream_receive_connection(void) hr = IDirectDrawMediaStream_SetFormat(ddraw_stream, &rgb555_format, NULL); ok(hr == S_OK, "Got hr %#lx.\n", hr); + /* After SetFormat is called, only this format is accepted by QueryAccept ... */ + mt = rgb555_mt; + mt.pbFormat = (BYTE *)&video_info; + hr = IPin_QueryAccept(pin, &mt); + todo_wine + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + mt = rgb8_mt; + mt.pbFormat = (BYTE *)&video_info; + hr = IPin_QueryAccept(pin, &mt); + todo_wine + ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr); hr = IPin_ReceiveConnection(pin, &source.source.pin.IPin_iface, &rgb565_mt); ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr); hr = IPin_ReceiveConnection(pin, &source.source.pin.IPin_iface, &rgb555_mt); ok(hr == S_OK, "Got hr %#lx.\n", hr); + /* .. even when connected (where all supported types were previously accepted) */ + hr = IPin_QueryAccept(pin, &mt); + todo_wine + ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr); hr = IPin_Disconnect(pin); ok(hr == S_OK, "Got hr %#lx.\n", hr); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10643
From: Brendan McGrath <bmcgrath@codeweavers.com> --- dlls/amstream/ddrawstream.c | 48 +++++++++++++++++++--------------- dlls/amstream/tests/amstream.c | 3 --- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/dlls/amstream/ddrawstream.c b/dlls/amstream/ddrawstream.c index f33656aa130..49257554d90 100644 --- a/dlls/amstream/ddrawstream.c +++ b/dlls/amstream/ddrawstream.c @@ -553,6 +553,22 @@ static unsigned int align(unsigned int n, unsigned int alignment) return (n + alignment - 1) & ~(alignment - 1); } +static void subtype_from_pf(GUID *subtype, const DDPIXELFORMAT *pf) +{ + if (pf->dwRGBBitCount == 16 && pf->dwRBitMask == 0x7c00) + *subtype = MEDIASUBTYPE_RGB555; + else if (pf->dwRGBBitCount == 16 && pf->dwRBitMask == 0xf800) + *subtype = MEDIASUBTYPE_RGB565; + else if (pf->dwRGBBitCount == 24) + *subtype = MEDIASUBTYPE_RGB24; + else if (pf->dwRGBBitCount == 32) + *subtype = MEDIASUBTYPE_RGB32; + else if (pf->dwRGBBitCount == 8 && (pf->dwFlags & DDPF_PALETTEINDEXED8)) + *subtype = MEDIASUBTYPE_RGB8; + else + FIXME("Unknown flags %#lx, bit count %lu.\n", pf->dwFlags, pf->dwRGBBitCount); +} + static void set_mt_from_desc(AM_MEDIA_TYPE *mt, const DDSURFACEDESC *format, unsigned int pitch) { VIDEOINFO *videoinfo = CoTaskMemAlloc(sizeof(VIDEOINFO)); @@ -577,38 +593,20 @@ static void set_mt_from_desc(AM_MEDIA_TYPE *mt, const DDSURFACEDESC *format, uns mt->lSampleSize = videoinfo->bmiHeader.biSizeImage; mt->bFixedSizeSamples = TRUE; - if (format->ddpfPixelFormat.dwRGBBitCount == 16 && format->ddpfPixelFormat.dwRBitMask == 0x7c00) - { - mt->subtype = MEDIASUBTYPE_RGB555; - } - else if (format->ddpfPixelFormat.dwRGBBitCount == 16 && format->ddpfPixelFormat.dwRBitMask == 0xf800) + subtype_from_pf(&mt->subtype, &format->ddpfPixelFormat); + + if (format->ddpfPixelFormat.dwRGBBitCount == 16 && format->ddpfPixelFormat.dwRBitMask == 0xf800) { - mt->subtype = MEDIASUBTYPE_RGB565; - videoinfo = (VIDEOINFO *)mt->pbFormat; videoinfo->bmiHeader.biCompression = BI_BITFIELDS; videoinfo->dwBitMasks[iRED] = 0xf800; videoinfo->dwBitMasks[iGREEN] = 0x07e0; videoinfo->dwBitMasks[iBLUE] = 0x001f; } - else if (format->ddpfPixelFormat.dwRGBBitCount == 24) - { - mt->subtype = MEDIASUBTYPE_RGB24; - } - else if (format->ddpfPixelFormat.dwRGBBitCount == 32) - { - mt->subtype = MEDIASUBTYPE_RGB32; - } else if (format->ddpfPixelFormat.dwRGBBitCount == 8 && (format->ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED8)) { - mt->subtype = MEDIASUBTYPE_RGB8; videoinfo->bmiHeader.biClrUsed = 256; /* FIXME: Translate the palette. */ } - else - { - FIXME("Unknown flags %#lx, bit count %lu.\n", - format->ddpfPixelFormat.dwFlags, format->ddpfPixelFormat.dwRGBBitCount); - } } static HRESULT WINAPI ddraw_IDirectDrawMediaStream_SetFormat(IDirectDrawMediaStream *iface, @@ -1277,6 +1275,7 @@ static HRESULT WINAPI ddraw_sink_QueryId(IPin *iface, WCHAR **id) static HRESULT WINAPI ddraw_sink_QueryAccept(IPin *iface, const AM_MEDIA_TYPE *mt) { struct ddraw_stream *stream = impl_from_IPin(iface); + GUID subtype; TRACE("iface %p, mt %p.\n", iface, mt); @@ -1285,6 +1284,13 @@ static HRESULT WINAPI ddraw_sink_QueryAccept(IPin *iface, const AM_MEDIA_TYPE *m || ((VIDEOINFOHEADER *)mt->pbFormat)->bmiHeader.biHeight < 0) return VFW_E_TYPE_NOT_ACCEPTED; + if (stream->format.flags & DDSD_PIXELFORMAT) + { + subtype_from_pf(&subtype, &stream->format.pf); + + return IsEqualGUID(&mt->subtype, &subtype) ? S_OK : VFW_E_TYPE_NOT_ACCEPTED; + } + if (IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_RGB8)) return S_OK; diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index c567b7598d5..5ec7944da99 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -4209,13 +4209,11 @@ static void test_ddrawstream_receive_connection(void) mt = rgb555_mt; mt.pbFormat = (BYTE *)&video_info; hr = IPin_QueryAccept(pin, &mt); - todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); mt = rgb8_mt; mt.pbFormat = (BYTE *)&video_info; hr = IPin_QueryAccept(pin, &mt); - todo_wine ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr); hr = IPin_ReceiveConnection(pin, &source.source.pin.IPin_iface, &rgb565_mt); ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr); @@ -4224,7 +4222,6 @@ static void test_ddrawstream_receive_connection(void) ok(hr == S_OK, "Got hr %#lx.\n", hr); /* .. even when connected (where all supported types were previously accepted) */ hr = IPin_QueryAccept(pin, &mt); - todo_wine ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr); hr = IPin_Disconnect(pin); ok(hr == S_OK, "Got hr %#lx.\n", hr); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10643
From: Brendan McGrath <bmcgrath@codeweavers.com> --- dlls/amstream/tests/amstream.c | 63 ++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 5ec7944da99..87c7c32c24c 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -3025,6 +3025,7 @@ static void test_media_types(void) AM_MEDIA_TYPE *pmt, mt; VIDEOINFOHEADER *vih; IMediaStream *stream; + IDirectDraw *ddraw; unsigned int i, j; ULONG ref, count; HRESULT hr; @@ -3225,6 +3226,68 @@ static void test_media_types(void) ref = IBaseFilter_Release(&source.filter.IBaseFilter_iface); ok(!ref, "Got outstanding refcount %ld.\n", ref); + + /* Test media types when ddraw is passed to AddMediaStream */ + mmstream = create_ammultimediastream(); + hr = DirectDrawCreate(NULL, &ddraw, NULL); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IAMMultiMediaStream_AddMediaStream(mmstream, (IUnknown *)ddraw, &MSPID_PrimaryVideo, 0, &stream); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IMediaStream_QueryInterface(stream, &IID_IPin, (void **)&pin); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + memset(&mt, 0, sizeof(mt)); + mt.majortype = MEDIATYPE_Video; + mt.subtype = MEDIASUBTYPE_RGB32; + mt.bFixedSizeSamples = TRUE; + mt.lSampleSize = 40000; + mt.formattype = FORMAT_VideoInfo; + mt.cbFormat = sizeof(req_vih); + mt.pbFormat = (BYTE*) &req_vih; + + hr = IPin_QueryAccept(pin, &mt); + todo_wine + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + mt.subtype = MEDIASUBTYPE_RGB8; + hr = IPin_QueryAccept(pin, &mt); + todo_wine + ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr); + + mt.subtype = MEDIASUBTYPE_RGB32; + hr = IPin_QueryAccept(pin, &mt); + todo_wine + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + testfilter_init(&source); + + hr = IPin_ReceiveConnection(pin, &source.source.pin.IPin_iface, &mt); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IPin_QueryAccept(pin, &mt); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + mt.subtype = MEDIASUBTYPE_RGB8; + hr = IPin_QueryAccept(pin, &mt); + todo_wine + ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr); + + hr = IPin_Disconnect(pin); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IPin_ReceiveConnection(pin, &source.source.pin.IPin_iface, &mt); + todo_wine + ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr); + + IPin_Release(pin); + IMediaStream_Release(stream); + IDirectDraw_Release(ddraw); + + ref = IAMMultiMediaStream_Release(mmstream); + ok(!ref, "Got outstanding refcount %ld.\n", ref); + + ref = IBaseFilter_Release(&source.filter.IBaseFilter_iface); + ok(!ref, "Got outstanding refcount %ld.\n", ref); } static void test_get_end_of_stream_event_handle(void) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10643
From: Brendan McGrath <bmcgrath@codeweavers.com> --- dlls/amstream/ddrawstream.c | 44 ++++++++++++++++++++++++---------- dlls/amstream/tests/amstream.c | 5 ---- 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/dlls/amstream/ddrawstream.c b/dlls/amstream/ddrawstream.c index 49257554d90..26cc3ab8587 100644 --- a/dlls/amstream/ddrawstream.c +++ b/dlls/amstream/ddrawstream.c @@ -97,6 +97,8 @@ struct ddraw_sample static HRESULT ddrawstreamsample_create(struct ddraw_stream *parent, IDirectDrawSurface *surface, const RECT *rect, IDirectDrawStreamSample **ddraw_stream_sample); +static HRESULT WINAPI ddraw_validate_format(const DDSURFACEDESC *format); + static void remove_queued_update(struct ddraw_sample *sample) { sample->pending = false; @@ -326,6 +328,7 @@ static HRESULT WINAPI ddraw_IAMMediaStream_Initialize(IAMMediaStream *iface, IUn REFMSPID purpose_id, const STREAM_TYPE stream_type) { struct ddraw_stream *stream = impl_from_IAMMediaStream(iface); + DDSURFACEDESC desc = { .dwSize = sizeof(desc) }; HRESULT hr; TRACE("stream %p, source_object %p, flags %lx, purpose_id %s, stream_type %u.\n", stream, source_object, flags, @@ -348,6 +351,15 @@ static HRESULT WINAPI ddraw_IAMMediaStream_Initialize(IAMMediaStream *iface, IUn && FAILED(hr = IUnknown_QueryInterface(source_object, &IID_IDirectDraw, (void **)&stream->ddraw))) FIXME("Stream object doesn't implement IDirectDraw interface, hr %#lx.\n", hr); + if (stream->ddraw + && SUCCEEDED(IDirectDraw_GetDisplayMode(stream->ddraw, &desc)) + && desc.dwFlags & DDSD_PIXELFORMAT + && SUCCEEDED(ddraw_validate_format(&desc))) + { + stream->format.flags |= DDSD_PIXELFORMAT; + stream->format.pf = desc.ddpfPixelFormat; + } + if (!source_object) { if (FAILED(hr = DirectDrawCreate(NULL, &stream->ddraw, NULL))) @@ -609,19 +621,8 @@ static void set_mt_from_desc(AM_MEDIA_TYPE *mt, const DDSURFACEDESC *format, uns } } -static HRESULT WINAPI ddraw_IDirectDrawMediaStream_SetFormat(IDirectDrawMediaStream *iface, - const DDSURFACEDESC *format, IDirectDrawPalette *palette) +static HRESULT WINAPI ddraw_validate_format(const DDSURFACEDESC *format) { - struct ddraw_stream *stream = impl_from_IDirectDrawMediaStream(iface); - struct format old_format; - IPin *old_peer; - HRESULT hr; - - TRACE("stream %p, format %p, palette %p.\n", stream, format, palette); - - if (palette) - FIXME("Setting palette is not yet supported.\n"); - if (!format) return E_POINTER; @@ -717,6 +718,25 @@ static HRESULT WINAPI ddraw_IDirectDrawMediaStream_SetFormat(IDirectDrawMediaStr } } + return S_OK; +} + +static HRESULT WINAPI ddraw_IDirectDrawMediaStream_SetFormat(IDirectDrawMediaStream *iface, + const DDSURFACEDESC *format, IDirectDrawPalette *palette) +{ + struct ddraw_stream *stream = impl_from_IDirectDrawMediaStream(iface); + struct format old_format; + IPin *old_peer; + HRESULT hr; + + TRACE("stream %p, format %p, palette %p.\n", stream, format, palette); + + if (palette) + FIXME("Setting palette is not yet supported.\n"); + + if (FAILED(hr = ddraw_validate_format(format))) + return hr; + EnterCriticalSection(&stream->cs); old_format = stream->format; diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 87c7c32c24c..8cd651fc466 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -3246,17 +3246,14 @@ static void test_media_types(void) mt.pbFormat = (BYTE*) &req_vih; hr = IPin_QueryAccept(pin, &mt); - todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); mt.subtype = MEDIASUBTYPE_RGB8; hr = IPin_QueryAccept(pin, &mt); - todo_wine ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr); mt.subtype = MEDIASUBTYPE_RGB32; hr = IPin_QueryAccept(pin, &mt); - todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); testfilter_init(&source); @@ -3269,14 +3266,12 @@ static void test_media_types(void) mt.subtype = MEDIASUBTYPE_RGB8; hr = IPin_QueryAccept(pin, &mt); - todo_wine ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr); hr = IPin_Disconnect(pin); ok(hr == S_OK, "Got hr %#lx.\n", hr); hr = IPin_ReceiveConnection(pin, &source.source.pin.IPin_iface, &mt); - todo_wine ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr); IPin_Release(pin); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10643
1/8: ``` + if (i < 4) + { + hr = IPin_ReceiveConnection(pin, &source.source.pin.IPin_iface, pmt); + ok(hr == S_OK, "Got hr %#lx on ReceiveConnection for subtype %s.\n", hr, + wine_dbgstr_guid(rejected_subtypes[i])); ``` Why test ReceiveConnection() on only these subtypes? If the others return VFW_E_TYPE_NOT_ACCEPTED, we should validate that in the test and then skip the rest of the new tests. 2/8: ``` + /* A negative height is never accepted */ + vih->bmiHeader.biHeight = -1; + hr = IPin_QueryAccept(pin, &mt); + todo_wine + ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr); ``` This would be more convincing if you also test a height of 1 is accepted. There's other reasons for -1 to be potentially invalid: it doesn't match the height returned from EnumMediaTypes(); it's not aligned; it doesn't match biSizeImage or lSampleSize. 6/8: ``` + if (stream->format.flags & DDSD_PIXELFORMAT) + { + subtype_from_pf(&subtype, &stream->format.pf); + + return IsEqualGUID(&mt->subtype, &subtype) ? S_OK : VFW_E_TYPE_NOT_ACCEPTED; + } ``` Are we sure only setting the subtype is enough? Probably everything else needs to match, too. 8/8: This could use a GetFormat() test. The name ddraw_validate_format() seems odd; it implies we're validating that it's a legal ddraw format, whereas we're actually validating it's a legal format for amstream. Also I don't think we need to bother checking if the format we get from GetDisplayMode() has DDSD_PIXELFORMAT set. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10643#note_135985
participants (3)
-
Brendan McGrath -
Brendan McGrath (@redmcg) -
Elizabeth Figura (@zfigura)