Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com --- dlls/amstream/ddrawstream.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/dlls/amstream/ddrawstream.c b/dlls/amstream/ddrawstream.c index 56230ca4e6..ca9826b14a 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,11 @@ 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 +1164,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)
Signed-off-by: Gijs Vermeulen gijsvrm@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 ca9826b14a..4cbde7ac78 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, @@ -1162,10 +1167,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) {
Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com --- dlls/amstream/tests/amstream.c | 36 ++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-)
diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 9a97b6be65..8f6054015a 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 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,20 @@ static void test_media_types(void) HRESULT hr; IPin *pin;
+ struct { + 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 +1937,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;
Signed-off-by: Gijs Vermeulen gijsvrm@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 4cbde7ac78..6f5d226d35 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 8f6054015a..3e74b611f5 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -1955,20 +1955,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])); }
Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com --- dlls/amstream/ddrawstream.c | 16 ++++------------ dlls/amstream/tests/amstream.c | 6 ++---- 2 files changed, 6 insertions(+), 16 deletions(-)
diff --git a/dlls/amstream/ddrawstream.c b/dlls/amstream/ddrawstream.c index 6f5d226d35..c697aa4318 100644 --- a/dlls/amstream/ddrawstream.c +++ b/dlls/amstream/ddrawstream.c @@ -634,19 +634,11 @@ 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->formattype, &FORMAT_VideoInfo) && + IsEqualGUID(&media_type->majortype, &MEDIATYPE_Video) && + IsEqualGUID(&media_type->subtype, &MEDIASUBTYPE_RGB8)) { - 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; - } + return TRUE; }
return FALSE; diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 3e74b611f5..de43708eb3 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -1943,7 +1943,6 @@ 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); }
@@ -1968,9 +1967,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);