Maarten Lankhorst : qcap: Make the server directly register a filter instead of the workarounds.

Alexandre Julliard julliard at winehq.org
Tue Jul 29 07:16:21 CDT 2008


Module: wine
Branch: master
Commit: 6032ab4f175a21dfb5d49885133cc3a9bd70d0df
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=6032ab4f175a21dfb5d49885133cc3a9bd70d0df

Author: Maarten Lankhorst <m.b.lankhorst at gmail.com>
Date:   Tue Jul 22 14:38:26 2008 -0700

qcap: Make the server directly register a filter instead of the workarounds.

---

 dlls/qcap/dllsetup.c  |  122 +-----------------------------------------------
 dlls/qcap/dllsetup.h  |   11 +----
 dlls/qcap/qcap_main.c |   13 -----
 3 files changed, 4 insertions(+), 142 deletions(-)

diff --git a/dlls/qcap/dllsetup.c b/dlls/qcap/dllsetup.c
index 6aa1478..a732b73 100644
--- a/dlls/qcap/dllsetup.c
+++ b/dlls/qcap/dllsetup.c
@@ -99,106 +99,6 @@ err_out:
 }
 
 /*
- * SetupRegisterFilter through IFilterMapper2
- */
-static HRESULT SetupRegisterFilter2(const AMOVIESETUP_FILTER * const pSetup,
-                                    IFilterMapper2 * pIFM2, BOOL bRegister)
-{
-    HRESULT hr;
-
-    if (NULL == pSetup)
-        return S_FALSE;
-
-    /* unregister filter */
-    hr = IFilterMapper2_UnregisterFilter(pIFM2, 0, 0, pSetup->clsID);
-
-    if (bRegister)
-    {
-        REGFILTER2 rf2;
-        rf2.dwVersion = 1;
-        rf2.dwMerit = pSetup->dwMerit;
-        rf2.u.s.cPins = pSetup->nPins;
-        rf2.u.s.rgPins = pSetup->lpPin;
-    
-        /* register filter */
-        hr = IFilterMapper2_RegisterFilter(pIFM2, pSetup->clsID,
-                                           pSetup->strName, 0, 0, NULL, &rf2);
-    }
-    else
-    {
-        /* filter not found is ignored here,
-           but there is no #define for 0x80070002  */
-        if (HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr)
-            hr = NOERROR;
-    }
-    return hr;
-}
-
-/*
- * SetupRegisterFilter through IFilterMapper
- */
-static HRESULT SetupRegisterFilter(const AMOVIESETUP_FILTER * const pSetup,
-                                   IFilterMapper * pIFM, BOOL bRegister)
-{
-    HRESULT hr;
-
-    if (NULL == pSetup)
-        return S_FALSE;
-
-    /* unregister filter */
-    hr = IFilterMapper_UnregisterFilter(pIFM, *pSetup->clsID);
-
-    if (bRegister)
-    {
-        /* register filter */
-        hr = IFilterMapper_RegisterFilter(pIFM, *pSetup->clsID,
-                                          pSetup->strName, pSetup->dwMerit);
-        if (SUCCEEDED(hr))
-        {
-            const AMOVIESETUP_PIN *lpPin = pSetup->lpPin;
-            const AMOVIESETUP_MEDIATYPE *lpType;
-            UINT i, j;
-
-            for (i = 0; i < pSetup->nPins; i++, lpPin++)
-            {
-                hr = IFilterMapper_RegisterPin(pIFM, *(pSetup->clsID),
-                                               lpPin->strName,
-                                               lpPin->bRendered,
-                                               lpPin->bOutput,
-                                               lpPin->bZero,
-                                               lpPin->bMany,
-                                               *(lpPin->clsConnectsToFilter),
-                                               lpPin->strConnectsToPin);
-
-                if (SUCCEEDED(hr))
-                {
-                    lpType = lpPin->lpMediaType;
-
-                    /* and each pin's media types */
-                    for (j = 0; j < lpPin->nMediaTypes; j++, lpType++)
-                    {
-                        hr = IFilterMapper_RegisterPinType(pIFM, *(pSetup->clsID),
-                                                           lpPin->strName,
-                                                           *(lpType->clsMajorType),
-                                                           *(lpType->clsMinorType));
-                        if (FAILED(hr)) break;
-                    }
-                    if (FAILED(hr)) break;
-                }
-                if (FAILED(hr)) break;
-            }
-        }
-    }
-    else
-    {
-        /* filter not registered is ignored here, there is no definition for 0x80070002  */
-        if (HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr)
-           hr = NOERROR;
-    }
-    return hr;
-}
-
-/*
  * RegisterAllClasses()
  */
 static HRESULT SetupRegisterAllClasses(const CFactoryTemplate * pList, int num,
@@ -246,7 +146,6 @@ HRESULT SetupRegisterServers(const CFactoryTemplate * pList, int num,
     static const WCHAR szFileName[] = {'q','c','a','p','.','d','l','l',0};
     HRESULT hr = NOERROR;
     IFilterMapper2 *pIFM2 = NULL;
-    IFilterMapper *pIFM = NULL;
 
     /* first register all server classes, just to make sure */
     if (bRegister)
@@ -260,13 +159,6 @@ HRESULT SetupRegisterServers(const CFactoryTemplate * pList, int num,
         TRACE("Getting IFilterMapper2\r\n");
         hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
                               &IID_IFilterMapper2, (void **)&pIFM2);
-        if (FAILED(hr))
-        {
-            TRACE("- trying IFilterMapper instead\r\n");
-
-            hr = CoCreateInstance(&CLSID_FilterMapper, NULL, CLSCTX_INPROC_SERVER,
-                                  &IID_IFilterMapper, (void **)&pIFM);
-        }
 
         if (SUCCEEDED(hr))
         {
@@ -275,14 +167,9 @@ HRESULT SetupRegisterServers(const CFactoryTemplate * pList, int num,
             /* scan through array of CFactoryTemplates registering all filters */
             for (i = 0; i < num; i++, pList++)
             {
-                if (NULL != pList->m_pAMovieSetup_Filter)
+                if (pList->m_pAMovieSetup_Filter.dwVersion)
                 {
-                    if (pIFM2)
-                        hr = SetupRegisterFilter2(pList->m_pAMovieSetup_Filter,
-                                                  pIFM2, bRegister);
-                    else
-                        hr = SetupRegisterFilter(pList->m_pAMovieSetup_Filter,
-                                                 pIFM, bRegister);
+                    hr = IFilterMapper2_RegisterFilter(pIFM2, pList->m_ClsID, pList->m_Name, NULL, &CLSID_LegacyAmFilterCategory, NULL, &pList->m_pAMovieSetup_Filter);
                 }
 
                 /* check final error for this pass and break loop if we failed */
@@ -291,10 +178,7 @@ HRESULT SetupRegisterServers(const CFactoryTemplate * pList, int num,
             }
 
             /* release interface */
-            if (pIFM2)
-                IFilterMapper2_Release(pIFM2);
-            else
-                IFilterMapper_Release(pIFM);
+            IFilterMapper2_Release(pIFM2);
         }
 
         /* and clear up */
diff --git a/dlls/qcap/dllsetup.h b/dlls/qcap/dllsetup.h
index 4b587ac..d582b74 100644
--- a/dlls/qcap/dllsetup.h
+++ b/dlls/qcap/dllsetup.h
@@ -35,15 +35,6 @@ typedef REGFILTERPINS AMOVIESETUP_PIN,
     * PAMOVIESETUP_PIN, 
     * LPAMOVIESETUP_PIN;
 
-typedef struct _AMOVIESETUP_FILTER
-{
-    const CLSID           *clsID;
-    const WCHAR           *strName;
-    DWORD                 dwMerit;
-    UINT                  nPins;
-    const AMOVIESETUP_PIN *lpPin;
-} AMOVIESETUP_FILTER, * PAMOVIESETUP_FILTER, * LPAMOVIESETUP_FILTER;
-
 /* This needs to go into Combase.h */
 typedef IUnknown *(CALLBACK *LPFNNewCOMObject)(LPUNKNOWN pUnkOuter, HRESULT *phr);
 typedef void (CALLBACK *LPFNInitRoutine)(BOOL bLoading, const CLSID *rclsid);
@@ -53,7 +44,7 @@ typedef struct tagCFactoryTemplate {
     const CLSID *m_ClsID;
     LPFNNewCOMObject m_lpfnNew;
     LPFNInitRoutine m_lpfnInit;
-    const AMOVIESETUP_FILTER *m_pAMovieSetup_Filter;
+    const REGFILTER2 m_pAMovieSetup_Filter;
 } CFactoryTemplate;
 
 /****************************************************************************
diff --git a/dlls/qcap/qcap_main.c b/dlls/qcap/qcap_main.c
index 0d29f58..e5c9e3b 100644
--- a/dlls/qcap/qcap_main.c
+++ b/dlls/qcap/qcap_main.c
@@ -83,79 +83,66 @@ static CFactoryTemplate const g_cTemplates[] = {
         wAudioCaptureFilter, 
         &CLSID_AudioCaptureFilter,
         QCAP_createAudioCaptureFilter,
-        NULL,
         NULL
     },{
         wAVICompressor, 
         &CLSID_AVICompressor, 
         QCAP_createAVICompressor,
-        NULL,
         NULL
     },*/{
         wVFWCaptFilter,
         &CLSID_VfwCapture,
         QCAP_createVFWCaptureFilter,
-        NULL,
         NULL
     },/*{
         wVFWCaptFilterProp,
         &CLSID_VFWCaptureFilterPropertyPage,
         QCAP_createVFWCaptureFilterPropertyPage,
-        NULL,
         NULL
     },{
         wAVIMux,
         &CLSID_AVImux,
         QCAP_createAVImux,
-        NULL,
         NULL
     },{
         wAVIMuxPropPage,
         &CLSID_AVImuxPropertyPage,
         QCAP_createAVImuxPropertyPage,
-        NULL,
         NULL
     },{
         wAVIMuxPropPage1,
         &CLSID_AVImuxPropertyPage1,
         QCAP_createAVImuxPropertyPage1,
-        NULL,
         NULL
     },{
         wFileWriter,
         &CLSID_FileWriter,
         QCAP_createFileWriter,
-        NULL,
         NULL
     },*/{
         wCaptGraphBuilder,
         &CLSID_CaptureGraphBuilder,
         QCAP_createCaptureGraphBuilder2,
-        NULL,
         NULL
     },{
         wCaptGraphBuilder2,
         &CLSID_CaptureGraphBuilder2,
         QCAP_createCaptureGraphBuilder2,
-        NULL,
         NULL
     }/*,{
         wInfPinTeeFilter, 
         &CLSID_InfinitePinTeeFilter, 
         QCAP_createInfinitePinTeeFilter,
-        NULL,
         NULL
     },{
         wSmartTeeFilter,
         &CLSID_SmartTeeFilter,
         QCAP_createSmartTeeFilter,
-        NULL,
         NULL
     },{
         wAudioInMixerProp,
         &CLSID_AudioInputMixerPropertyPage,
         QCAP_createAudioInputMixerPropertyPage,
-        NULL,
         NULL
     }*/
 };




More information about the wine-cvs mailing list