From: Gijs Vermeulen gijsvrm@gmail.com
Fixes: 51fce87c607d92300bb6b3f7674e7e6c775c86ff Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com Signed-off-by: Zebediah Figura z.figura12@gmail.com --- v2: reword subject to be a bit more specific.
dlls/amstream/ddrawstream.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/dlls/amstream/ddrawstream.c b/dlls/amstream/ddrawstream.c index 56230ca4e63..b7196d9fc9e 100644 --- a/dlls/amstream/ddrawstream.c +++ b/dlls/amstream/ddrawstream.c @@ -980,7 +980,6 @@ HRESULT ddraw_stream_create(IUnknown *outer, void **out) object->IMemInputPin_iface.lpVtbl = &ddraw_meminput_vtbl; object->IPin_iface.lpVtbl = &ddraw_sink_vtbl; object->ref = 1; - object->sample_refs = 0;
InitializeCriticalSection(&object->cs);
@@ -1043,12 +1042,12 @@ static ULONG WINAPI ddraw_sample_Release(IDirectDrawStreamSample *iface)
TRACE("(%p)->(): new ref = %u\n", iface, ref);
- EnterCriticalSection(&sample->parent->cs); - InterlockedDecrement(&sample->parent->sample_refs); - LeaveCriticalSection(&sample->parent->cs); - if (!ref) { + EnterCriticalSection(&sample->parent->cs); + --sample->parent->sample_refs; + LeaveCriticalSection(&sample->parent->cs); + if (sample->surface) IDirectDrawSurface_Release(sample->surface); HeapFree(GetProcessHeap(), 0, sample); @@ -1166,7 +1165,7 @@ static HRESULT ddrawstreamsample_create(struct ddraw_stream *parent, IDirectDraw object->parent = parent;
EnterCriticalSection(&parent->cs); - InterlockedIncrement(&parent->sample_refs); + ++parent->sample_refs; LeaveCriticalSection(&parent->cs);
if (surface)
From: Gijs Vermeulen gijsvrm@gmail.com
Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/amstream/ddrawstream.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/dlls/amstream/ddrawstream.c b/dlls/amstream/ddrawstream.c index b7196d9fc9e..7095e1d49ab 100644 --- a/dlls/amstream/ddrawstream.c +++ b/dlls/amstream/ddrawstream.c @@ -437,11 +437,16 @@ static HRESULT WINAPI ddraw_IDirectDrawMediaStream_CreateSample(IDirectDrawMedia IDirectDrawStreamSample **sample) { struct ddraw_stream *stream = impl_from_IDirectDrawMediaStream(iface); + HRESULT hr;
TRACE("stream %p, surface %p, rect %s, flags %#x, sample %p.\n", stream, surface, wine_dbgstr_rect(rect), flags, sample);
- return ddrawstreamsample_create(stream, surface, rect, sample); + EnterCriticalSection(&stream->cs); + hr = ddrawstreamsample_create(stream, surface, rect, sample); + LeaveCriticalSection(&stream->cs); + + return hr; }
static HRESULT WINAPI ddraw_IDirectDrawMediaStream_GetTimePerFrame(IDirectDrawMediaStream *iface, @@ -1163,10 +1168,7 @@ static HRESULT ddrawstreamsample_create(struct ddraw_stream *parent, IDirectDraw object->IDirectDrawStreamSample_iface.lpVtbl = &DirectDrawStreamSample_Vtbl; object->ref = 1; object->parent = parent; - - EnterCriticalSection(&parent->cs); ++parent->sample_refs; - LeaveCriticalSection(&parent->cs);
if (surface) {
From: Gijs Vermeulen gijsvrm@gmail.com
Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com Signed-off-by: Zebediah Figura z.figura12@gmail.com --- v3: minor spacing tweaks; also make the "tests" array static const by using GUID pointers
dlls/amstream/tests/amstream.c | 41 ++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 9 deletions(-)
diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 9a97b6be655..5db46bbca4d 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -27,6 +27,7 @@ #include "ks.h" #include "initguid.h" #include "ksmedia.h" +#include "dvdmedia.h" #include "wine/strmbase.h"
static const WAVEFORMATEX audio_format = @@ -1859,7 +1860,11 @@ static void test_enum_media_types(void)
static void test_media_types(void) { - static const VIDEOINFOHEADER req_vih = {}; + static const VIDEOINFOHEADER2 req_vih2; + static const VIDEOINFOHEADER req_vih; + static const MPEG2VIDEOINFO req_m2vi; + static const MPEG1VIDEOINFO req_m1vi; + static const WAVEFORMATEX req_wfx; static const WAVEFORMATEX expect_wfx = { .wFormatTag = WAVE_FORMAT_PCM, @@ -1879,6 +1884,23 @@ static void test_media_types(void) HRESULT hr; IPin *pin;
+ static const struct + { + const GUID *type; + BYTE *format; + ULONG size; + } + tests[] = + { + {&GUID_NULL, NULL, 0 }, + {&FORMAT_None, NULL, 0 }, + {&FORMAT_WaveFormatEx, (BYTE *)&req_wfx, sizeof(WAVEFORMATEX)}, + {&FORMAT_MPEG2Video, (BYTE *)&req_m2vi, sizeof(MPEG2VIDEOINFO)}, + {&FORMAT_MPEGVideo, (BYTE *)&req_m1vi, sizeof(MPEG2VIDEOINFO)}, + {&FORMAT_VideoInfo2, (BYTE *)&req_vih2, sizeof(VIDEOINFOHEADER2)}, + {&FORMAT_VideoInfo, (BYTE *)&req_vih, sizeof(VIDEOINFOHEADER)}, + }; + static const GUID *rejected_subtypes[] = { &MEDIASUBTYPE_RGB1, @@ -1918,14 +1940,15 @@ static void test_media_types(void) wine_dbgstr_guid(&pmt->formattype)); ok(!pmt->pUnk, "Got pUnk %p.\n", pmt->pUnk);
- hr = IPin_QueryAccept(pin, pmt); - todo_wine ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr); - - pmt->formattype = FORMAT_VideoInfo; - pmt->cbFormat = sizeof(VIDEOINFOHEADER); - pmt->pbFormat = (BYTE *)&req_vih; - hr = IPin_QueryAccept(pin, pmt); - ok(hr == S_OK, "Got hr %#x.\n", hr); + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + pmt->formattype = *tests[i].type; + pmt->cbFormat = tests[i].size; + pmt->pbFormat = tests[i].format; + hr = IPin_QueryAccept(pin, pmt); + todo_wine_if (i != 6) + ok(hr == (i == 6) ? S_OK : VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr); + }
pmt->bFixedSizeSamples = FALSE; pmt->bTemporalCompression = TRUE;
From: Gijs Vermeulen gijsvrm@gmail.com
Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/amstream/ddrawstream.c | 2 +- dlls/amstream/tests/amstream.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/dlls/amstream/ddrawstream.c b/dlls/amstream/ddrawstream.c index 7095e1d49ab..bcb752e6bdf 100644 --- a/dlls/amstream/ddrawstream.c +++ b/dlls/amstream/ddrawstream.c @@ -798,7 +798,7 @@ static HRESULT WINAPI ddraw_sink_QueryId(IPin *iface, WCHAR **id) static HRESULT WINAPI ddraw_sink_QueryAccept(IPin *iface, const AM_MEDIA_TYPE *mt) { TRACE("iface %p, mt %p.\n", iface, mt); - return check_media_type(mt) ? S_OK : S_FALSE; + return check_media_type(mt) ? S_OK : VFW_E_TYPE_NOT_ACCEPTED; }
static HRESULT WINAPI ddraw_sink_EnumMediaTypes(IPin *iface, IEnumMediaTypes **enum_media_types) diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 5db46bbca4d..a9a9ccfed09 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -1958,20 +1958,21 @@ static void test_media_types(void)
pmt->majortype = MEDIATYPE_NULL; hr = IPin_QueryAccept(pin, pmt); - todo_wine ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr); + ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr); pmt->majortype = MEDIATYPE_Audio; hr = IPin_QueryAccept(pin, pmt); - todo_wine ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr); + ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr); pmt->majortype = MEDIATYPE_Stream; hr = IPin_QueryAccept(pin, pmt); - todo_wine ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr); + ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr); pmt->majortype = MEDIATYPE_Video;
for (i = 0; i < ARRAY_SIZE(rejected_subtypes); ++i) { pmt->subtype = *rejected_subtypes[i]; hr = IPin_QueryAccept(pin, pmt); - todo_wine ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#x for subtype %s.\n", + todo_wine_if (i < 6) + ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#x for subtype %s.\n", hr, wine_dbgstr_guid(rejected_subtypes[i])); }
From: Gijs Vermeulen gijsvrm@gmail.com
Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com Signed-off-by: Zebediah Figura z.figura12@gmail.com --- v2: split and clarify subject
dlls/amstream/ddrawstream.c | 3 ++- dlls/amstream/tests/amstream.c | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/dlls/amstream/ddrawstream.c b/dlls/amstream/ddrawstream.c index bcb752e6bdf..9fcb6d37cee 100644 --- a/dlls/amstream/ddrawstream.c +++ b/dlls/amstream/ddrawstream.c @@ -634,7 +634,8 @@ static HRESULT WINAPI ddraw_sink_Connect(IPin *iface, IPin *peer, const AM_MEDIA
static BOOL check_media_type(const AM_MEDIA_TYPE *media_type) { - if (IsEqualGUID(&media_type->majortype, &MEDIATYPE_Video)) + if (IsEqualGUID(&media_type->majortype, &MEDIATYPE_Video) + && IsEqualGUID(&media_type->formattype, &FORMAT_VideoInfo)) { if (IsEqualGUID(&media_type->subtype, &MEDIASUBTYPE_RGB1) || IsEqualGUID(&media_type->subtype, &MEDIASUBTYPE_RGB4) || diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index a9a9ccfed09..1fa1f2432c5 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -1946,8 +1946,7 @@ static void test_media_types(void) pmt->cbFormat = tests[i].size; pmt->pbFormat = tests[i].format; hr = IPin_QueryAccept(pin, pmt); - todo_wine_if (i != 6) - ok(hr == (i == 6) ? S_OK : VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr); + ok(hr == (i == 6) ? S_OK : VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr); }
pmt->bFixedSizeSamples = FALSE;
From: Gijs Vermeulen gijsvrm@gmail.com
Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/amstream/ddrawstream.c | 21 +++++---------------- dlls/amstream/tests/amstream.c | 5 ++--- 2 files changed, 7 insertions(+), 19 deletions(-)
diff --git a/dlls/amstream/ddrawstream.c b/dlls/amstream/ddrawstream.c index 9fcb6d37cee..5530603f7aa 100644 --- a/dlls/amstream/ddrawstream.c +++ b/dlls/amstream/ddrawstream.c @@ -632,23 +632,12 @@ static HRESULT WINAPI ddraw_sink_Connect(IPin *iface, IPin *peer, const AM_MEDIA return E_UNEXPECTED; }
-static BOOL check_media_type(const AM_MEDIA_TYPE *media_type) +static BOOL check_media_type(const AM_MEDIA_TYPE *mt) { - if (IsEqualGUID(&media_type->majortype, &MEDIATYPE_Video) - && IsEqualGUID(&media_type->formattype, &FORMAT_VideoInfo)) - { - if (IsEqualGUID(&media_type->subtype, &MEDIASUBTYPE_RGB1) || - IsEqualGUID(&media_type->subtype, &MEDIASUBTYPE_RGB4) || - IsEqualGUID(&media_type->subtype, &MEDIASUBTYPE_RGB8) || - IsEqualGUID(&media_type->subtype, &MEDIASUBTYPE_RGB565) || - IsEqualGUID(&media_type->subtype, &MEDIASUBTYPE_RGB555) || - IsEqualGUID(&media_type->subtype, &MEDIASUBTYPE_RGB24) || - IsEqualGUID(&media_type->subtype, &MEDIASUBTYPE_RGB32)) - { - TRACE("Video sub-type %s matches\n", debugstr_guid(&media_type->subtype)); - return TRUE; - } - } + if (IsEqualGUID(&mt->majortype, &MEDIATYPE_Video) + && IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_RGB8) + && IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo)) + return TRUE;
return FALSE; } diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 1fa1f2432c5..bbad585d48a 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -1970,9 +1970,8 @@ static void test_media_types(void) { pmt->subtype = *rejected_subtypes[i]; hr = IPin_QueryAccept(pin, pmt); - todo_wine_if (i < 6) - ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#x for subtype %s.\n", - hr, wine_dbgstr_guid(rejected_subtypes[i])); + ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#x for subtype %s.\n", + hr, wine_dbgstr_guid(rejected_subtypes[i])); }
CoTaskMemFree(pmt);