From 550208a597769582df56f9693366d051e6a3be7b Mon Sep 17 00:00:00 2001 From: Maarten Lankhorst Date: Mon, 7 Apr 2008 22:28:15 -0700 Subject: [PATCH] quartz: Try using the registry specified filter source first before falling back to the generic asynchronous reader This makes a test ogg file crash in the same way it does on windows ;-) --- dlls/quartz/filtergraph.c | 69 +++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 66 insertions(+), 3 deletions(-) diff --git a/dlls/quartz/filtergraph.c b/dlls/quartz/filtergraph.c index 1c0acc7..2671c77 100644 --- a/dlls/quartz/filtergraph.c +++ b/dlls/quartz/filtergraph.c @@ -29,6 +29,8 @@ #include "windef.h" #include "winbase.h" #include "winuser.h" +#include "winreg.h" +#include "shlwapi.h" #include "dshow.h" #include "wine/debug.h" #include "quartz_private.h" @@ -1199,6 +1201,63 @@ static HRESULT WINAPI FilterGraph2_RenderFile(IFilterGraph2 *iface, return hr; } +/* Some filters implement their own asynchronous reader (Theoretically they all should, try to load it first */ +static HRESULT GetFileSourceFilter(LPCOLESTR pszFileName, IBaseFilter **filter) +{ + static const WCHAR wszReg[] = {'M','e','d','i','a',' ','T','y','p','e','\\','E','x','t','e','n','s','i','o','n','s',0}; + HRESULT hr = S_OK; + HKEY extkey; + LONG lRet; + + lRet = RegOpenKeyExW(HKEY_CLASSES_ROOT, wszReg, 0, KEY_READ, &extkey); + hr = HRESULT_FROM_WIN32(lRet); + + if (SUCCEEDED(hr)) + { + static const WCHAR filtersource[] = {'S','o','u','r','c','e',' ','F','i','l','t','e','r',0}; + WCHAR *ext = PathFindExtensionW(pszFileName); + WCHAR clsid_key[39]; + GUID clsid; + DWORD size = sizeof(clsid_key); + HKEY pathkey; + + if (!ext) + { + CloseHandle(extkey); + return E_FAIL; + } + + lRet = RegOpenKeyExW(extkey, ext, 0, KEY_READ, &pathkey); + hr = HRESULT_FROM_WIN32(lRet); + CloseHandle(extkey); + if (FAILED(hr)) + return hr; + + lRet = RegQueryValueExW(pathkey, filtersource, NULL, NULL, (LPBYTE)clsid_key, &size); + hr = HRESULT_FROM_WIN32(lRet); + CloseHandle(pathkey); + if (FAILED(hr)) + return hr; + + CLSIDFromString(clsid_key, &clsid); + + TRACE("CLSID: %s\n", debugstr_guid(&clsid)); + hr = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (LPVOID*)filter); + if (SUCCEEDED(hr)) + { + IFileSourceFilter *source = NULL; + hr = IBaseFilter_QueryInterface(*filter, &IID_IFileSourceFilter, (LPVOID*)&source); + if (SUCCEEDED(hr)) + IFileSourceFilter_Release(source); + else + IBaseFilter_Release(*filter); + } + } + if (FAILED(hr)) + *filter = NULL; + return hr; +} + static HRESULT WINAPI FilterGraph2_AddSourceFilter(IFilterGraph2 *iface, LPCWSTR lpcwstrFileName, LPCWSTR lpcwstrFilterName, @@ -1212,8 +1271,11 @@ static HRESULT WINAPI FilterGraph2_AddSourceFilter(IFilterGraph2 *iface, TRACE("(%p/%p)->(%s, %s, %p)\n", This, iface, debugstr_w(lpcwstrFileName), debugstr_w(lpcwstrFilterName), ppFilter); - /* Instantiate a file source filter */ - hr = CoCreateInstance(&CLSID_AsyncReader, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (LPVOID*)&preader); + /* Try from file name first, then fall back to default asynchronous reader */ + hr = GetFileSourceFilter(lpcwstrFileName, &preader); + + if (FAILED(hr)) + hr = CoCreateInstance(&CLSID_AsyncReader, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (LPVOID*)&preader); if (FAILED(hr)) { ERR("Unable to create file source filter (%x)\n", hr); return hr; @@ -1238,12 +1300,13 @@ static HRESULT WINAPI FilterGraph2_AddSourceFilter(IFilterGraph2 *iface, ERR("Load (%x)\n", hr); goto error; } - + IFileSourceFilter_GetCurFile(pfile, &filename, &mt); if (FAILED(hr)) { ERR("GetCurFile (%x)\n", hr); goto error; } + TRACE("File %s\n", debugstr_w(filename)); TRACE("MajorType %s\n", debugstr_guid(&mt.majortype)); TRACE("SubType %s\n", debugstr_guid(&mt.subtype)); -- 1.5.4.1