Commit c11b6217 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

quartz: Get rid of GetFileSourceFilter() and CreateFilterInstanceAndLoadFile().

parent 26ac991c
...@@ -1655,68 +1655,52 @@ static HRESULT WINAPI FilterGraph2_RenderFile(IFilterGraph2 *iface, LPCWSTR lpcw ...@@ -1655,68 +1655,52 @@ static HRESULT WINAPI FilterGraph2_RenderFile(IFilterGraph2 *iface, LPCWSTR lpcw
return hr; return hr;
} }
static HRESULT CreateFilterInstanceAndLoadFile(GUID* clsid, LPCOLESTR pszFileName, IBaseFilter **filter) static HRESULT WINAPI FilterGraph2_AddSourceFilter(IFilterGraph2 *iface,
const WCHAR *filename, const WCHAR *filter_name, IBaseFilter **ret_filter)
{ {
IFileSourceFilter *source = NULL; IFilterGraphImpl *graph = impl_from_IFilterGraph2(iface);
HRESULT hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (LPVOID*)filter); IFileSourceFilter *filesource;
TRACE("CLSID: %s\n", debugstr_guid(clsid)); IBaseFilter *filter;
if (FAILED(hr)) HRESULT hr;
return hr; GUID clsid;
hr = IBaseFilter_QueryInterface(*filter, &IID_IFileSourceFilter, (LPVOID*)&source); TRACE("graph %p, filename %s, filter_name %s, ret_filter %p.\n",
if (FAILED(hr)) graph, debugstr_w(filename), debugstr_w(filter_name), ret_filter);
if (!get_media_type(filename, NULL, NULL, &clsid))
clsid = CLSID_AsyncReader;
TRACE("Using source filter %s.\n", debugstr_guid(&clsid));
if (FAILED(hr = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER,
&IID_IBaseFilter, (void **)&filter)))
{ {
IBaseFilter_Release(*filter); WARN("Failed to create filter, hr %#x.\n", hr);
return hr; return hr;
} }
/* Load the file in the file source filter */ if (FAILED(hr = IBaseFilter_QueryInterface(filter, &IID_IFileSourceFilter, (void **)&filesource)))
hr = IFileSourceFilter_Load(source, pszFileName, NULL); {
IFileSourceFilter_Release(source); WARN("Failed to get IFileSourceFilter, hr %#x.\n", hr);
if (FAILED(hr)) { IBaseFilter_Release(filter);
WARN("Load (%x)\n", hr);
IBaseFilter_Release(*filter);
return hr; return hr;
} }
return hr; hr = IFileSourceFilter_Load(filesource, filename, NULL);
} IFileSourceFilter_Release(filesource);
if (FAILED(hr))
/* Some filters implement their own asynchronous reader (Theoretically they all should, try to load it first */ {
static HRESULT GetFileSourceFilter(const WCHAR *filename, IBaseFilter **filter) WARN("Failed to load file, hr %#x.\n", hr);
{
GUID clsid;
if (!get_media_type(filename, NULL, NULL, &clsid))
clsid = CLSID_AsyncReader;
return CreateFilterInstanceAndLoadFile(&clsid, filename, filter);
}
static HRESULT WINAPI FilterGraph2_AddSourceFilter(IFilterGraph2 *iface, LPCWSTR lpcwstrFileName,
LPCWSTR lpcwstrFilterName, IBaseFilter **ppFilter)
{
IFilterGraphImpl *This = impl_from_IFilterGraph2(iface);
HRESULT hr;
IBaseFilter* preader;
TRACE("(%p/%p)->(%s, %s, %p)\n", This, iface, debugstr_w(lpcwstrFileName), debugstr_w(lpcwstrFilterName), ppFilter);
/* Try from file name first, then fall back to default asynchronous reader */
hr = GetFileSourceFilter(lpcwstrFileName, &preader);
if (FAILED(hr)) {
WARN("Unable to create file source filter (%x)\n", hr);
return hr; return hr;
} }
hr = IFilterGraph2_AddFilter(iface, preader, lpcwstrFilterName); if (FAILED(hr = IFilterGraph2_AddFilter(iface, filter, filter_name)))
if (FAILED(hr)) { {
WARN("Unable add filter (%x)\n", hr); IBaseFilter_Release(filter);
IBaseFilter_Release(preader);
return hr; return hr;
} }
if (ppFilter) if (ret_filter)
*ppFilter = preader; *ret_filter = filter;
return S_OK; return S_OK;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment