[PATCH 3/4] qasf: Partially implement IFileSourceFilter_Load() for WM ASF reader.

Zebediah Figura zfigura at codeweavers.com
Wed Apr 1 10:33:11 CDT 2020


On 3/31/20 11:03 AM, Jactry Zeng wrote:
> Signed-off-by: Jactry Zeng <jzeng at codeweavers.com>
> ---
>  dlls/qasf/tests/wmasf.c | 84 +++++++++++++++++++++++++++++++++++++++++
>  dlls/qasf/wmasf.c       | 28 +++++++++++++-
>  2 files changed, 110 insertions(+), 2 deletions(-)
> 
> diff --git a/dlls/qasf/tests/wmasf.c b/dlls/qasf/tests/wmasf.c
> index 3bf1e4ce4e..7cf11c6c9f 100644
> --- a/dlls/qasf/tests/wmasf.c
> +++ b/dlls/qasf/tests/wmasf.c
> @@ -174,7 +174,13 @@ static void test_aggregation(void)
>  static void test_filesourcefilter(void)
>  {
>      IFileSourceFilter *filesource;
> +    IFilterGraph2 *graph;
> +    IEnumPins *enumpins;
>      IBaseFilter *filter;
> +    AM_MEDIA_TYPE type;
> +    const WCHAR *path;
> +    LPOLESTR olepath;
> +    IPin *pins[4];
>      HRESULT hr;
>  
>      hr = CoCreateInstance(&CLSID_WMAsfReader, NULL, CLSCTX_INPROC_SERVER,
> @@ -195,6 +201,84 @@ static void test_filesourcefilter(void)
>      ok(hr == S_OK, "Got hr %#x.\n", hr);
>      expected_ref(filesource, 1);
>  
> +    hr = IFileSourceFilter_Load(filesource, NULL, NULL);
> +    ok(hr == E_POINTER, "Got hr %#x.\n", hr);
> +
> +    olepath = (void *)0xdeadbeef;
> +    memset(&type, 0x22, sizeof(type));
> +    hr = IFileSourceFilter_GetCurFile(filesource, &olepath, &type);
> +    todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
> +    todo_wine ok(!olepath, "Got %s.\n", wine_dbgstr_w(olepath));
> +    todo_wine ok(IsEqualGUID(&type.majortype, &MEDIATYPE_NULL), "Got majortype %s.\n",
> +       wine_dbgstr_guid(&type.majortype));
> +    todo_wine ok(IsEqualGUID(&type.subtype, &MEDIASUBTYPE_NULL), "Got subtype %s.\n",
> +       wine_dbgstr_guid(&type.subtype));
> +    CoTaskMemFree(olepath);
> +
> +    path = L"nonexistent.wmv";
> +    hr = IFileSourceFilter_Load(filesource, path, NULL);

Any particular reason this is a separate variable?

> +    ok(hr == S_OK, "Got hr %#x.\n", hr);
> +    hr = IFileSourceFilter_GetCurFile(filesource, NULL, NULL);
> +    todo_wine ok(hr == E_POINTER, "Got hr %#x.\n", hr);
> +
> +    path = L"nonexistent2.wmv";
> +    hr = IFileSourceFilter_Load(filesource, path, NULL);
> +    ok(hr == E_FAIL, "Got hr %#x.\n", hr);
> +
> +    path = L"nonexistent.wmv";
> +    olepath = (void *)0xdeadbeef;
> +    memset(&type, 0x22, sizeof(type));
> +    hr = IFileSourceFilter_GetCurFile(filesource, &olepath, &type);
> +    todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
> +    if (SUCCEEDED(hr))
> +    {
> +    ok(!wcscmp(olepath, path), "Expected path %s, got %s.\n",
> +       wine_dbgstr_w(path), wine_dbgstr_w(olepath));
> +    ok(IsEqualGUID(&type.majortype, &MEDIATYPE_NULL), "Got majortype %s.\n",
> +       wine_dbgstr_guid(&type.majortype));
> +    ok(IsEqualGUID(&type.subtype, &MEDIASUBTYPE_NULL), "Got subtype %s.\n",
> +       wine_dbgstr_guid(&type.subtype));

Comparing the whole media type wouldn't be bad.

> +    }
> +    CoTaskMemFree(olepath);

Shouldn't this be inside the SUCCEEDED() block above?

> +
> +    hr = IFileSourceFilter_QueryInterface(filesource, &IID_IBaseFilter, (void **)&filter);
> +    ok(hr == S_OK, "Got hr %#x.\n", hr);
> +    hr = IBaseFilter_EnumPins(filter, &enumpins);
> +    ok(hr == S_OK, "Got hr %#x.\n", hr);
> +    hr = IEnumPins_Next(enumpins, 1, pins, NULL);
> +    ok(hr == S_FALSE, "Got hr %#x.\n", hr);
> +    IEnumPins_Release(enumpins);
> +
> +    hr = CoCreateInstance(&CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
> +                          &IID_IFilterGraph2, (void **)&graph);
> +    ok(hr == S_OK, "Got hr %#x.\n", hr);
> +    hr = IFilterGraph2_AddFilter(graph, filter, NULL);
> +    todo_wine ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) ||
> +       broken(hr == HRESULT_FROM_WIN32(ERROR_MOD_NOT_FOUND)) /* win2008 */,
> +       "Got hr %#x.\n", hr);
> +
> +    path = L"nonexistent2.wmv";
> +    hr = IFileSourceFilter_Load(filesource, path, NULL);
> +    ok(hr == E_FAIL, "Got hr %#x.\n", hr);
> +
> +    path = L"nonexistent.wmv";
> +    olepath = (void *)0xdeadbeef;
> +    memset(&type, 0x22, sizeof(type));
> +    hr = IFileSourceFilter_GetCurFile(filesource, &olepath, &type);
> +    todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
> +    if (SUCCEEDED(hr))
> +    {
> +    ok(!wcscmp(olepath, path), "Expected path %s, got %s.\n",
> +       wine_dbgstr_w(path), wine_dbgstr_w(olepath));
> +    ok(IsEqualGUID(&type.majortype, &MEDIATYPE_NULL), "Got majortype %s.\n",
> +       wine_dbgstr_guid(&type.majortype));
> +    ok(IsEqualGUID(&type.subtype, &MEDIASUBTYPE_NULL), "Got subtype %s.\n",
> +       wine_dbgstr_guid(&type.subtype));
> +    }
> +    CoTaskMemFree(olepath);
> +
> +    IFilterGraph2_Release(graph);
> +    IBaseFilter_Release(filter);
>      IFileSourceFilter_Release(filesource);

Can you please check for reference leaks? See other DirectShow tests for
examples.

>  }
>  
> diff --git a/dlls/qasf/wmasf.c b/dlls/qasf/wmasf.c
> index ad7bb5be8f..e8d1363170 100644
> --- a/dlls/qasf/wmasf.c
> +++ b/dlls/qasf/wmasf.c
> @@ -26,6 +26,9 @@ struct wmasf_reader
>  {
>      struct strmbase_filter filter;
>      IFileSourceFilter IFileSourceFilter_iface;
> +
> +    AM_MEDIA_TYPE type;
> +    LPOLESTR filename;
>  };
>  
>  static inline struct wmasf_reader *impl_reader_from_strmbase_filter(struct strmbase_filter *iface)
> @@ -47,6 +50,12 @@ static void wmasf_reader_destroy(struct strmbase_filter *iface)
>  {
>      struct wmasf_reader *filter = impl_reader_from_strmbase_filter(iface);
>  
> +    if (filter->filename)
> +    {
> +        CoTaskMemFree(filter->filename);
> +        FreeMediaType(&filter->type);
> +    }
> +
>      strmbase_filter_cleanup(&filter->filter);
>      free(filter);
>  }
> @@ -95,9 +104,24 @@ static ULONG WINAPI filesourcefilter_Release(IFileSourceFilter *iface)
>  
>  static HRESULT WINAPI filesourcefilter_Load(IFileSourceFilter * iface, LPCOLESTR filename, const AM_MEDIA_TYPE *type)
>  {
> -    FIXME("(%p, %s, %p): stub.\n", iface, debugstr_w(filename), type);
> +    struct wmasf_reader *This = impl_reader_from_IFileSourceFilter(iface);
> +    static const AM_MEDIA_TYPE empty_type = {0};

For what it's worth, the initializer is redundant here.

>  
> -    return E_NOTIMPL;
> +    TRACE("(%p, %s, %p).\n", iface, debugstr_w(filename), type);

Could you also add strmbase_dump_media_type() here?

> +
> +    if (!filename)
> +        return E_POINTER;
> +
> +    if (This->filename)
> +        return E_FAIL;
> +
> +    This->filename = wcsdup(filename);
> +    if (!This->filename)
> +        return E_OUTOFMEMORY;
> +
> +    CopyMediaType(&This->type, type ? type : &empty_type);
> +
> +    return S_OK;
>  }
>  
>  static HRESULT WINAPI filesourcefilter_GetCurFile(IFileSourceFilter *iface, LPOLESTR *filename, AM_MEDIA_TYPE *type)
> 



More information about the wine-devel mailing list