Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/filesource.c | 4 ++-- dlls/quartz/tests/filesource.c | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/dlls/quartz/filesource.c b/dlls/quartz/filesource.c index ab8d645d40..44794dff1b 100644 --- a/dlls/quartz/filesource.c +++ b/dlls/quartz/filesource.c @@ -623,8 +623,8 @@ static HRESULT WINAPI FileSource_Load(IFileSourceFilter * iface, LPCOLESTR pszFi This->pmt->cbFormat = 0; This->pmt->pbFormat = NULL; This->pmt->pUnk = NULL; - This->pmt->lSampleSize = 0; - This->pmt->formattype = FORMAT_None; + This->pmt->lSampleSize = 1; + This->pmt->formattype = GUID_NULL; hr = GetClassMediaFile(pReader, pszFileName, &This->pmt->majortype, &This->pmt->subtype, NULL); if (FAILED(hr)) { diff --git a/dlls/quartz/tests/filesource.c b/dlls/quartz/tests/filesource.c index 845e74d609..2e287f7cf2 100644 --- a/dlls/quartz/tests/filesource.c +++ b/dlls/quartz/tests/filesource.c @@ -237,11 +237,9 @@ static void test_file_source_filter(void) ok(file_mt.bFixedSizeSamples == TRUE, "Got fixed size %d.\n", file_mt.bFixedSizeSamples); ok(file_mt.bTemporalCompression == FALSE, "Got temporal compression %d.\n", file_mt.bTemporalCompression); -todo_wine { ok(file_mt.lSampleSize == 1, "Got sample size %u.\n", file_mt.lSampleSize); ok(IsEqualGUID(&file_mt.formattype, &GUID_NULL), "Got format type %s.\n", wine_dbgstr_guid(&file_mt.formattype)); -} ok(!file_mt.pUnk, "Got pUnk %p.\n", file_mt.pUnk); ok(!file_mt.cbFormat, "Got format size %#x.\n", file_mt.cbFormat); ok(!file_mt.pbFormat, "Got format %p.\n", file_mt.pbFormat);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/filesource.c | 39 +++++++++++++++++----------- dlls/quartz/tests/filesource.c | 46 ++++++++++++++-------------------- 2 files changed, 44 insertions(+), 41 deletions(-)
diff --git a/dlls/quartz/filesource.c b/dlls/quartz/filesource.c index 44794dff1b..6b8bfa3353 100644 --- a/dlls/quartz/filesource.c +++ b/dlls/quartz/filesource.c @@ -37,6 +37,19 @@ WINE_DEFAULT_DEBUG_CHANNEL(quartz);
static const WCHAR wszOutputPinName[] = { 'O','u','t','p','u','t',0 };
+static const AM_MEDIA_TYPE default_mt = +{ + {0xe436eb83,0x524f,0x11ce,{0x9f,0x53,0x00,0x20,0xaf,0x0b,0xa7,0x70}}, /* MEDIATYPE_Stream */ + {0,0,0,{0,0,0,0,0,0,0,0}}, + TRUE, + FALSE, + 1, + {0,0,0,{0,0,0,0,0,0,0,0}}, + NULL, + 0, + NULL +}; + typedef struct AsyncReader { BaseFilter filter; @@ -618,19 +631,11 @@ static HRESULT WINAPI FileSource_Load(IFileSourceFilter * iface, LPCOLESTR pszFi This->pmt = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE)); if (!pmt) { - This->pmt->bFixedSizeSamples = TRUE; - This->pmt->bTemporalCompression = FALSE; - This->pmt->cbFormat = 0; - This->pmt->pbFormat = NULL; - This->pmt->pUnk = NULL; - This->pmt->lSampleSize = 1; - This->pmt->formattype = GUID_NULL; - hr = GetClassMediaFile(pReader, pszFileName, &This->pmt->majortype, &This->pmt->subtype, NULL); - if (FAILED(hr)) + CopyMediaType(This->pmt, &default_mt); + if (FAILED(GetClassMediaFile(pReader, pszFileName, &This->pmt->majortype, &This->pmt->subtype, NULL))) { This->pmt->majortype = MEDIATYPE_Stream; This->pmt->subtype = MEDIASUBTYPE_NULL; - hr = S_OK; } } else @@ -763,14 +768,20 @@ static HRESULT WINAPI FileAsyncReaderPin_CheckMediaType(BasePin *pin, const AM_M return S_FALSE; }
-static HRESULT WINAPI FileAsyncReaderPin_GetMediaType(BasePin *iface, int iPosition, AM_MEDIA_TYPE *pmt) +static HRESULT WINAPI FileAsyncReaderPin_GetMediaType(BasePin *iface, int index, AM_MEDIA_TYPE *mt) { FileAsyncReader *This = impl_from_BasePin(iface); - if (iPosition < 0) + AsyncReader *filter = impl_from_IBaseFilter(This->pin.pin.pinInfo.pFilter); + + if (index < 0) return E_INVALIDARG; - if (iPosition > 0) + else if (index > 1) return VFW_S_NO_MORE_ITEMS; - CopyMediaType(pmt, impl_from_IBaseFilter(This->pin.pin.pinInfo.pFilter)->pmt); + + if (index == 0) + CopyMediaType(mt, filter->pmt); + else if (index == 1) + CopyMediaType(mt, &default_mt); return S_OK; }
diff --git a/dlls/quartz/tests/filesource.c b/dlls/quartz/tests/filesource.c index 2e287f7cf2..7330a83da7 100644 --- a/dlls/quartz/tests/filesource.c +++ b/dlls/quartz/tests/filesource.c @@ -257,15 +257,11 @@ static void test_file_source_filter(void) CoTaskMemFree(pmt);
hr = IEnumMediaTypes_Next(enum_mt, 1, &pmt, NULL); -todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); - if (hr == S_OK) - { - mt = file_mt; - mt.subtype = GUID_NULL; - ok(!memcmp(pmt, &mt, sizeof(*pmt)), "Media types did not match.\n"); - CoTaskMemFree(pmt); - } + mt = file_mt; + mt.subtype = GUID_NULL; + ok(!memcmp(pmt, &mt, sizeof(*pmt)), "Media types did not match.\n"); + CoTaskMemFree(pmt);
hr = IEnumMediaTypes_Next(enum_mt, 1, &pmt, NULL); ok(hr == S_FALSE, "Got hr %#x.\n", hr); @@ -339,26 +335,22 @@ todo_wine CoTaskMemFree(pmt);
hr = IEnumMediaTypes_Next(enum_mt, 1, &pmt, NULL); -todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); - if (hr == S_OK) - { - ok(IsEqualGUID(&pmt->majortype, &MEDIATYPE_Stream), "Got major type %s.\n", - wine_dbgstr_guid(&pmt->majortype)); - ok(IsEqualGUID(&pmt->subtype, &GUID_NULL), "Got subtype %s.\n", - wine_dbgstr_guid(&pmt->subtype)); - ok(pmt->bFixedSizeSamples == TRUE, "Got fixed size %d.\n", pmt->bFixedSizeSamples); - ok(!pmt->bTemporalCompression, "Got temporal compression %d.\n", pmt->bTemporalCompression); - ok(pmt->lSampleSize == 1, "Got sample size %u.\n", pmt->lSampleSize); - ok(IsEqualGUID(&pmt->formattype, &GUID_NULL), "Got format type %s.\n", - wine_dbgstr_guid(&pmt->formattype)); - ok(!pmt->pUnk, "Got pUnk %p.\n", pmt->pUnk); - ok(!pmt->cbFormat, "Got format size %#x.\n", pmt->cbFormat); - ok(!pmt->pbFormat, "Got format %p.\n", pmt->pbFormat); - - hr = IPin_QueryAccept(pin, pmt); - ok(hr == S_FALSE, "Got hr %#x.\n", hr); - } + ok(IsEqualGUID(&pmt->majortype, &MEDIATYPE_Stream), "Got major type %s.\n", + wine_dbgstr_guid(&pmt->majortype)); + ok(IsEqualGUID(&pmt->subtype, &GUID_NULL), "Got subtype %s.\n", + wine_dbgstr_guid(&pmt->subtype)); + ok(pmt->bFixedSizeSamples == TRUE, "Got fixed size %d.\n", pmt->bFixedSizeSamples); + ok(!pmt->bTemporalCompression, "Got temporal compression %d.\n", pmt->bTemporalCompression); + ok(pmt->lSampleSize == 1, "Got sample size %u.\n", pmt->lSampleSize); + ok(IsEqualGUID(&pmt->formattype, &GUID_NULL), "Got format type %s.\n", + wine_dbgstr_guid(&pmt->formattype)); + ok(!pmt->pUnk, "Got pUnk %p.\n", pmt->pUnk); + ok(!pmt->cbFormat, "Got format size %#x.\n", pmt->cbFormat); + ok(!pmt->pbFormat, "Got format %p.\n", pmt->pbFormat); + + hr = IPin_QueryAccept(pin, pmt); + ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum_mt, 1, &pmt, NULL); ok(hr == S_FALSE, "Got hr %#x.\n", hr);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/tests/filesource.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
diff --git a/dlls/quartz/tests/filesource.c b/dlls/quartz/tests/filesource.c index 7330a83da7..d485211429 100644 --- a/dlls/quartz/tests/filesource.c +++ b/dlls/quartz/tests/filesource.c @@ -97,7 +97,9 @@ static void check_interface_(unsigned int line, void *iface_ptr, REFIID iid, BOO
static void test_interfaces(void) { + const WCHAR *filename = load_resource(avifile); IBaseFilter *filter = create_file_source(); + IPin *pin;
check_interface(filter, &IID_IBaseFilter, TRUE); check_interface(filter, &IID_IFileSourceFilter, TRUE); @@ -115,6 +117,19 @@ static void test_interfaces(void) check_interface(filter, &IID_IReferenceClock, FALSE); check_interface(filter, &IID_IVideoWindow, FALSE);
+ load_file(filter, filename); + IBaseFilter_FindPin(filter, source_id, &pin); + + check_interface(pin, &IID_IAsyncReader, TRUE); + check_interface(pin, &IID_IPin, TRUE); + todo_wine check_interface(pin, &IID_IQualityControl, TRUE); + check_interface(pin, &IID_IUnknown, TRUE); + + check_interface(pin, &IID_IKsPropertySet, FALSE); + check_interface(pin, &IID_IMediaPosition, FALSE); + check_interface(pin, &IID_IMediaSeeking, FALSE); + + IPin_Release(pin); IBaseFilter_Release(filter); }
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/tests/filesource.c | 65 ++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+)
diff --git a/dlls/quartz/tests/filesource.c b/dlls/quartz/tests/filesource.c index d485211429..ddf0709a8e 100644 --- a/dlls/quartz/tests/filesource.c +++ b/dlls/quartz/tests/filesource.c @@ -602,6 +602,70 @@ todo_wine ok(ret, "Failed to delete file, error %u.\n", GetLastError()); }
+static void test_filter_state(void) +{ + IBaseFilter *filter = create_file_source(); + IMediaControl *control; + IFilterGraph2 *graph; + FILTER_STATE state; + HRESULT hr; + ULONG ref; + + CoCreateInstance(&CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, + &IID_IFilterGraph2, (void **)&graph); + IFilterGraph2_AddFilter(graph, filter, NULL); + IFilterGraph2_QueryInterface(graph, &IID_IMediaControl, (void **)&control); + + hr = IBaseFilter_GetState(filter, 0, &state); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(state == State_Stopped, "Got state %d.\n", state); + + hr = IMediaControl_Run(control); +todo_wine + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IBaseFilter_GetState(filter, 1000, &state); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(state == State_Running, "Got state %d.\n", state); + + hr = IMediaControl_Stop(control); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IBaseFilter_GetState(filter, 1000, &state); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(state == State_Stopped, "Got state %d.\n", state); + + hr = IMediaControl_Pause(control); +todo_wine + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IBaseFilter_GetState(filter, 1000, &state); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(state == State_Paused, "Got state %d.\n", state); + + hr = IMediaControl_Run(control); +todo_wine + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IBaseFilter_GetState(filter, 1000, &state); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(state == State_Running, "Got state %d.\n", state); + + hr = IMediaControl_Pause(control); +todo_wine + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IBaseFilter_GetState(filter, 1000, &state); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(state == State_Paused, "Got state %d.\n", state); + + hr = IMediaControl_Stop(control); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IBaseFilter_GetState(filter, 1000, &state); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(state == State_Stopped, "Got state %d.\n", state); + + IMediaControl_Release(control); + IFilterGraph2_Release(graph); + ref = IBaseFilter_Release(filter); + ok(!ref, "Got outstanding refcount %d.\n", ref); +} + START_TEST(filesource) { CoInitialize(NULL); @@ -610,6 +674,7 @@ START_TEST(filesource) test_enum_pins(); test_find_pin(); test_pin_info(); + test_filter_state(); test_file_source_filter();
CoUninitialize();
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/tests/filesource.c | 79 ++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+)
diff --git a/dlls/quartz/tests/filesource.c b/dlls/quartz/tests/filesource.c index ddf0709a8e..7f25596ae3 100644 --- a/dlls/quartz/tests/filesource.c +++ b/dlls/quartz/tests/filesource.c @@ -666,6 +666,84 @@ todo_wine ok(!ref, "Got outstanding refcount %d.\n", ref); }
+static void test_async_reader(void) +{ + IBaseFilter *filter = create_file_source(); + IFileSourceFilter *filesource; + LONGLONG length, available; + WCHAR filename[MAX_PATH]; + IAsyncReader *reader; + BYTE buffer[20]; + DWORD written; + HANDLE file; + HRESULT hr; + ULONG ref; + IPin *pin; + BOOL ret; + int i; + + GetTempPathW(ARRAY_SIZE(filename), filename); + lstrcatW(filename, avifile); + file = CreateFileW(filename, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0); + ok(file != INVALID_HANDLE_VALUE, "Failed to create file, error %u.\n", GetLastError()); + for (i = 0; i < 600; i++) + { + BYTE b = i % 111; + WriteFile(file, &b, 1, &written, NULL); + } + CloseHandle(file); + + IBaseFilter_QueryInterface(filter, &IID_IFileSourceFilter, (void **)&filesource); + IFileSourceFilter_Load(filesource, filename, NULL); + IBaseFilter_FindPin(filter, source_id, &pin); + + hr = IPin_QueryInterface(pin, &IID_IAsyncReader, (void **)&reader); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAsyncReader_Length(reader, &length, &available); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(length == 600, "Got length %s.\n", wine_dbgstr_longlong(length)); + ok(available == 600, "Got available length %s.\n", wine_dbgstr_longlong(available)); + + memset(buffer, 0xcc, sizeof(buffer)); + hr = IAsyncReader_SyncRead(reader, 0, 10, buffer); + ok(hr == S_OK, "Got hr %#x.\n", hr); + for (i = 0; i < 10; i++) + ok(buffer[i] == i % 111, "Got wrong byte %02x at %u.\n", buffer[i], i); + + hr = IAsyncReader_SyncRead(reader, 0, 10, buffer); + ok(hr == S_OK, "Got hr %#x.\n", hr); + for (i = 0; i < 10; i++) + ok(buffer[i] == i % 111, "Got wrong byte %02x at %u.\n", buffer[i], i); + + hr = IAsyncReader_SyncRead(reader, 10, 10, buffer); + ok(hr == S_OK, "Got hr %#x.\n", hr); + for (i = 0; i < 10; i++) + ok(buffer[i] == (10 + i) % 111, "Got wrong byte %02x at %u.\n", buffer[i], i); + + hr = IAsyncReader_SyncRead(reader, 590, 20, buffer); +todo_wine + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + for (i = 0; i < 10; i++) + ok(buffer[i] == (590 + i) % 111, "Got wrong byte %02x at %u.\n", buffer[i], i); + for (; i < 20; i++) + ok(buffer[i] == 0xcc, "Got wrong byte %02x at %u.\n", buffer[i], i); + + memset(buffer, 0xcc, sizeof(buffer)); + hr = IAsyncReader_SyncRead(reader, 600, 10, buffer); +todo_wine + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(buffer[0] == 0xcc, "Got wrong byte %02x.\n", buffer[0]); + + IAsyncReader_Release(reader); + IPin_Release(pin); + IFileSourceFilter_Release(filesource); + ref = IBaseFilter_Release(filter); + ok(!ref, "Got outstanding refcount %d.\n", ref); + ret = DeleteFileW(filename); + ok(ret, "Failed to delete file, error %u.\n", GetLastError()); +} + START_TEST(filesource) { CoInitialize(NULL); @@ -676,6 +754,7 @@ START_TEST(filesource) test_pin_info(); test_filter_state(); test_file_source_filter(); + test_async_reader();
CoUninitialize(); }