Changeset 6952 for trunk/src/quartz


Ignore:
Timestamp:
Oct 6, 2001, 10:56:18 AM (24 years ago)
Author:
sandervl
Message:

Wine 20011004 resync

Location:
trunk/src/quartz
Files:
12 added
10 deleted
26 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/quartz/complist.c

    r6710 r6952  
    1010#include "winbase.h"
    1111#include "wingdi.h"
     12#include "winuser.h"
    1213#include "winerror.h"
    1314#include "wine/obj_base.h"
  • trunk/src/quartz/devenum.c

    r6710 r6952  
    22 * Implementation of CLSID_SystemDeviceEnum.
    33 *
    4  * FIXME - stub.
     4 * FIXME - not tested enough.
    55 *
    66 * hidenori@a2.ctktv.ne.jp
     
    1212#include "winbase.h"
    1313#include "wingdi.h"
     14#include "winuser.h"
     15#include "winreg.h"
    1416#include "winerror.h"
    1517#include "wine/obj_base.h"
    16 #include "wine/obj_oleaut.h"
     18#include "objidl.h"
     19#include "oleidl.h"
     20#include "ocidl.h"
    1721#include "strmif.h"
    1822#include "control.h"
    1923#include "uuids.h"
     24#include "wine/unicode.h"
    2025
    2126#include "debugtools.h"
     
    2429#include "quartz_private.h"
    2530#include "devenum.h"
     31#include "regsvr.h"
     32#include "enumunk.h"
     33#include "complist.h"
     34#include "devmon.h"
     35
     36
     37/***************************************************************************
     38 *
     39 *      new/delete for CLSID_SystemDeviceEnum
     40 *
     41 */
    2642
    2743/* can I use offsetof safely? - FIXME? */
     
    6884}
    6985
     86
     87/***************************************************************************
     88 *
     89 *      CSysDevEnum::ICreateDevEnum
     90 *
     91 */
     92
     93
     94static HRESULT WINAPI
     95ICreateDevEnum_fnQueryInterface(ICreateDevEnum* iface,REFIID riid,void** ppobj)
     96{
     97        CSysDevEnum_THIS(iface,createdevenum);
     98
     99        TRACE("(%p)->()\n",This);
     100
     101        return IUnknown_QueryInterface(This->unk.punkControl,riid,ppobj);
     102}
     103
     104static ULONG WINAPI
     105ICreateDevEnum_fnAddRef(ICreateDevEnum* iface)
     106{
     107        CSysDevEnum_THIS(iface,createdevenum);
     108
     109        TRACE("(%p)->()\n",This);
     110
     111        return IUnknown_AddRef(This->unk.punkControl);
     112}
     113
     114static ULONG WINAPI
     115ICreateDevEnum_fnRelease(ICreateDevEnum* iface)
     116{
     117        CSysDevEnum_THIS(iface,createdevenum);
     118
     119        TRACE("(%p)->()\n",This);
     120
     121        return IUnknown_Release(This->unk.punkControl);
     122}
     123
     124static HRESULT WINAPI
     125ICreateDevEnum_fnCreateClassEnumerator(ICreateDevEnum* iface,REFCLSID rclsidDeviceClass,IEnumMoniker** ppobj, DWORD dwFlags)
     126{
     127        CSysDevEnum_THIS(iface,createdevenum);
     128        HRESULT hr;
     129        HKEY    hKey;
     130        QUARTZ_CompList*        pMonList;
     131        IMoniker*       pMon;
     132        DWORD   dwIndex;
     133        LONG    lr;
     134        WCHAR   wszPath[ 1024 ];
     135        DWORD   dwLen;
     136        DWORD   dwNameMax;
     137        DWORD   cbName;
     138        FILETIME        ftLastWrite;
     139
     140        TRACE("(%p)->(%s,%p,%08lx)\n",This,
     141                debugstr_guid(rclsidDeviceClass),ppobj,dwFlags);
     142        if ( dwFlags != 0 )
     143        {
     144                FIXME("unknown flags %08lx\n",dwFlags);
     145                return E_NOTIMPL;
     146        }
     147
     148        if ( ppobj == NULL )
     149                return E_POINTER;
     150        *ppobj = NULL;
     151
     152        hr = QUARTZ_CreateCLSIDPath(
     153                wszPath, sizeof(wszPath)/sizeof(wszPath[0]),
     154                rclsidDeviceClass, QUARTZ_wszInstance );
     155        if ( FAILED(hr) )
     156                return hr;
     157
     158        if ( RegOpenKeyExW( HKEY_CLASSES_ROOT, wszPath,
     159                0, KEY_READ, &hKey ) != ERROR_SUCCESS )
     160                return E_FAIL;
     161
     162        dwLen = strlenW(wszPath);
     163        wszPath[dwLen++] = '\\'; wszPath[dwLen] = 0;
     164        dwNameMax = sizeof(wszPath)/sizeof(wszPath[0]) - dwLen - 8;
     165
     166        pMonList = QUARTZ_CompList_Alloc();
     167        if ( pMonList == NULL )
     168        {
     169                hr = E_OUTOFMEMORY;
     170                goto err;
     171        }
     172
     173        /* enumerate all subkeys. */
     174        dwIndex = 0;
     175        while ( 1 )
     176        {
     177                cbName = dwNameMax;
     178                lr = RegEnumKeyExW(
     179                        hKey, dwIndex, &wszPath[dwLen], &cbName,
     180                        NULL, NULL, NULL, &ftLastWrite );
     181                if ( lr == ERROR_NO_MORE_ITEMS )
     182                        break;
     183                if ( lr != ERROR_SUCCESS )
     184                {
     185                        hr = E_FAIL;
     186                        goto err;
     187                }
     188
     189                hr = QUARTZ_CreateDeviceMoniker(
     190                        HKEY_CLASSES_ROOT, wszPath, &pMon );
     191                if ( FAILED(hr) )
     192                        goto err;
     193
     194                hr = QUARTZ_CompList_AddComp(
     195                        pMonList, (IUnknown*)pMon, NULL, 0 );
     196                IMoniker_Release( pMon );
     197
     198                if ( FAILED(hr) )
     199                        goto err;
     200
     201                dwIndex ++;
     202        }
     203
     204        /* create an enumerator. */
     205        hr = QUARTZ_CreateEnumUnknown(
     206                &IID_IEnumMoniker, (void**)ppobj, pMonList );
     207        if ( FAILED(hr) )
     208                goto err;
     209
     210        hr = S_OK;
     211err:
     212        if ( pMonList != NULL )
     213                QUARTZ_CompList_Free( pMonList );
     214        RegCloseKey( hKey );
     215
     216        return hr;
     217}
     218
     219static ICOM_VTABLE(ICreateDevEnum) icreatedevenum =
     220{
     221        ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
     222        /* IUnknown fields */
     223        ICreateDevEnum_fnQueryInterface,
     224        ICreateDevEnum_fnAddRef,
     225        ICreateDevEnum_fnRelease,
     226        /* ICreateDevEnum fields */
     227        ICreateDevEnum_fnCreateClassEnumerator,
     228};
     229
     230HRESULT CSysDevEnum_InitICreateDevEnum( CSysDevEnum* psde )
     231{
     232        TRACE("(%p)\n",psde);
     233        ICOM_VTBL(&psde->createdevenum) = &icreatedevenum;
     234
     235        return NOERROR;
     236}
     237
     238void CSysDevEnum_UninitICreateDevEnum( CSysDevEnum* psde )
     239{
     240        TRACE("(%p)\n",psde);
     241}
  • trunk/src/quartz/devmon.c

    r6710 r6952  
    11/*
    22 * Implements IMoniker for CLSID_CDeviceMoniker.
     3 * Implements IPropertyBag. (internal)
    34 *
    45 * hidenori@a2.ctktv.ne.jp
     
    2728#include "quartz_private.h"
    2829#include "devmon.h"
    29 #include "monprop.h"
    3030#include "regsvr.h"
    3131
     32
     33/***************************************************************************
     34 *
     35 *      CDeviceMoniker::IMoniker
     36 *
     37 */
    3238
    3339static HRESULT WINAPI
     
    150156                return hr;
    151157
    152         return CoCreateInstance(
     158        hr = CoCreateInstance(
    153159                &clsid, NULL, CLSCTX_INPROC_SERVER, riid, ppvResult );
     160        TRACE( "hr = %08lx\n", hr );
     161
     162        return hr;
    154163}
    155164
     
    374383}
    375384
     385/***************************************************************************
     386 *
     387 *      new/delete for CDeviceMoniker
     388 *
     389 */
    376390
    377391static void QUARTZ_DestroyDeviceMoniker(IUnknown* punk)
     
    383397
    384398/* can I use offsetof safely? - FIXME? */
    385 static QUARTZ_IFEntry IFEntries[] =
     399static QUARTZ_IFEntry CDeviceMoniker_IFEntries[] =
    386400{
    387401  { &IID_IPersist, offsetof(CDeviceMoniker,moniker)-offsetof(CDeviceMoniker,unk) },
     
    411425        }
    412426
    413         pdm->unk.pEntries = IFEntries;
    414         pdm->unk.dwEntries = sizeof(IFEntries)/sizeof(IFEntries[0]);
     427        pdm->unk.pEntries = CDeviceMoniker_IFEntries;
     428        pdm->unk.dwEntries = sizeof(CDeviceMoniker_IFEntries)/sizeof(CDeviceMoniker_IFEntries[0]);
    415429        pdm->unk.pOnFinalRelease = &QUARTZ_DestroyDeviceMoniker;
    416430
     
    421435
    422436
     437/***************************************************************************
     438 *
     439 *      CRegPropertyBag::IPropertyBag
     440 *
     441 */
     442
     443static HRESULT WINAPI
     444IPropertyBag_fnQueryInterface(IPropertyBag* iface,REFIID riid,void** ppobj)
     445{
     446        CRegPropertyBag_THIS(iface,propbag);
     447
     448        TRACE("(%p)->()\n",This);
     449
     450        return IUnknown_QueryInterface(This->unk.punkControl,riid,ppobj);
     451}
     452
     453static ULONG WINAPI
     454IPropertyBag_fnAddRef(IPropertyBag* iface)
     455{
     456        CRegPropertyBag_THIS(iface,propbag);
     457
     458        TRACE("(%p)->()\n",This);
     459
     460        return IUnknown_AddRef(This->unk.punkControl);
     461}
     462
     463static ULONG WINAPI
     464IPropertyBag_fnRelease(IPropertyBag* iface)
     465{
     466        CRegPropertyBag_THIS(iface,propbag);
     467
     468        TRACE("(%p)->()\n",This);
     469
     470        return IUnknown_Release(This->unk.punkControl);
     471}
     472
     473static HRESULT WINAPI
     474IPropertyBag_fnRead(IPropertyBag* iface,LPCOLESTR lpszPropName,VARIANT* pVar,IErrorLog* pLog)
     475{
     476        CRegPropertyBag_THIS(iface,propbag);
     477        LONG    lr;
     478        DWORD   dwSize;
     479        DWORD   dwValueType;
     480
     481        TRACE("(%p)->(%s,%p,%p)\n",This,
     482                debugstr_w(lpszPropName),pVar,pLog);
     483
     484        if ( lpszPropName == NULL || pVar == NULL )
     485                return E_POINTER;
     486
     487        dwSize = 0;
     488        lr = RegQueryValueExW(
     489                This->m_hKey, lpszPropName, NULL,
     490                &dwValueType, NULL, &dwSize );
     491        if ( lr != ERROR_SUCCESS )
     492        {
     493                TRACE( "RegQueryValueExW failed.\n" );
     494                return E_INVALIDARG;
     495        }
     496
     497        switch ( dwValueType )
     498        {
     499        case REG_SZ:
     500                TRACE( "REG_SZ / length = %lu\n", dwSize );
     501                if ( pVar->n1.n2.vt == VT_EMPTY )
     502                        pVar->n1.n2.vt = VT_BSTR;
     503                if ( pVar->n1.n2.vt != VT_BSTR )
     504                {
     505                        TRACE( "type of VARIANT is not BSTR\n" );
     506                        return E_FAIL;
     507                }
     508
     509                pVar->n1.n2.n3.bstrVal = SysAllocStringByteLen(
     510                        NULL, dwSize );
     511                if ( pVar->n1.n2.n3.bstrVal == NULL )
     512                {
     513                        TRACE( "out of memory.\n" );
     514                        return E_OUTOFMEMORY;
     515                }
     516                lr = RegQueryValueExW(
     517                        This->m_hKey, lpszPropName, NULL,
     518                        &dwValueType,
     519                        (BYTE*)pVar->n1.n2.n3.bstrVal, &dwSize );
     520                if ( lr != ERROR_SUCCESS )
     521                {
     522                        TRACE( "failed to query value\n" );
     523                        SysFreeString(pVar->n1.n2.n3.bstrVal);
     524                        return E_FAIL;
     525                }
     526                TRACE( "value is BSTR; %s\n", debugstr_w(pVar->n1.n2.n3.bstrVal) );
     527                break;
     528        default:
     529                FIXME("(%p)->(%s,%p,%p) - unsupported value type.\n",This,
     530                        debugstr_w(lpszPropName),pVar,pLog);
     531                return E_FAIL;
     532        }
     533
     534        TRACE( "returned successfully.\n" );
     535        return NOERROR;
     536}
     537
     538static HRESULT WINAPI
     539IPropertyBag_fnWrite(IPropertyBag* iface,LPCOLESTR lpszPropName,VARIANT* pVar)
     540{
     541        CRegPropertyBag_THIS(iface,propbag);
     542
     543        FIXME("(%p)->(%s,%p) stub!\n",This,
     544                debugstr_w(lpszPropName),pVar);
     545
     546        if ( lpszPropName == NULL || pVar == NULL )
     547                return E_POINTER;
     548
     549        return E_NOTIMPL;
     550}
     551
     552
     553
     554
     555static ICOM_VTABLE(IPropertyBag) ipropbag =
     556{
     557        ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
     558        /* IUnknown fields */
     559        IPropertyBag_fnQueryInterface,
     560        IPropertyBag_fnAddRef,
     561        IPropertyBag_fnRelease,
     562        /* IPropertyBag fields */
     563        IPropertyBag_fnRead,
     564        IPropertyBag_fnWrite,
     565};
     566
     567static HRESULT CRegPropertyBag_InitIPropertyBag(
     568        CRegPropertyBag* prpb, HKEY hkRoot, LPCWSTR lpKeyPath )
     569{
     570        ICOM_VTBL(&prpb->propbag) = &ipropbag;
     571
     572        if ( RegOpenKeyExW(
     573                hkRoot, lpKeyPath, 0,
     574                KEY_ALL_ACCESS, &prpb->m_hKey ) != ERROR_SUCCESS )
     575                return E_FAIL;
     576
     577        return NOERROR;
     578}
     579
     580static void CRegPropertyBag_UninitIPropertyBag(
     581        CRegPropertyBag* prpb )
     582{
     583        RegCloseKey( prpb->m_hKey );
     584}
     585
     586
     587/***************************************************************************
     588 *
     589 *      new/delete for CRegPropertyBag
     590 *
     591 */
     592
     593static void QUARTZ_DestroyRegPropertyBag(IUnknown* punk)
     594{
     595        CRegPropertyBag_THIS(punk,unk);
     596
     597        CRegPropertyBag_UninitIPropertyBag(This);
     598}
     599
     600
     601/* can I use offsetof safely? - FIXME? */
     602static QUARTZ_IFEntry CRegPropertyBag_IFEntries[] =
     603{
     604  { &IID_IPropertyBag, offsetof(CRegPropertyBag,propbag)-offsetof(CRegPropertyBag,unk) },
     605};
     606
     607HRESULT QUARTZ_CreateRegPropertyBag(
     608        HKEY hkRoot, LPCWSTR lpKeyPath,
     609        IPropertyBag** ppPropBag )
     610{
     611        CRegPropertyBag*        prpb;
     612        HRESULT hr;
     613
     614        TRACE("(%08x,%s,%p)\n",hkRoot,debugstr_w(lpKeyPath),ppPropBag );
     615
     616        prpb = (CRegPropertyBag*)QUARTZ_AllocObj( sizeof(CRegPropertyBag) );
     617        if ( prpb == NULL )
     618                return E_OUTOFMEMORY;
     619
     620        QUARTZ_IUnkInit( &prpb->unk, NULL );
     621        hr = CRegPropertyBag_InitIPropertyBag( prpb, hkRoot, lpKeyPath );
     622        if ( FAILED(hr) )
     623        {
     624                QUARTZ_FreeObj( prpb );
     625                return hr;
     626        }
     627
     628        prpb->unk.pEntries = CRegPropertyBag_IFEntries;
     629        prpb->unk.dwEntries = sizeof(CRegPropertyBag_IFEntries)/sizeof(CRegPropertyBag_IFEntries[0]);
     630        prpb->unk.pOnFinalRelease = &QUARTZ_DestroyRegPropertyBag;
     631
     632        *ppPropBag = (IPropertyBag*)(&prpb->propbag);
     633
     634        return S_OK;
     635}
     636
     637
     638
  • trunk/src/quartz/devmon.h

    r6710 r6952  
    3434
    3535
     36/*
     37                implements IPropertyBag for accessing registry.
     38
     39        - At least, the following interfaces should be implemented:
     40
     41        IUnknown
     42                + IPropertyBag
     43 */
     44
     45#include "iunk.h"
     46
     47typedef struct DMON_IPropertyBagImpl
     48{
     49        ICOM_VFIELD(IPropertyBag);
     50} DMON_IPropertyBagImpl;
     51
     52typedef struct CRegPropertyBag
     53{
     54        QUARTZ_IUnkImpl unk;
     55        DMON_IPropertyBagImpl   propbag;
     56        /* IPropertyBag fields */
     57        HKEY    m_hKey;
     58} CRegPropertyBag;
     59
     60#define CRegPropertyBag_THIS(iface,member)      CRegPropertyBag*        This = (CRegPropertyBag*)(((char*)iface)-offsetof(CRegPropertyBag,member))
     61
     62HRESULT QUARTZ_CreateRegPropertyBag(
     63        HKEY hkRoot, LPCWSTR lpKeyPath,
     64        IPropertyBag** ppPropBag );
     65
    3666#endif  /* WINE_DSHOW_DEVMON_H */
  • trunk/src/quartz/enumunk.c

    r6710 r6952  
    1010#include "winbase.h"
    1111#include "wingdi.h"
     12#include "winuser.h"
    1213#include "winerror.h"
    1314#include "wine/obj_base.h"
     
    177178                (void**)ppunk,
    178179                This->pCompList );
     180        FIXME( "current pointer must be seeked correctly\n" );
    179181
    180182        QUARTZ_CompList_Unlock( This->pCompList );
  • trunk/src/quartz/fgidisp.c

    r6710 r6952  
    1212#include "winbase.h"
    1313#include "wingdi.h"
     14#include "winuser.h"
    1415#include "winerror.h"
    1516#include "wine/obj_base.h"
  • trunk/src/quartz/fgraph.c

    r6710 r6952  
    1010#include "winbase.h"
    1111#include "wingdi.h"
     12#include "winuser.h"
    1213#include "winerror.h"
    1314#include "wine/obj_base.h"
     
    2324#include "fgraph.h"
    2425
     26/***************************************************************************
     27 *
     28 *      new/delete for CFilterGraph
     29 *
     30 */
     31
    2532/* can I use offsetof safely? - FIXME? */
    2633static QUARTZ_IFEntry IFEntries[] =
     
    3239  { &IID_IFilterGraph2, offsetof(CFilterGraph,fgraph)-offsetof(CFilterGraph,unk) },
    3340  { &IID_IGraphVersion, offsetof(CFilterGraph,graphversion)-offsetof(CFilterGraph,unk) },
     41  { &IID_IGraphConfig, offsetof(CFilterGraph,grphconf)-offsetof(CFilterGraph,unk) },
    3442  { &IID_IMediaControl, offsetof(CFilterGraph,mediacontrol)-offsetof(CFilterGraph,unk) },
    3543  { &IID_IMediaFilter, offsetof(CFilterGraph,mediafilter)-offsetof(CFilterGraph,unk) },
     
    6068        FGENT(IFilterGraph2)
    6169        FGENT(IGraphVersion)
     70        FGENT(IGraphConfig)
    6271        FGENT(IMediaControl)
    6372        FGENT(IMediaFilter)
     
    8089        int     i;
    8190
     91        TRACE( "(%p)\n", punk );
     92
    8293        /* At first, call Stop. */
    8394        IMediaControl_Stop( CFilterGraph_IMediaControl(This) );
     
    136147
    137148
     149/***************************************************************************
     150 *
     151 *      CFilterGraph::IPersist
     152 *
     153 */
     154
     155static HRESULT WINAPI
     156IPersist_fnQueryInterface(IPersist* iface,REFIID riid,void** ppobj)
     157{
     158        CFilterGraph_THIS(iface,persist);
     159
     160        TRACE("(%p)->()\n",This);
     161
     162        return IUnknown_QueryInterface(This->unk.punkControl,riid,ppobj);
     163}
     164
     165static ULONG WINAPI
     166IPersist_fnAddRef(IPersist* iface)
     167{
     168        CFilterGraph_THIS(iface,persist);
     169
     170        TRACE("(%p)->()\n",This);
     171
     172        return IUnknown_AddRef(This->unk.punkControl);
     173}
     174
     175static ULONG WINAPI
     176IPersist_fnRelease(IPersist* iface)
     177{
     178        CFilterGraph_THIS(iface,persist);
     179
     180        TRACE("(%p)->()\n",This);
     181
     182        return IUnknown_Release(This->unk.punkControl);
     183}
     184
     185
     186static HRESULT WINAPI
     187IPersist_fnGetClassID(IPersist* iface,CLSID* pclsid)
     188{
     189        CFilterGraph_THIS(iface,persist);
     190
     191        TRACE("(%p)->()\n",This);
     192
     193        if ( pclsid == NULL )
     194                return E_POINTER;
     195        memcpy( pclsid, &CLSID_FilterGraph, sizeof(CLSID) );
     196
     197        return E_NOTIMPL;
     198}
     199
     200
     201static ICOM_VTABLE(IPersist) ipersist =
     202{
     203        ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
     204        /* IUnknown fields */
     205        IPersist_fnQueryInterface,
     206        IPersist_fnAddRef,
     207        IPersist_fnRelease,
     208        /* IPersist fields */
     209        IPersist_fnGetClassID,
     210};
     211
     212HRESULT CFilterGraph_InitIPersist( CFilterGraph* pfg )
     213{
     214        TRACE("(%p)\n",pfg);
     215        ICOM_VTBL(&pfg->persist) = &ipersist;
     216
     217        return NOERROR;
     218}
     219
     220void CFilterGraph_UninitIPersist( CFilterGraph* pfg )
     221{
     222        TRACE("(%p)\n",pfg);
     223}
  • trunk/src/quartz/fgraph.h

    r6710 r6952  
    1212                + IFilterGraph - IGraphBuilder - IFilterGraph2
    1313                + IGraphVersion
     14                + IGraphConfig
    1415                + IDispatch - IMediaControl
    1516                + IPersist - IMediaFilter
     
    5051        ICOM_VFIELD(IGraphVersion);
    5152} FG_IGraphVersionImpl;
     53
     54typedef struct FG_IGraphConfigImpl
     55{
     56        ICOM_VFIELD(IGraphConfig);
     57} FG_IGraphConfigImpl;
    5258
    5359typedef struct FG_IMediaControlImpl
     
    96102} FG_IVideoWindowImpl;
    97103
     104typedef struct FilterGraph_MEDIAEVENT   FilterGraph_MEDIAEVENT;
    98105
    99106typedef struct CFilterGraph
     
    104111        FG_IFilterGraph2Impl    fgraph;
    105112        FG_IGraphVersionImpl    graphversion;
     113        FG_IGraphConfigImpl     grphconf;
    106114        FG_IMediaControlImpl    mediacontrol;
    107115        FG_IMediaFilterImpl     mediafilter;
     
    124132        CRITICAL_SECTION        m_csGraphState;
    125133        FILTER_STATE    m_stateGraph; /* must NOT accessed directly! */
     134        CRITICAL_SECTION        m_csClock;
     135        IReferenceClock*        m_pClock;
    126136        /* IMediaEvent fields. */
    127137        HANDLE  m_hMediaEvent;
     138        CRITICAL_SECTION        m_csMediaEvents;
     139        FilterGraph_MEDIAEVENT* m_pMediaEvents;
     140        ULONG   m_cbMediaEventsPut;
     141        ULONG   m_cbMediaEventsGet;
     142        ULONG   m_cbMediaEventsMax;
     143        HWND    m_hwndEventNotify;
     144        long    m_lEventNotifyMsg;
     145        LONG_PTR        m_lEventNotifyParam;
     146        long    m_lEventNotifyFlags;
    128147        /* IMediaEventSink fields. */
    129148        /* IMediaPosition fields. */
     
    138157#define CFilterGraph_IDispatch(th)              ((IDispatch*)&((th)->disp))
    139158#define CFilterGraph_IFilterGraph2(th)          ((IFilterGraph2*)&((th)->fgraph))
     159#define CFilterGraph_IMediaControl(th)          ((IMediaControl*)&((th)->mediacontrol))
    140160#define CFilterGraph_IMediaFilter(th)           ((IMediaFilter*)&((th)->mediafilter))
    141 #define CFilterGraph_IMediaControl(th)          ((IMediaControl*)&((th)->mediacontrol))
     161#define CFilterGraph_IMediaEventEx(th)          ((IMediaEventEx*)&((th)->mediaevent))
     162#define CFilterGraph_IMediaEventSink(th)                ((IMediaEventSink*)&((th)->mediaeventsink))
    142163
    143164HRESULT QUARTZ_CreateFilterGraph(IUnknown* punkOuter,void** ppobj);
     
    151172HRESULT CFilterGraph_InitIGraphVersion( CFilterGraph* pfg );
    152173void CFilterGraph_UninitIGraphVersion( CFilterGraph* pfg );
     174HRESULT CFilterGraph_InitIGraphConfig( CFilterGraph* pfg );
     175void CFilterGraph_UninitIGraphConfig( CFilterGraph* pfg );
    153176HRESULT CFilterGraph_InitIMediaControl( CFilterGraph* pfg );
    154177void CFilterGraph_UninitIMediaControl( CFilterGraph* pfg );
  • trunk/src/quartz/fmap.c

    r6710 r6952  
    1212#include "winbase.h"
    1313#include "wingdi.h"
     14#include "winuser.h"
     15#include "winreg.h"
    1416#include "winerror.h"
    1517#include "wine/obj_base.h"
     
    2426#include "quartz_private.h"
    2527#include "fmap.h"
     28#include "regsvr.h"
     29
     30
     31/***************************************************************************
     32 *
     33 *      new/delete for CLSID_FilterMapper
     34 *
     35 */
    2636
    2737/* can I use offsetof safely? - FIXME? */
     
    6676        return S_OK;
    6777}
     78
     79/***************************************************************************
     80 *
     81 *      CLSID_FilterMapper::IFilterMapper
     82 *
     83 */
     84
     85static HRESULT WINAPI
     86IFilterMapper_fnQueryInterface(IFilterMapper* iface,REFIID riid,void** ppobj)
     87{
     88        CFilterMapper_THIS(iface,fmap);
     89
     90        TRACE("(%p)->()\n",This);
     91
     92        return IUnknown_QueryInterface(This->unk.punkControl,riid,ppobj);
     93}
     94
     95static ULONG WINAPI
     96IFilterMapper_fnAddRef(IFilterMapper* iface)
     97{
     98        CFilterMapper_THIS(iface,fmap);
     99
     100        TRACE("(%p)->()\n",This);
     101
     102        return IUnknown_AddRef(This->unk.punkControl);
     103}
     104
     105static ULONG WINAPI
     106IFilterMapper_fnRelease(IFilterMapper* iface)
     107{
     108        CFilterMapper_THIS(iface,fmap);
     109
     110        TRACE("(%p)->()\n",This);
     111
     112        return IUnknown_Release(This->unk.punkControl);
     113}
     114
     115
     116static HRESULT WINAPI
     117IFilterMapper_fnRegisterFilter(IFilterMapper* iface,CLSID clsid,LPCWSTR lpwszName,DWORD dwMerit)
     118{
     119        CFilterMapper_THIS(iface,fmap);
     120
     121        FIXME("(%p)->(%s,%s,%08lx)\n",This,
     122                debugstr_guid(&clsid),debugstr_w(lpwszName),dwMerit);
     123
     124        /* FIXME */
     125        /* FIXME - handle dwMerit! */
     126        return QUARTZ_RegisterAMovieFilter(
     127                &CLSID_LegacyAmFilterCategory,
     128                &clsid,
     129                NULL, 0,
     130                lpwszName, NULL, TRUE );
     131}
     132
     133static HRESULT WINAPI
     134IFilterMapper_fnRegisterFilterInstance(IFilterMapper* iface,CLSID clsid,LPCWSTR lpwszName,CLSID* pclsidMedia)
     135{
     136        CFilterMapper_THIS(iface,fmap);
     137        HRESULT hr;
     138
     139        FIXME("(%p)->()\n",This);
     140
     141        if ( pclsidMedia == NULL )
     142                return E_POINTER;
     143        hr = CoCreateGuid(pclsidMedia);
     144        if ( FAILED(hr) )
     145                return hr;
     146
     147        /* FIXME */
     148        /* this doesn't work. */
     149        /* return IFilterMapper_RegisterFilter(iface,
     150                *pclsidMedia,lpwszName,0x60000000); */
     151
     152        return E_NOTIMPL;
     153}
     154
     155static HRESULT WINAPI
     156IFilterMapper_fnRegisterPin(IFilterMapper* iface,CLSID clsidFilter,LPCWSTR lpwszName,BOOL bRendered,BOOL bOutput,BOOL bZero,BOOL bMany,CLSID clsidReserved,LPCWSTR lpwszReserved)
     157{
     158        CFilterMapper_THIS(iface,fmap);
     159
     160        FIXME("(%p)->() stub!\n",This);
     161
     162        return E_NOTIMPL;
     163}
     164
     165static HRESULT WINAPI
     166IFilterMapper_fnRegisterPinType(IFilterMapper* iface,CLSID clsidFilter,LPCWSTR lpwszName,CLSID clsidMajorType,CLSID clsidSubType)
     167{
     168        CFilterMapper_THIS(iface,fmap);
     169
     170        FIXME("(%p)->() stub!\n",This);
     171
     172        return E_NOTIMPL;
     173}
     174
     175static HRESULT WINAPI
     176IFilterMapper_fnUnregisterFilter(IFilterMapper* iface,CLSID clsidFilter)
     177{
     178        CFilterMapper_THIS(iface,fmap);
     179
     180        FIXME("(%p)->(%s)\n",This,debugstr_guid(&clsidFilter));
     181
     182        /* FIXME */
     183        return QUARTZ_RegisterAMovieFilter(
     184                &CLSID_LegacyAmFilterCategory,
     185                &clsidFilter,
     186                NULL, 0, NULL, NULL, FALSE );
     187}
     188
     189static HRESULT WINAPI
     190IFilterMapper_fnUnregisterFilterInstance(IFilterMapper* iface,CLSID clsidMedia)
     191{
     192        CFilterMapper_THIS(iface,fmap);
     193
     194        FIXME("(%p)->(%s)\n",This,debugstr_guid(&clsidMedia));
     195
     196        /* FIXME */
     197        /* this doesn't work. */
     198        /* return IFilterMapper_UnregisterFilter(iface,clsidMedia); */
     199
     200        return E_NOTIMPL;
     201}
     202
     203static HRESULT WINAPI
     204IFilterMapper_fnUnregisterPin(IFilterMapper* iface,CLSID clsidPin,LPCWSTR lpwszName)
     205{
     206        CFilterMapper_THIS(iface,fmap);
     207
     208        FIXME("(%p)->(%s,%s) stub!\n",This,
     209                debugstr_guid(&clsidPin),debugstr_w(lpwszName));
     210
     211        return E_NOTIMPL;
     212}
     213
     214static HRESULT WINAPI
     215IFilterMapper_fnEnumMatchingFilters(IFilterMapper* iface,IEnumRegFilters** ppobj,DWORD dwMerit,BOOL bInputNeeded,CLSID clsInMajorType,CLSID clsidSubType,BOOL bRender,BOOL bOutputNeeded,CLSID clsOutMajorType,CLSID clsOutSubType)
     216{
     217        CFilterMapper_THIS(iface,fmap);
     218
     219        FIXME("(%p)->() stub!\n",This);
     220
     221        return E_NOTIMPL;
     222}
     223
     224
     225
     226static ICOM_VTABLE(IFilterMapper) ifmap =
     227{
     228        ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
     229        /* IUnknown fields */
     230        IFilterMapper_fnQueryInterface,
     231        IFilterMapper_fnAddRef,
     232        IFilterMapper_fnRelease,
     233        /* IFilterMapper fields */
     234        IFilterMapper_fnRegisterFilter,
     235        IFilterMapper_fnRegisterFilterInstance,
     236        IFilterMapper_fnRegisterPin,
     237        IFilterMapper_fnRegisterPinType,
     238        IFilterMapper_fnUnregisterFilter,
     239        IFilterMapper_fnUnregisterFilterInstance,
     240        IFilterMapper_fnUnregisterPin,
     241        IFilterMapper_fnEnumMatchingFilters,
     242};
     243
     244
     245HRESULT CFilterMapper_InitIFilterMapper( CFilterMapper* pfm )
     246{
     247        TRACE("(%p)\n",pfm);
     248        ICOM_VTBL(&pfm->fmap) = &ifmap;
     249
     250        return NOERROR;
     251}
     252
     253void CFilterMapper_UninitIFilterMapper( CFilterMapper* pfm )
     254{
     255        TRACE("(%p)\n",pfm);
     256}
  • trunk/src/quartz/fmap2.c

    r6710 r6952  
    1212#include "winbase.h"
    1313#include "wingdi.h"
     14#include "winuser.h"
     15#include "winreg.h"
    1416#include "winerror.h"
    1517#include "wine/obj_base.h"
     
    2426#include "quartz_private.h"
    2527#include "fmap2.h"
     28#include "regsvr.h"
     29
     30
     31/***************************************************************************
     32 *
     33 *      new/delete for CLSID_FilterMapper2
     34 *
     35 */
    2636
    2737/* can I use offsetof safely? - FIXME? */
     
    6777        return S_OK;
    6878}
     79
     80/***************************************************************************
     81 *
     82 *      CLSID_FilterMapper2::IFilterMapper3
     83 *
     84 */
     85
     86
     87static HRESULT WINAPI
     88IFilterMapper3_fnQueryInterface(IFilterMapper3* iface,REFIID riid,void** ppobj)
     89{
     90        CFilterMapper2_THIS(iface,fmap3);
     91
     92        TRACE("(%p)->()\n",This);
     93
     94        return IUnknown_QueryInterface(This->unk.punkControl,riid,ppobj);
     95}
     96
     97static ULONG WINAPI
     98IFilterMapper3_fnAddRef(IFilterMapper3* iface)
     99{
     100        CFilterMapper2_THIS(iface,fmap3);
     101
     102        TRACE("(%p)->()\n",This);
     103
     104        return IUnknown_AddRef(This->unk.punkControl);
     105}
     106
     107static ULONG WINAPI
     108IFilterMapper3_fnRelease(IFilterMapper3* iface)
     109{
     110        CFilterMapper2_THIS(iface,fmap3);
     111
     112        TRACE("(%p)->()\n",This);
     113
     114        return IUnknown_Release(This->unk.punkControl);
     115}
     116
     117static HRESULT WINAPI
     118IFilterMapper3_fnCreateCategory(IFilterMapper3* iface,REFCLSID rclsidCategory,DWORD dwMerit,LPCWSTR lpwszDesc)
     119{
     120        CFilterMapper2_THIS(iface,fmap3);
     121
     122        FIXME("(%p)->(%s,%lu,%s) stub!\n",This,
     123                debugstr_guid(rclsidCategory),
     124                (unsigned long)dwMerit,debugstr_w(lpwszDesc));
     125
     126        return E_NOTIMPL;
     127}
     128
     129
     130static HRESULT WINAPI
     131IFilterMapper3_fnUnregisterFilter(IFilterMapper3* iface,const CLSID* pclsidCategory,const OLECHAR* lpwszInst,REFCLSID rclsidFilter)
     132{
     133        CFilterMapper2_THIS(iface,fmap3);
     134
     135        FIXME("(%p)->(%s,%s,%s) stub!\n",This,
     136                debugstr_guid(pclsidCategory),
     137                debugstr_w(lpwszInst),
     138                debugstr_guid(rclsidFilter));
     139
     140        if ( pclsidCategory == NULL )
     141                pclsidCategory = &CLSID_LegacyAmFilterCategory;
     142
     143        /* FIXME */
     144        return QUARTZ_RegisterAMovieFilter(
     145                pclsidCategory,
     146                rclsidFilter,
     147                NULL, 0,
     148                NULL, lpwszInst, FALSE );
     149}
     150
     151
     152static HRESULT WINAPI
     153IFilterMapper3_fnRegisterFilter(IFilterMapper3* iface,REFCLSID rclsidFilter,LPCWSTR lpName,IMoniker** ppMoniker,const CLSID* pclsidCategory,const OLECHAR* lpwszInst,const REGFILTER2* pRF2)
     154{
     155        CFilterMapper2_THIS(iface,fmap3);
     156
     157        FIXME( "(%p)->(%s,%s,%p,%s,%s,%p) stub!\n",This,
     158                debugstr_guid(rclsidFilter),debugstr_w(lpName),
     159                ppMoniker,debugstr_guid(pclsidCategory),
     160                debugstr_w(lpwszInst),pRF2 );
     161
     162        if ( lpName == NULL || pRF2 == NULL )
     163                return E_POINTER;
     164
     165        if ( ppMoniker != NULL )
     166        {
     167                FIXME( "ppMoniker != NULL - not implemented!\n" );
     168                return E_NOTIMPL;
     169        }
     170
     171        if ( pclsidCategory == NULL )
     172                pclsidCategory = &CLSID_LegacyAmFilterCategory;
     173
     174        /* FIXME!! - all members in REGFILTER2 are ignored ! */
     175
     176        return QUARTZ_RegisterAMovieFilter(
     177                pclsidCategory,
     178                rclsidFilter,
     179                NULL, 0,
     180                lpName, lpwszInst, TRUE );
     181}
     182
     183
     184static HRESULT WINAPI
     185IFilterMapper3_fnEnumMatchingFilters(IFilterMapper3* iface,IEnumMoniker** ppMoniker,DWORD dwFlags,BOOL bExactMatch,DWORD dwMerit,BOOL bInputNeeded,DWORD cInputTypes,const GUID* pguidInputTypes,const REGPINMEDIUM* pPinMediumIn,const CLSID* pPinCategoryIn,BOOL bRender,BOOL bOutputNeeded,DWORD cOutputTypes,const GUID* pguidOutputTypes,const REGPINMEDIUM* pPinMediumOut,const CLSID* pPinCategoryOut)
     186{
     187        CFilterMapper2_THIS(iface,fmap3);
     188
     189        FIXME("(%p)->() stub!\n",This);
     190
     191        return E_NOTIMPL;
     192}
     193
     194static HRESULT WINAPI
     195IFilterMapper3_fnGetICreateDevEnum(IFilterMapper3* iface,ICreateDevEnum** ppDevEnum)
     196{
     197        CFilterMapper2_THIS(iface,fmap3);
     198
     199        /* undocumented */
     200        FIXME("(%p)->() stub!\n",This);
     201
     202        return E_NOTIMPL;
     203}
     204
     205
     206
     207
     208static ICOM_VTABLE(IFilterMapper3) ifmap3 =
     209{
     210        ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
     211        /* IUnknown fields */
     212        IFilterMapper3_fnQueryInterface,
     213        IFilterMapper3_fnAddRef,
     214        IFilterMapper3_fnRelease,
     215        /* IFilterMapper2 fields */
     216        IFilterMapper3_fnCreateCategory,
     217        IFilterMapper3_fnUnregisterFilter,
     218        IFilterMapper3_fnRegisterFilter,
     219        IFilterMapper3_fnEnumMatchingFilters,
     220        /* IFilterMapper3 fields */
     221        IFilterMapper3_fnGetICreateDevEnum,
     222};
     223
     224
     225HRESULT CFilterMapper2_InitIFilterMapper3( CFilterMapper2* pfm )
     226{
     227        TRACE("(%p)\n",pfm);
     228        ICOM_VTBL(&pfm->fmap3) = &ifmap3;
     229
     230        return NOERROR;
     231}
     232
     233void CFilterMapper2_UninitIFilterMapper3( CFilterMapper2* pfm )
     234{
     235        TRACE("(%p)\n",pfm);
     236}
     237
  • trunk/src/quartz/ifgraph.c

    r6710 r6952  
    22 * Implementation of IFilterGraph.
    33 *
    4  * FIXME - stub.
    5  * FIXME - implement IGraphBuilder / IFilterGraph2.
     4 * FIXME - create a thread to process some methods correctly.
     5 *
     6 * FIXME - ReconnectEx
     7 * FIXME - process Pause/Stop asynchronously and notify when completed.
     8 *
    69 *
    710 * hidenori@a2.ctktv.ne.jp
     
    1316#include "winbase.h"
    1417#include "wingdi.h"
     18#include "winuser.h"
    1519#include "winerror.h"
    1620#include "wine/obj_base.h"
     
    2125#include "vfwmsgs.h"
    2226#include "wine/unicode.h"
     27#include "evcode.h"
    2328
    2429#include "debugtools.h"
     
    2833#include "fgraph.h"
    2934#include "enumunk.h"
     35#include "sysclock.h"
    3036
    3137
     
    7581
    7682
     83static HRESULT CFilterGraph_GraphChanged( CFilterGraph* This )
     84{
     85        /* IDistributorNotify_NotifyGraphChange() */
     86
     87        IMediaEventSink_Notify(CFilterGraph_IMediaEventSink(This),
     88                        EC_GRAPH_CHANGED, 0, 0);
     89        EnterCriticalSection( &This->m_csGraphVersion );
     90        This->m_lGraphVersion ++;
     91        LeaveCriticalSection( &This->m_csGraphVersion );
     92
     93        return NOERROR;
     94}
     95
     96
    7797/****************************************************************************/
    7898
     
    111131{
    112132        CFilterGraph_THIS(iface,fgraph);
     133        FILTER_STATE fs;
    113134        FILTER_INFO     info;
    114135        HRESULT hr;
     
    120141
    121142        QUARTZ_CompList_Lock( This->m_pFilterList );
     143
     144        hr = IMediaFilter_GetState(CFilterGraph_IMediaFilter(This),0,&fs);
     145        if ( hr == VFW_S_STATE_INTERMEDIATE )
     146                hr = VFW_E_STATE_CHANGED;
     147        if ( fs != State_Stopped )
     148                hr = VFW_E_NOT_STOPPED;
     149        if ( FAILED(hr) )
     150                goto end;
     151
     152        TRACE( "(%p) search the specified name.\n",This );
    122153
    123154        if ( pName != NULL )
     
    180211
    181212name_ok:
     213        TRACE( "(%p) add this filter.\n",This );
     214
    182215        /* register this filter. */
    183216        hr = QUARTZ_CompList_AddComp(
     
    188221
    189222        hr = IBaseFilter_JoinFilterGraph(pFilter,(IFilterGraph*)iface,pName);
    190         if ( FAILED(hr) )
    191         {
     223        if ( SUCCEEDED(hr) )
     224        {
     225                EnterCriticalSection( &This->m_csClock );
     226                hr = IBaseFilter_SetSyncSource( pFilter, This->m_pClock );
     227                LeaveCriticalSection( &This->m_csClock );
     228        }
     229        if ( FAILED(hr) )
     230        {
     231                IBaseFilter_JoinFilterGraph(pFilter,NULL,pName);
    192232                QUARTZ_CompList_RemoveComp(
    193233                        This->m_pFilterList,(IUnknown*)pFilter);
     
    195235        }
    196236
    197         EnterCriticalSection( &This->m_csGraphVersion );
    198         This->m_lGraphVersion ++;
    199         LeaveCriticalSection( &This->m_csGraphVersion );
     237        hr = CFilterGraph_GraphChanged(This);
     238        if ( FAILED(hr) )
     239                goto end;
    200240
    201241        hr = hrSucceeded;
     
    203243        QUARTZ_CompList_Unlock( This->m_pFilterList );
    204244
     245        TRACE( "(%p) return %08lx\n", This, hr );
     246
    205247        return hr;
    206248}
     
    211253        CFilterGraph_THIS(iface,fgraph);
    212254        QUARTZ_CompListItem*    pItem;
     255        FILTER_STATE fs;
    213256        HRESULT hr = NOERROR;
    214257
     
    217260        QUARTZ_CompList_Lock( This->m_pFilterList );
    218261
     262        hr = IMediaFilter_GetState(CFilterGraph_IMediaFilter(This),0,&fs);
     263        if ( hr == VFW_S_STATE_INTERMEDIATE )
     264                hr = VFW_E_STATE_CHANGED;
     265        if ( fs != State_Stopped )
     266                hr = VFW_E_NOT_STOPPED;
     267        if ( FAILED(hr) )
     268                goto end;
     269
     270        hr = S_FALSE; /* FIXME? */
    219271        pItem = QUARTZ_CompList_SearchComp(
    220272                This->m_pFilterList, (IUnknown*)pFilter );
     
    222274        {
    223275                CFilterGraph_DisconnectAllPins(pFilter);
     276                IBaseFilter_SetSyncSource( pFilter, NULL );
    224277                hr = IBaseFilter_JoinFilterGraph(
    225278                        pFilter, NULL, QUARTZ_CompList_GetDataPtr(pItem) );
     
    228281        }
    229282
    230         EnterCriticalSection( &This->m_csGraphVersion );
    231         This->m_lGraphVersion ++;
    232         LeaveCriticalSection( &This->m_csGraphVersion );
    233 
     283        hr = CFilterGraph_GraphChanged(This);
     284        if ( FAILED(hr) )
     285                goto end;
     286
     287end:;
    234288        QUARTZ_CompList_Unlock( This->m_pFilterList );
    235289
     
    332386        pConnTo = NULL;
    333387        hr = IPin_ConnectedTo(pIn,&pConnTo);
    334         if ( FAILED(hr) )
    335                 goto end;
    336         if ( pConnTo != NULL )
     388        if ( hr == NOERROR && pConnTo != NULL )
    337389        {
    338390                IPin_Release(pConnTo);
     391                hr = VFW_E_ALREADY_CONNECTED;
    339392                goto end;
    340393        }
     
    342395        pConnTo = NULL;
    343396        hr = IPin_ConnectedTo(pOut,&pConnTo);
    344         if ( FAILED(hr) )
    345                 goto end;
    346         if ( pConnTo != NULL )
     397        if ( hr == NOERROR && pConnTo != NULL )
    347398        {
    348399                IPin_Release(pConnTo);
    349                 goto end;
    350         }
    351 
    352         hr = IPin_Connect(pIn,pOut,pmt);
    353         if ( FAILED(hr) )
    354                 goto end;
     400                hr = VFW_E_ALREADY_CONNECTED;
     401                goto end;
     402        }
     403
     404        TRACE("(%p) try to connect %p<->%p\n",This,pIn,pOut);
    355405        hr = IPin_Connect(pOut,pIn,pmt);
    356406        if ( FAILED(hr) )
    357407        {
     408                TRACE("(%p)->Connect(%p,%p) hr = %08lx\n",pOut,pIn,pmt,hr);
     409                IPin_Disconnect(pOut);
    358410                IPin_Disconnect(pIn);
    359411                goto end;
    360412        }
    361413
    362         EnterCriticalSection( &This->m_csGraphVersion );
    363         This->m_lGraphVersion ++;
    364         LeaveCriticalSection( &This->m_csGraphVersion );
     414        hr = CFilterGraph_GraphChanged(This);
     415        if ( FAILED(hr) )
     416                goto end;
    365417
    366418end:
     
    384436        CFilterGraph_THIS(iface,fgraph);
    385437
    386         FIXME( "(%p)->(%p) stub!\n",This,pPin );
    387 
    388         EnterCriticalSection( &This->m_csGraphVersion );
    389         This->m_lGraphVersion ++;
    390         LeaveCriticalSection( &This->m_csGraphVersion );
    391 
    392         return E_NOTIMPL;
     438        TRACE( "(%p)->(%p)\n",This,pPin );
     439
     440        return IFilterGraph2_ReconnectEx(iface,pPin,NULL);
    393441}
    394442
     
    397445{
    398446        CFilterGraph_THIS(iface,fgraph);
    399 
    400         FIXME( "(%p)->(%p) stub!\n",This,pPin );
    401 
    402         EnterCriticalSection( &This->m_csGraphVersion );
    403         This->m_lGraphVersion ++;
    404         LeaveCriticalSection( &This->m_csGraphVersion );
    405 
    406         return E_NOTIMPL;
     447        IPin* pConnTo;
     448        HRESULT hr;
     449
     450        TRACE( "(%p)->(%p)\n",This,pPin );
     451
     452        QUARTZ_CompList_Lock( This->m_pFilterList );
     453
     454        pConnTo = NULL;
     455        hr = IPin_ConnectedTo(pPin,&pConnTo);
     456        if ( hr == NOERROR && pConnTo != NULL )
     457        {
     458                IPin_Disconnect(pConnTo);
     459                IPin_Release(pConnTo);
     460        }
     461        hr = IPin_Disconnect(pPin);
     462        if ( FAILED(hr) )
     463                goto end;
     464
     465        hr = CFilterGraph_GraphChanged(This);
     466        if ( FAILED(hr) )
     467                goto end;
     468
     469end:
     470        QUARTZ_CompList_Unlock( This->m_pFilterList );
     471
     472        return hr;
    407473}
    408474
     
    411477{
    412478        CFilterGraph_THIS(iface,fgraph);
     479        IUnknown* punk;
     480        IReferenceClock* pClock;
     481        HRESULT hr;
    413482
    414483        FIXME( "(%p)->() stub!\n", This );
    415         return E_NOTIMPL;
     484
     485        /* FIXME - search all filters. */
     486
     487        hr = QUARTZ_CreateSystemClock( NULL, (void**)&punk );
     488        if ( FAILED(hr) )
     489                return hr;
     490        hr = IUnknown_QueryInterface( punk, &IID_IReferenceClock, (void**)&pClock );    IUnknown_Release( punk );
     491        if ( FAILED(hr) )
     492                return hr;
     493
     494        hr = IMediaFilter_SetSyncSource(
     495                CFilterGraph_IMediaFilter(This), pClock );
     496        IReferenceClock_Release( pClock );
     497
     498        return hr;
    416499}
    417500
     
    580663{
    581664        CFilterGraph_THIS(iface,fgraph);
     665        HRESULT hr;
    582666
    583667        FIXME( "(%p)->(%p,%p) stub!\n",This,pPin,pmt );
    584668
    585         EnterCriticalSection( &This->m_csGraphVersion );
    586         This->m_lGraphVersion ++;
    587         LeaveCriticalSection( &This->m_csGraphVersion );
     669        /* reconnect asynchronously. */
     670
     671        hr = CFilterGraph_GraphChanged(This);
    588672
    589673        return E_NOTIMPL;
     
    657741                if ( pItem == NULL )
    658742                        break;
    659                 IFilterGraph2_fnRemoveFilter(
     743                IFilterGraph2_RemoveFilter(
    660744                        (IFilterGraph2*)(&pfg->fgraph),
    661745                        (IBaseFilter*)QUARTZ_CompList_GetItemPtr(pItem) );
  • trunk/src/quartz/igrver.c

    r6710 r6952  
    1212#include "winbase.h"
    1313#include "wingdi.h"
     14#include "winuser.h"
    1415#include "winerror.h"
    1516#include "wine/obj_base.h"
  • trunk/src/quartz/imcntl.c

    r6710 r6952  
    1212#include "winbase.h"
    1313#include "wingdi.h"
     14#include "winuser.h"
    1415#include "winerror.h"
    1516#include "wine/obj_base.h"
  • trunk/src/quartz/imfilter.c

    r6710 r6952  
    1212#include "winbase.h"
    1313#include "wingdi.h"
     14#include "winuser.h"
    1415#include "winerror.h"
    1516#include "wine/obj_base.h"
     
    1920#include "uuids.h"
    2021#include "vfwmsgs.h"
     22#include "evcode.h"
    2123
    2224#include "debugtools.h"
     
    127129        if ( This->m_stateGraph != State_Stopped )
    128130        {
     131                /* IDistributorNotify_Stop() */
     132
    129133                QUARTZ_CompList_Lock( This->m_pFilterList );
    130134
     
    171175        if ( This->m_stateGraph != State_Paused )
    172176        {
     177                /* IDistributorNotify_Pause() */
     178
    173179                QUARTZ_CompList_Lock( This->m_pFilterList );
    174180
     
    210216        TRACE("(%p)->()\n",This);
    211217
    212         /* handle the special time. */
    213         if ( rtStart == (REFERENCE_TIME)0 )
    214         {
    215                 hr = IMediaFilter_GetSyncSource(iface,&pClock);
    216                 if ( hr == S_OK && pClock != NULL )
    217                 {
    218                         IReferenceClock_GetTime(pClock,&rtStart);
    219                         IReferenceClock_Release(pClock);
    220                 }
    221         }
    222 
    223         hr = S_OK;
    224 
    225218        EnterCriticalSection( &This->m_csGraphState );
    226219
     220        if ( This->m_stateGraph == State_Stopped )
     221        {
     222                hr = IMediaFilter_Pause(iface);
     223                if ( FAILED(hr) )
     224                        goto end;
     225        }
     226
     227        /* handle the special time. */
     228        if ( rtStart == (REFERENCE_TIME)0 )
     229        {
     230                hr = IMediaFilter_GetSyncSource(iface,&pClock);
     231                if ( hr == S_OK && pClock != NULL )
     232                {
     233                        IReferenceClock_GetTime(pClock,&rtStart);
     234                        IReferenceClock_Release(pClock);
     235                }
     236        }
     237
     238        hr = NOERROR;
     239
    227240        if ( This->m_stateGraph != State_Running )
    228241        {
     242                /* IDistributorNotify_Run() */
     243
    229244                QUARTZ_CompList_Lock( This->m_pFilterList );
    230245
     
    249264        }
    250265
     266end:
    251267        LeaveCriticalSection( &This->m_csGraphState );
    252268
     
    265281        if ( pState == NULL )
    266282                return E_POINTER;
    267 
    268         EnterCriticalSection( &This->m_csGraphState );
    269         *pState = This->m_stateGraph;
    270         LeaveCriticalSection( &This->m_csGraphState );
    271283
    272284        dwTickStart = GetTickCount();
     
    292304        }
    293305
     306        EnterCriticalSection( &This->m_csGraphState );
     307        *pState = This->m_stateGraph;
     308        LeaveCriticalSection( &This->m_csGraphState );
     309
    294310        return hr;
    295311}
     
    299315{
    300316        CFilterGraph_THIS(iface,mediafilter);
    301 
    302         FIXME("(%p)->() stub!\n",This);
    303 
    304         return E_NOTIMPL;
     317        QUARTZ_CompListItem*    pItem;
     318        IBaseFilter*    pFilter;
     319        HRESULT hr = NOERROR;
     320        HRESULT hrCur;
     321
     322        TRACE("(%p)->(%p)\n",This,pobjClock);
     323
     324        /* IDistributorNotify_SetSyncSource() */
     325
     326        EnterCriticalSection( &This->m_csClock );
     327        QUARTZ_CompList_Lock( This->m_pFilterList );
     328
     329        if ( This->m_pClock != NULL )
     330        {
     331                IReferenceClock_Release(This->m_pClock);
     332                This->m_pClock = NULL;
     333        }
     334
     335        This->m_pClock = pobjClock;
     336        if ( pobjClock != NULL )
     337                IReferenceClock_AddRef( pobjClock );
     338
     339        pItem = QUARTZ_CompList_GetFirst( This->m_pFilterList );
     340        while ( pItem != NULL )
     341        {
     342                pFilter = (IBaseFilter*)QUARTZ_CompList_GetItemPtr( pItem );
     343                hrCur = IBaseFilter_SetSyncSource(pFilter,pobjClock);
     344                if ( FAILED(hrCur) )
     345                        hr = hrCur;
     346                pItem = QUARTZ_CompList_GetNext( This->m_pFilterList, pItem );
     347        }
     348
     349        QUARTZ_CompList_Unlock( This->m_pFilterList );
     350
     351        IMediaEventSink_Notify(CFilterGraph_IMediaEventSink(This),
     352                EC_CLOCK_CHANGED, 0, 0);
     353
     354        LeaveCriticalSection( &This->m_csClock );
     355
     356        TRACE( "hr = %08lx\n", hr );
     357
     358        return hr;
    305359}
    306360
     
    309363{
    310364        CFilterGraph_THIS(iface,mediafilter);
    311 
    312         FIXME("(%p)->() stub!\n",This);
    313 
    314         return E_NOTIMPL;
     365        HRESULT hr = VFW_E_NO_CLOCK;
     366
     367        TRACE("(%p)->(%p)\n",This,ppobjClock);
     368
     369        if ( ppobjClock == NULL )
     370                return E_POINTER;
     371
     372        EnterCriticalSection( &This->m_csClock );
     373        *ppobjClock = This->m_pClock;
     374        if ( This->m_pClock != NULL )
     375        {
     376                hr = NOERROR;
     377                IReferenceClock_AddRef( This->m_pClock );
     378        }
     379        LeaveCriticalSection( &This->m_csClock );
     380
     381        TRACE( "hr = %08lx\n", hr );
     382
     383        return hr;
    315384}
    316385
     
    342411
    343412        InitializeCriticalSection( &pfg->m_csGraphState );
     413        InitializeCriticalSection( &pfg->m_csClock );
    344414        pfg->m_stateGraph = State_Stopped;
     415        pfg->m_pClock = NULL;
    345416
    346417        return NOERROR;
     
    351422        TRACE("(%p)\n",pfg);
    352423
     424        if ( pfg->m_pClock != NULL )
     425        {
     426                IReferenceClock_Release( pfg->m_pClock );
     427                pfg->m_pClock = NULL;
     428        }
     429
    353430        DeleteCriticalSection( &pfg->m_csGraphState );
    354 }
     431        DeleteCriticalSection( &pfg->m_csClock );
     432}
  • trunk/src/quartz/impos.c

    r6710 r6952  
    1212#include "winbase.h"
    1313#include "wingdi.h"
     14#include "winuser.h"
    1415#include "winerror.h"
    1516#include "wine/obj_base.h"
  • trunk/src/quartz/imseek.c

    r6710 r6952  
    33 *
    44 * FIXME - stub.
     5 * FIXME - this interface should be allocated as a plug-in(?)
    56 *
    67 * hidenori@a2.ctktv.ne.jp
     
    1213#include "winbase.h"
    1314#include "wingdi.h"
     15#include "winuser.h"
    1416#include "winerror.h"
    1517#include "wine/obj_base.h"
     
    133135        CFilterGraph_THIS(iface,mediaseeking);
    134136
     137        /* the following line may produce too many FIXMEs... */
    135138        FIXME("(%p)->() stub!\n",This);
    136139
  • trunk/src/quartz/iunk.c

    r6710 r6952  
    6666                        if ( hr == E_NOINTERFACE )
    6767                        {
    68                                 FIXME("unknown interface: %s\n",debugstr_guid(riid));
     68                                FIXME("(%p) unknown interface: %s\n",This,debugstr_guid(riid));
    6969                        }
    7070
  • trunk/src/quartz/main.c

    r6710 r6952  
     1/*
     2 * Exported APIs.
     3 *
     4 * hidenori@a2.ctktv.ne.jp
     5 */
     6
    17#include "config.h"
    28
     
    511#include "winbase.h"
    612#include "wingdi.h"
     13#include "winuser.h"
     14#include "winnls.h"
     15#include "mmsystem.h"
    716#include "ole2.h"
    817#include "wine/obj_oleaut.h"
     
    1019#include "control.h"
    1120#include "uuids.h"
     21#include "errors.h"
    1222
    1323#include "debugtools.h"
     
    2232#include "fmap2.h"
    2333#include "seekpass.h"
     34#include "audren.h"
    2435
    2536
     
    6677        { &CLSID_FilterMapper2, &QUARTZ_CreateFilterMapper2 },
    6778        { &CLSID_SeekingPassThru, &QUARTZ_CreateSeekingPassThru },
     79        { &CLSID_AudioRender, &QUARTZ_CreateAudioRenderer },
    6880        { NULL, NULL },
    6981};
     
    105117        HeapFree( hDLLHeap, 0, pMem );
    106118}
     119
     120void* QUARTZ_ReallocMem( void* pMem, DWORD dwSize )
     121{
     122        if ( pMem == NULL )
     123                return QUARTZ_AllocMem( dwSize );
     124
     125        return HeapReAlloc( hDLLHeap, 0, pMem, dwSize );
     126}
     127
     128static
     129LPWSTR QUARTZ_strncpyAtoW( LPWSTR lpwstr, LPCSTR lpstr, INT wbuflen )
     130{
     131        INT     len;
     132
     133        len = MultiByteToWideChar( CP_ACP, 0, lpstr, -1, lpwstr, wbuflen );
     134        if ( len == 0 )
     135                *lpwstr = 0;
     136        return lpwstr;
     137}
     138
    107139
    108140/************************************************************************/
     
    264296        LPVOID lpvReserved )
    265297{
     298        TRACE("(%08x,%08lx,%p)\n",hInstDLL,fdwReason,lpvReserved);
     299
    266300        switch ( fdwReason )
    267301        {
     
    337371}
    338372
    339 
    340 
     373/**************************************************************************/
     374/**************************************************************************/
     375
     376/* FIXME - all string should be defined in the resource of quartz. */
     377
     378static LPCSTR hresult_to_string( HRESULT hr )
     379{
     380        switch ( hr )
     381        {
     382        #define ENTRY(x)        case x: return (const char*)#x
     383        /* some known codes */
     384        ENTRY(S_OK);
     385        ENTRY(S_FALSE);
     386        ENTRY(E_FAIL);
     387        ENTRY(E_POINTER);
     388        ENTRY(E_NOTIMPL);
     389        ENTRY(E_NOINTERFACE);
     390        ENTRY(E_OUTOFMEMORY);
     391        ENTRY(CLASS_E_CLASSNOTAVAILABLE);
     392        ENTRY(CLASS_E_NOAGGREGATION);
     393
     394        /* vfwmsgs.h */
     395        ENTRY(VFW_S_NO_MORE_ITEMS);
     396        ENTRY(VFW_E_BAD_KEY);
     397        ENTRY(VFW_E_INVALIDMEDIATYPE);
     398        ENTRY(VFW_E_INVALIDSUBTYPE);
     399        ENTRY(VFW_E_NEED_OWNER);
     400        ENTRY(VFW_E_ENUM_OUT_OF_SYNC);
     401        ENTRY(VFW_E_ALREADY_CONNECTED);
     402        ENTRY(VFW_E_FILTER_ACTIVE);
     403        ENTRY(VFW_E_NO_TYPES);
     404        ENTRY(VFW_E_NO_ACCEPTABLE_TYPES);
     405        ENTRY(VFW_E_INVALID_DIRECTION);
     406        ENTRY(VFW_E_NOT_CONNECTED);
     407        ENTRY(VFW_E_NO_ALLOCATOR);
     408        ENTRY(VFW_E_RUNTIME_ERROR);
     409        ENTRY(VFW_E_BUFFER_NOTSET);
     410        ENTRY(VFW_E_BUFFER_OVERFLOW);
     411        ENTRY(VFW_E_BADALIGN);
     412        ENTRY(VFW_E_ALREADY_COMMITTED);
     413        ENTRY(VFW_E_BUFFERS_OUTSTANDING);
     414        ENTRY(VFW_E_NOT_COMMITTED);
     415        ENTRY(VFW_E_SIZENOTSET);
     416        ENTRY(VFW_E_NO_CLOCK);
     417        ENTRY(VFW_E_NO_SINK);
     418        ENTRY(VFW_E_NO_INTERFACE);
     419        ENTRY(VFW_E_NOT_FOUND);
     420        ENTRY(VFW_E_CANNOT_CONNECT);
     421        ENTRY(VFW_E_CANNOT_RENDER);
     422        ENTRY(VFW_E_CHANGING_FORMAT);
     423        ENTRY(VFW_E_NO_COLOR_KEY_SET);
     424        ENTRY(VFW_E_NOT_OVERLAY_CONNECTION);
     425        ENTRY(VFW_E_NOT_SAMPLE_CONNECTION);
     426        ENTRY(VFW_E_PALETTE_SET);
     427        ENTRY(VFW_E_COLOR_KEY_SET);
     428        ENTRY(VFW_E_NO_COLOR_KEY_FOUND);
     429        ENTRY(VFW_E_NO_PALETTE_AVAILABLE);
     430        ENTRY(VFW_E_NO_DISPLAY_PALETTE);
     431        ENTRY(VFW_E_TOO_MANY_COLORS);
     432        ENTRY(VFW_E_STATE_CHANGED);
     433        ENTRY(VFW_E_NOT_STOPPED);
     434        ENTRY(VFW_E_NOT_PAUSED);
     435        ENTRY(VFW_E_NOT_RUNNING);
     436        ENTRY(VFW_E_WRONG_STATE);
     437        ENTRY(VFW_E_START_TIME_AFTER_END);
     438        ENTRY(VFW_E_INVALID_RECT);
     439        ENTRY(VFW_E_TYPE_NOT_ACCEPTED);
     440        ENTRY(VFW_E_SAMPLE_REJECTED);
     441        ENTRY(VFW_E_SAMPLE_REJECTED_EOS);
     442        ENTRY(VFW_S_DUPLICATE_NAME);
     443        ENTRY(VFW_E_DUPLICATE_NAME);
     444        ENTRY(VFW_E_TIMEOUT);
     445        ENTRY(VFW_E_INVALID_FILE_FORMAT);
     446        ENTRY(VFW_E_ENUM_OUT_OF_RANGE);
     447        ENTRY(VFW_E_CIRCULAR_GRAPH);
     448        ENTRY(VFW_E_NOT_ALLOWED_TO_SAVE);
     449        ENTRY(VFW_E_TIME_ALREADY_PASSED);
     450        ENTRY(VFW_E_ALREADY_CANCELLED);
     451        ENTRY(VFW_E_CORRUPT_GRAPH_FILE);
     452        ENTRY(VFW_E_ADVISE_ALREADY_SET);
     453        ENTRY(VFW_S_STATE_INTERMEDIATE);
     454        ENTRY(VFW_E_NO_MODEX_AVAILABLE);
     455        ENTRY(VFW_E_NO_ADVISE_SET);
     456        ENTRY(VFW_E_NO_FULLSCREEN);
     457        ENTRY(VFW_E_IN_FULLSCREEN_MODE);
     458        ENTRY(VFW_E_UNKNOWN_FILE_TYPE);
     459        ENTRY(VFW_E_CANNOT_LOAD_SOURCE_FILTER);
     460        ENTRY(VFW_S_PARTIAL_RENDER);
     461        ENTRY(VFW_E_FILE_TOO_SHORT);
     462        ENTRY(VFW_E_INVALID_FILE_VERSION);
     463        ENTRY(VFW_S_SOME_DATA_IGNORED);
     464        ENTRY(VFW_S_CONNECTIONS_DEFERRED);
     465        ENTRY(VFW_E_INVALID_CLSID);
     466        ENTRY(VFW_E_INVALID_MEDIA_TYPE);
     467        ENTRY(VFW_E_SAMPLE_TIME_NOT_SET);
     468        ENTRY(VFW_S_RESOURCE_NOT_NEEDED);
     469        ENTRY(VFW_E_MEDIA_TIME_NOT_SET);
     470        ENTRY(VFW_E_NO_TIME_FORMAT_SET);
     471        ENTRY(VFW_E_MONO_AUDIO_HW);
     472        ENTRY(VFW_S_MEDIA_TYPE_IGNORED);
     473        ENTRY(VFW_E_NO_DECOMPRESSOR);
     474        ENTRY(VFW_E_NO_AUDIO_HARDWARE);
     475        ENTRY(VFW_S_VIDEO_NOT_RENDERED);
     476        ENTRY(VFW_S_AUDIO_NOT_RENDERED);
     477        ENTRY(VFW_E_RPZA);
     478        ENTRY(VFW_S_RPZA);
     479        ENTRY(VFW_E_PROCESSOR_NOT_SUITABLE);
     480        ENTRY(VFW_E_UNSUPPORTED_AUDIO);
     481        ENTRY(VFW_E_UNSUPPORTED_VIDEO);
     482        ENTRY(VFW_E_MPEG_NOT_CONSTRAINED);
     483        ENTRY(VFW_E_NOT_IN_GRAPH);
     484        ENTRY(VFW_S_ESTIMATED);
     485        ENTRY(VFW_E_NO_TIME_FORMAT);
     486        ENTRY(VFW_E_READ_ONLY);
     487        ENTRY(VFW_S_RESERVED);
     488        ENTRY(VFW_E_BUFFER_UNDERFLOW);
     489        ENTRY(VFW_E_UNSUPPORTED_STREAM);
     490        ENTRY(VFW_E_NO_TRANSPORT);
     491        ENTRY(VFW_S_STREAM_OFF);
     492        ENTRY(VFW_S_CANT_CUE);
     493        ENTRY(VFW_E_BAD_VIDEOCD);
     494        ENTRY(VFW_S_NO_STOP_TIME);
     495        ENTRY(VFW_E_OUT_OF_VIDEO_MEMORY);
     496        ENTRY(VFW_E_VP_NEGOTIATION_FAILED);
     497        ENTRY(VFW_E_DDRAW_CAPS_NOT_SUITABLE);
     498        ENTRY(VFW_E_NO_VP_HARDWARE);
     499        ENTRY(VFW_E_NO_CAPTURE_HARDWARE);
     500        ENTRY(VFW_E_DVD_OPERATION_INHIBITED);
     501        ENTRY(VFW_E_DVD_INVALIDDOMAIN);
     502        ENTRY(VFW_E_DVD_NO_BUTTON);
     503        ENTRY(VFW_E_DVD_GRAPHNOTREADY);
     504        ENTRY(VFW_E_DVD_RENDERFAIL);
     505        ENTRY(VFW_E_DVD_DECNOTENOUGH);
     506        ENTRY(VFW_E_DDRAW_VERSION_NOT_SUITABLE);
     507        ENTRY(VFW_E_COPYPROT_FAILED);
     508        ENTRY(VFW_S_NOPREVIEWPIN);
     509        ENTRY(VFW_E_TIME_EXPIRED);
     510        ENTRY(VFW_S_DVD_NON_ONE_SEQUENTIAL);
     511        ENTRY(VFW_E_DVD_WRONG_SPEED);
     512        ENTRY(VFW_E_DVD_MENU_DOES_NOT_EXIST);
     513        ENTRY(VFW_E_DVD_CMD_CANCELLED);
     514        ENTRY(VFW_E_DVD_STATE_WRONG_VERSION);
     515        ENTRY(VFW_E_DVD_STATE_CORRUPT);
     516        ENTRY(VFW_E_DVD_STATE_WRONG_DISC);
     517        ENTRY(VFW_E_DVD_INCOMPATIBLE_REGION);
     518        ENTRY(VFW_E_DVD_NO_ATTRIBUTES);
     519        ENTRY(VFW_E_DVD_NO_GOUP_PGC);
     520        ENTRY(VFW_E_DVD_LOW_PARENTAL_LEVEL);
     521        ENTRY(VFW_E_DVD_NOT_IN_KARAOKE_MODE);
     522        ENTRY(VFW_S_DVD_CHANNEL_CONTENTS_NOT_AVAILABLE);
     523        ENTRY(VFW_S_DVD_NOT_ACCURATE);
     524        ENTRY(VFW_E_FRAME_STEP_UNSUPPORTED);
     525        ENTRY(VFW_E_DVD_STREAM_DISABLED);
     526        ENTRY(VFW_E_DVD_TITLE_UNKNOWN);
     527        ENTRY(VFW_E_DVD_INVALID_DISC);
     528        ENTRY(VFW_E_DVD_NO_RESUME_INFORMATION);
     529        ENTRY(VFW_E_PIN_ALREADY_BLOCKED_ON_THIS_THREAD);
     530        ENTRY(VFW_E_PIN_ALREADY_BLOCKED);
     531        ENTRY(VFW_E_CERTIFICATION_FAILURE);
     532        #undef  ENTRY
     533        }
     534
     535        return NULL;
     536}
     537
     538/***********************************************************************
     539 *      AMGetErrorTextA (quartz.@)
     540 */
     541DWORD WINAPI AMGetErrorTextA(HRESULT hr, LPSTR pszbuf, DWORD dwBufLen)
     542{
     543        LPCSTR  lpszRes;
     544        DWORD len;
     545
     546        lpszRes = hresult_to_string( hr );
     547        if ( lpszRes == NULL )
     548                return 0;
     549        len = (DWORD)(strlen(lpszRes)+1);
     550        if ( len > dwBufLen )
     551                return 0;
     552
     553        memcpy( pszbuf, lpszRes, len );
     554        return len;
     555}
     556
     557/***********************************************************************
     558 *      AMGetErrorTextW (quartz.@)
     559 */
     560DWORD WINAPI AMGetErrorTextW(HRESULT hr, LPWSTR pwszbuf, DWORD dwBufLen)
     561{
     562        CHAR    szBuf[MAX_ERROR_TEXT_LEN+1];
     563        DWORD   dwLen;
     564
     565        dwLen = AMGetErrorTextA(hr,szBuf,MAX_ERROR_TEXT_LEN);
     566        if ( dwLen == 0 )
     567                return 0;
     568        szBuf[dwLen] = 0;
     569
     570        QUARTZ_strncpyAtoW( pwszbuf, szBuf, dwBufLen );
     571
     572        return lstrlenW( pwszbuf );
     573}
  • trunk/src/quartz/makefile

    r6918 r6952  
    1 # $Id: makefile,v 1.4 2001-10-01 01:41:21 bird Exp $
     1# $Id: makefile,v 1.5 2001-10-06 08:54:26 sandervl Exp $
    22
    33#
     
    2828#
    2929OBJS = \
    30 $(OBJDIR)\amerror.obj \
    3130$(OBJDIR)\amundoc.obj \
     31$(OBJDIR)\audren.obj \
     32$(OBJDIR)\basefilt.obj \
     33$(OBJDIR)\basepin.obj \
    3234$(OBJDIR)\complist.obj \
    33 $(OBJDIR)\fgclsid.obj \
     35$(OBJDIR)\devenum.obj \
     36$(OBJDIR)\devmon.obj \
     37$(OBJDIR)\enumunk.obj \
     38$(OBJDIR)\fgevent.obj \
    3439$(OBJDIR)\fgidisp.obj \
     40$(OBJDIR)\fgpass.obj \
    3541$(OBJDIR)\fgraph.obj \
    3642$(OBJDIR)\fmap.obj \
    3743$(OBJDIR)\fmap2.obj \
    38 $(OBJDIR)\ibasaud.obj \
    39 $(OBJDIR)\ibasvid.obj \
    4044$(OBJDIR)\ifgraph.obj \
    41 $(OBJDIR)\ifmap.obj \
    42 $(OBJDIR)\ifmap3.obj \
     45$(OBJDIR)\igconfig.obj \
    4346$(OBJDIR)\igrver.obj \
    4447$(OBJDIR)\imcntl.obj \
    45 $(OBJDIR)\imem.obj \
    46 $(OBJDIR)\imesink.obj \
    47 $(OBJDIR)\imevent.obj \
    4848$(OBJDIR)\imfilter.obj \
    4949$(OBJDIR)\impos.obj \
    5050$(OBJDIR)\imseek.obj \
    51 $(OBJDIR)\irclock.obj \
    5251$(OBJDIR)\iunk.obj \
    53 $(OBJDIR)\ividwin.obj \
    5452$(OBJDIR)\main.obj \
    5553$(OBJDIR)\memalloc.obj \
    56 $(OBJDIR)\monprop.obj \
     54$(OBJDIR)\mtype.obj \
    5755$(OBJDIR)\regsvr.obj \
     56$(OBJDIR)\sample.obj \
    5857$(OBJDIR)\seekpass.obj \
    5958$(OBJDIR)\sysclock.obj \
    60 $(OBJDIR)\devenum.obj \
    61 $(OBJDIR)\devmon.obj \
    62 $(OBJDIR)\enumunk.obj \
    63 $(OBJDIR)\idevenum.obj \
    6459$(OBJDIR)\initterm.obj \
    6560$(OBJDIR)\initquartz.obj \
     
    7469$(ODIN32_LIB)/kernel32.lib \
    7570$(ODIN32_LIB)/user32.lib \
     71$(ODIN32_LIB)/winmm.lib \
     72$(ODIN32_LIB)/ntdll.lib \
    7673$(ODIN32_LIB)/ole32.lib \
    7774$(ODIN32_LIB)/oleaut32.lib \
  • trunk/src/quartz/memalloc.c

    r6710 r6952  
    22 * Implementation of CLSID_MemoryAllocator.
    33 *
    4  * FIXME - stub.
    5  *
    64 * hidenori@a2.ctktv.ne.jp
    75 */
     
    1210#include "winbase.h"
    1311#include "wingdi.h"
     12#include "winuser.h"
    1413#include "winerror.h"
    1514#include "wine/obj_base.h"
     
    2423
    2524
     25/***************************************************************************
     26 *
     27 *      new/delete for CLSID_MemoryAllocator.
     28 *
     29 */
     30
    2631/* can I use offsetof safely? - FIXME? */
    2732static QUARTZ_IFEntry IFEntries[] =
     
    6469        return S_OK;
    6570}
     71
     72
     73/***************************************************************************
     74 *
     75 *      CMemoryAllocator::IMemAllocator
     76 *
     77 */
     78
     79
     80static HRESULT WINAPI
     81IMemAllocator_fnQueryInterface(IMemAllocator* iface,REFIID riid,void** ppobj)
     82{
     83        CMemoryAllocator_THIS(iface,memalloc);
     84
     85        TRACE("(%p)->()\n",This);
     86
     87        return IUnknown_QueryInterface(This->unk.punkControl,riid,ppobj);
     88}
     89
     90static ULONG WINAPI
     91IMemAllocator_fnAddRef(IMemAllocator* iface)
     92{
     93        CMemoryAllocator_THIS(iface,memalloc);
     94
     95        TRACE("(%p)->()\n",This);
     96
     97        return IUnknown_AddRef(This->unk.punkControl);
     98}
     99
     100static ULONG WINAPI
     101IMemAllocator_fnRelease(IMemAllocator* iface)
     102{
     103        CMemoryAllocator_THIS(iface,memalloc);
     104
     105        TRACE("(%p)->()\n",This);
     106
     107        return IUnknown_Release(This->unk.punkControl);
     108}
     109
     110static HRESULT WINAPI
     111IMemAllocator_fnSetProperties(IMemAllocator* iface,ALLOCATOR_PROPERTIES* pPropReq,ALLOCATOR_PROPERTIES* pPropActual)
     112{
     113        CMemoryAllocator_THIS(iface,memalloc);
     114        long    padding;
     115        HRESULT hr;
     116
     117        TRACE( "(%p)->(%p,%p)\n", This, pPropReq, pPropActual );
     118
     119        if ( pPropReq == NULL || pPropActual == NULL )
     120                return E_POINTER;
     121        if ( pPropReq->cBuffers < 0 ||
     122             pPropReq->cbBuffer < 0 ||
     123             pPropReq->cbAlign < 0 ||
     124             pPropReq->cbPrefix < 0 )
     125                return E_INVALIDARG;
     126
     127        if ( ( pPropReq->cbAlign & (pPropReq->cbAlign-1) ) != 0 )
     128                return E_INVALIDARG;
     129
     130        hr = NOERROR;
     131
     132        EnterCriticalSection( &This->csMem );
     133
     134        if ( This->pData != NULL || This->ppSamples != NULL )
     135        {
     136                /* if commited, properties must not be changed. */
     137                hr = E_UNEXPECTED;
     138                goto end;
     139        }
     140
     141        This->prop.cBuffers = pPropReq->cBuffers;
     142        This->prop.cbBuffer = pPropReq->cbBuffer;
     143        This->prop.cbAlign = pPropReq->cbAlign;
     144        This->prop.cbPrefix = pPropReq->cbPrefix;
     145
     146        if ( This->prop.cbAlign == 0 )
     147                This->prop.cbAlign = 1;
     148        padding = This->prop.cbAlign -
     149                ( (This->prop.cbBuffer+This->prop.cbPrefix) % This->prop.cbAlign );
     150
     151        This->prop.cbBuffer += padding;
     152
     153        memcpy( pPropActual, &This->prop, sizeof(ALLOCATOR_PROPERTIES) );
     154
     155end:
     156        LeaveCriticalSection( &This->csMem );
     157
     158        return hr;
     159}
     160
     161static HRESULT WINAPI
     162IMemAllocator_fnGetProperties(IMemAllocator* iface,ALLOCATOR_PROPERTIES* pProp)
     163{
     164        CMemoryAllocator_THIS(iface,memalloc);
     165
     166        TRACE( "(%p)->(%p)\n", This, pProp );
     167
     168        if ( pProp == NULL )
     169                return E_POINTER;
     170
     171        EnterCriticalSection( &This->csMem );
     172
     173        memcpy( pProp, &This->prop, sizeof(ALLOCATOR_PROPERTIES) );
     174
     175        LeaveCriticalSection( &This->csMem );
     176
     177        return NOERROR;
     178}
     179
     180static HRESULT WINAPI
     181IMemAllocator_fnCommit(IMemAllocator* iface)
     182{
     183        CMemoryAllocator_THIS(iface,memalloc);
     184        HRESULT hr;
     185        LONG    lBufSize;
     186        LONG    i;
     187        BYTE*   pCur;
     188
     189        TRACE( "(%p)->()\n", This );
     190
     191        EnterCriticalSection( &This->csMem );
     192
     193        hr = NOERROR;
     194        if ( This->pData != NULL || This->ppSamples != NULL ||
     195             This->prop.cBuffers <= 0 )
     196                goto end;
     197
     198        lBufSize = This->prop.cBuffers *
     199                (This->prop.cbBuffer + This->prop.cbPrefix) +
     200                This->prop.cbAlign;
     201        if ( lBufSize <= 0 )
     202                lBufSize = 1;
     203
     204        This->pData = (BYTE*)QUARTZ_AllocMem( lBufSize );
     205        if ( This->pData == NULL )
     206        {
     207                hr = E_OUTOFMEMORY;
     208                goto end;
     209        }
     210
     211        This->ppSamples = (CMemMediaSample**)QUARTZ_AllocMem(
     212                sizeof(CMemMediaSample*) * This->prop.cBuffers );
     213        if ( This->ppSamples == NULL )
     214        {
     215                hr = E_OUTOFMEMORY;
     216                goto end;
     217        }
     218
     219        for ( i = 0; i < This->prop.cBuffers; i++ )
     220                This->ppSamples[i] = NULL;
     221
     222        pCur = This->pData + This->prop.cbAlign - ((This->pData-(BYTE*)NULL) & (This->prop.cbAlign-1));
     223
     224        for ( i = 0; i < This->prop.cBuffers; i++ )
     225        {
     226                hr = QUARTZ_CreateMemMediaSample(
     227                        pCur, (This->prop.cbBuffer + This->prop.cbPrefix),
     228                        iface, &This->ppSamples[i] );
     229                if ( FAILED(hr) )
     230                        goto end;
     231                pCur += (This->prop.cbBuffer + This->prop.cbPrefix);
     232        }
     233
     234        hr = NOERROR;
     235end:
     236        if ( FAILED(hr) )
     237                IMemAllocator_Decommit(iface);
     238
     239        LeaveCriticalSection( &This->csMem );
     240
     241        return hr;
     242}
     243
     244static HRESULT WINAPI
     245IMemAllocator_fnDecommit(IMemAllocator* iface)
     246{
     247        CMemoryAllocator_THIS(iface,memalloc);
     248        HRESULT hr;
     249        LONG    i;
     250        BOOL    bBlock;
     251
     252        TRACE( "(%p)->()\n", This );
     253
     254        EnterCriticalSection( &This->csMem );
     255
     256        hr = NOERROR;
     257
     258        if ( This->pData == NULL && This->ppSamples == NULL )
     259                goto end;
     260
     261        while ( 1 )
     262        {
     263                bBlock = FALSE;
     264                i = 0;
     265
     266                ResetEvent( This->hEventSample );
     267
     268                while ( 1 )
     269                {
     270                        if ( i >= This->prop.cBuffers )
     271                                break;
     272
     273                        if ( This->ppSamples[i] != NULL )
     274                        {
     275                                if ( This->ppSamples[i]->ref == 0 )
     276                                {
     277                                        QUARTZ_DestroyMemMediaSample( This->ppSamples[i] );
     278                                        This->ppSamples[i] = NULL;
     279                                }
     280                                else
     281                                {
     282                                        bBlock = TRUE;
     283                                }
     284                        }
     285                        i++;
     286                }
     287
     288                if ( !bBlock )
     289                {
     290                        QUARTZ_FreeMem(This->ppSamples);
     291                        This->ppSamples = NULL;
     292                        QUARTZ_FreeMem(This->pData);
     293                        This->pData = NULL;
     294                        hr = NOERROR;
     295                        break;
     296                }
     297
     298                WaitForSingleObject( This->hEventSample, INFINITE );
     299        }
     300
     301end:
     302        LeaveCriticalSection( &This->csMem );
     303
     304        return hr;
     305}
     306
     307static HRESULT WINAPI
     308IMemAllocator_fnGetBuffer(IMemAllocator* iface,IMediaSample** ppSample,REFERENCE_TIME* prtStart,REFERENCE_TIME* prtEnd,DWORD dwFlags)
     309{
     310        CMemoryAllocator_THIS(iface,memalloc);
     311        LONG    i;
     312        HRESULT hr;
     313
     314        TRACE( "(%p)->(%p,%p,%p,%lu)\n", This, ppSample, prtStart, prtEnd, dwFlags );
     315
     316        if ( ppSample == NULL )
     317                return E_POINTER;
     318
     319        EnterCriticalSection( &This->csMem );
     320
     321        hr = NOERROR;
     322
     323        if ( This->pData == NULL || This->ppSamples == NULL ||
     324             This->prop.cBuffers <= 0 )
     325        {
     326                hr = E_FAIL; /* FIXME? */
     327                goto end;
     328        }
     329
     330        while ( 1 )
     331        {
     332                ResetEvent( This->hEventSample );
     333
     334                for ( i = 0; i < This->prop.cBuffers; i++ )
     335                {
     336                        if ( This->ppSamples[i]->ref == 0 )
     337                        {
     338                                *ppSample = (IMediaSample*)(This->ppSamples[i]);
     339                                IMediaSample_AddRef( *ppSample );
     340                                hr = NOERROR;
     341                                goto end;
     342                        }
     343                }
     344
     345                if ( dwFlags & AM_GBF_NOWAIT )
     346                {
     347                        hr = E_FAIL; /* FIXME? */
     348                        goto end;
     349                }
     350
     351                WaitForSingleObject( This->hEventSample, INFINITE );
     352        }
     353
     354end:
     355        LeaveCriticalSection( &This->csMem );
     356
     357        return hr;
     358}
     359
     360static HRESULT WINAPI
     361IMemAllocator_fnReleaseBuffer(IMemAllocator* iface,IMediaSample* pSample)
     362{
     363        CMemoryAllocator_THIS(iface,memalloc);
     364
     365        TRACE( "(%p)->(%p)\n", This, pSample );
     366        SetEvent( This->hEventSample );
     367
     368        return NOERROR;
     369}
     370
     371
     372
     373static ICOM_VTABLE(IMemAllocator) imemalloc =
     374{
     375        ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
     376        /* IUnknown fields */
     377        IMemAllocator_fnQueryInterface,
     378        IMemAllocator_fnAddRef,
     379        IMemAllocator_fnRelease,
     380        /* IMemAllocator fields */
     381        IMemAllocator_fnSetProperties,
     382        IMemAllocator_fnGetProperties,
     383        IMemAllocator_fnCommit,
     384        IMemAllocator_fnDecommit,
     385        IMemAllocator_fnGetBuffer,
     386        IMemAllocator_fnReleaseBuffer,
     387};
     388
     389
     390HRESULT CMemoryAllocator_InitIMemAllocator( CMemoryAllocator* pma )
     391{
     392        TRACE("(%p)\n",pma);
     393
     394        ICOM_VTBL(&pma->memalloc) = &imemalloc;
     395
     396        ZeroMemory( &pma->prop, sizeof(pma->prop) );
     397        pma->hEventSample = (HANDLE)NULL;
     398        pma->pData = NULL;
     399        pma->ppSamples = NULL;
     400
     401        pma->hEventSample = CreateEventA( NULL, TRUE, FALSE, NULL );
     402        if ( pma->hEventSample == (HANDLE)NULL )
     403                return E_OUTOFMEMORY;
     404
     405        InitializeCriticalSection( &pma->csMem );
     406
     407        return NOERROR;
     408}
     409
     410void CMemoryAllocator_UninitIMemAllocator( CMemoryAllocator* pma )
     411{
     412        TRACE("(%p)\n",pma);
     413
     414        IMemAllocator_Decommit( (IMemAllocator*)(&pma->memalloc) );
     415
     416        DeleteCriticalSection( &pma->csMem );
     417
     418        if ( pma->hEventSample != (HANDLE)NULL )
     419                CloseHandle( pma->hEventSample );
     420}
  • trunk/src/quartz/memalloc.h

    r6710 r6952  
    1313
    1414#include "iunk.h"
     15#include "sample.h"
    1516
    1617typedef struct MA_IMemAllocatorImpl
     
    2728        CRITICAL_SECTION        csMem;
    2829        ALLOCATOR_PROPERTIES    prop;
     30        HANDLE  hEventSample;
     31        BYTE*   pData;
     32        CMemMediaSample**       ppSamples;
    2933} CMemoryAllocator;
    3034
  • trunk/src/quartz/quartz_private.h

    r6563 r6952  
    88void* QUARTZ_AllocMem( DWORD dwSize );
    99void QUARTZ_FreeMem( void* pMem );
     10void* QUARTZ_ReallocMem( void* pMem, DWORD dwSize );
    1011
    1112#endif  /* QUARTZ_PRIVATE_H */
  • trunk/src/quartz/regsvr.c

    r6710 r6952  
    1313#include "winerror.h"
    1414#include "winreg.h"
    15 #ifdef __WIN32OS2__
    16 #include "wine/obj_base.h"
    17 #endif
    1815#include "uuids.h"
    1916#include "wine/unicode.h"
  • trunk/src/quartz/seekpass.c

    r6710 r6952  
    11/*
    2  * Implementation of CLSID_SeekingPassThru.
     2 *      Implementation of CLSID_SeekingPassThru
     3 *
     4 *      FIXME - not tested yet.
    35 *
    46 * hidenori@a2.ctktv.ne.jp
     
    1012#include "winbase.h"
    1113#include "wingdi.h"
     14#include "winuser.h"
    1215#include "winerror.h"
    1316#include "wine/obj_base.h"
    1417#include "strmif.h"
     18#include "control.h"
    1519#include "uuids.h"
    1620
     
    2226
    2327
     28/***************************************************************************
     29 *
     30 *      CSeekingPassThru::ISeekingPassThru
     31 *
     32 */
    2433
    2534static HRESULT WINAPI
     
    5867        CSeekingPassThru_THIS(iface,seekpass);
    5968
    60         FIXME("(%p)->(%d,%p) stub!\n",This,bRendering,pPin);
    61 
    62         return E_NOTIMPL;
     69        FIXME("(%p)->(%d,%p) not tested!\n",This,bRendering,pPin);
     70
     71        if ( pPin == NULL )
     72                return E_POINTER;
     73
     74        /* Why is 'bRendering' given as an argument?? */
     75        EnterCriticalSection( &This->cs );
     76
     77        if ( This->passthru.pPin != NULL )
     78                IPin_Release( This->passthru.pPin );
     79        This->passthru.pPin = pPin; IPin_AddRef( pPin );
     80
     81        LeaveCriticalSection( &This->cs );
     82
     83        return NOERROR;
    6384}
    6485
     
    80101        TRACE("(%p)\n",This);
    81102        ICOM_VTBL(&This->seekpass) = &iseekingpassthru;
     103        This->passthru.punk = This->unk.punkControl;
     104        This->passthru.pPin = NULL;
     105        InitializeCriticalSection( &This->cs );
    82106
    83107        return NOERROR;
     
    88112{
    89113        TRACE("(%p)\n",This);
    90 }
    91 
     114        if ( This->passthru.pPin != NULL )
     115        {
     116                IPin_Release( This->passthru.pPin );
     117                This->passthru.pPin = NULL;
     118        }
     119        DeleteCriticalSection( &This->cs );
     120}
     121
     122/***************************************************************************
     123 *
     124 *      new/delete for CLSID_SeekingPassThru.
     125 *
     126 */
    92127
    93128/* can I use offsetof safely? - FIXME? */
     
    95130{
    96131  { &IID_ISeekingPassThru, offsetof(CSeekingPassThru,seekpass)-offsetof(CSeekingPassThru,unk) },
     132  { &IID_IMediaPosition, offsetof(CSeekingPassThru,passthru.mpos)-offsetof(CSeekingPassThru,unk) },
     133  { &IID_IMediaSeeking, offsetof(CSeekingPassThru,passthru.mseek)-offsetof(CSeekingPassThru,unk) },
    97134};
    98135
     
    133170}
    134171
     172
     173
     174
     175/***************************************************************************
     176 *
     177 *      CPassThruImpl Helper methods.
     178 *
     179 */
     180
     181static
     182HRESULT CPassThruImpl_GetConnected( CPassThruImpl* pImpl, IPin** ppPin )
     183{
     184        return IPin_ConnectedTo( pImpl->pPin, ppPin );
     185}
     186
     187HRESULT CPassThruImpl_QueryPosPass(
     188        CPassThruImpl* pImpl, IMediaPosition** ppPosition )
     189{
     190        IPin*   pPin;
     191        HRESULT hr;
     192
     193        hr = CPassThruImpl_GetConnected( pImpl, &pPin );
     194        if ( FAILED(hr) )
     195                return hr;
     196        hr = IPin_QueryInterface(pPin,&IID_IMediaPosition,(void**)ppPosition);
     197        IPin_Release(pPin);
     198
     199        return hr;
     200}
     201
     202HRESULT CPassThruImpl_QuerySeekPass(
     203        CPassThruImpl* pImpl, IMediaSeeking** ppSeeking )
     204{
     205        IPin*   pPin;
     206        HRESULT hr;
     207
     208        hr = CPassThruImpl_GetConnected( pImpl, &pPin );
     209        if ( FAILED(hr) )
     210                return hr;
     211        hr = IPin_QueryInterface(pPin,&IID_IMediaSeeking,(void**)ppSeeking);
     212        IPin_Release(pPin);
     213
     214        return hr;
     215}
     216
     217/***************************************************************************
     218 *
     219 *      An implementation for CPassThruImpl::IMediaPosition.
     220 *
     221 */
     222
     223
     224#define QUERYPOSPASS \
     225        IMediaPosition* pPos = NULL; \
     226        HRESULT hr; \
     227        hr = CPassThruImpl_QueryPosPass( This, &pPos ); \
     228        if ( FAILED(hr) ) return hr;
     229
     230static HRESULT WINAPI
     231IMediaPosition_fnQueryInterface(IMediaPosition* iface,REFIID riid,void** ppobj)
     232{
     233        CPassThruImpl_THIS(iface,mpos);
     234
     235        TRACE("(%p)->()\n",This);
     236
     237        return IUnknown_QueryInterface(This->punk,riid,ppobj);
     238}
     239
     240static ULONG WINAPI
     241IMediaPosition_fnAddRef(IMediaPosition* iface)
     242{
     243        CPassThruImpl_THIS(iface,mpos);
     244
     245        TRACE("(%p)->()\n",This);
     246
     247        return IUnknown_AddRef(This->punk);
     248}
     249
     250static ULONG WINAPI
     251IMediaPosition_fnRelease(IMediaPosition* iface)
     252{
     253        CPassThruImpl_THIS(iface,mpos);
     254
     255        TRACE("(%p)->()\n",This);
     256
     257        return IUnknown_Release(This->punk);
     258}
     259
     260static HRESULT WINAPI
     261IMediaPosition_fnGetTypeInfoCount(IMediaPosition* iface,UINT* pcTypeInfo)
     262{
     263        CPassThruImpl_THIS(iface,mpos);
     264
     265        FIXME("(%p)->() stub!\n",This);
     266
     267        return E_NOTIMPL;
     268}
     269
     270static HRESULT WINAPI
     271IMediaPosition_fnGetTypeInfo(IMediaPosition* iface,UINT iTypeInfo, LCID lcid, ITypeInfo** ppobj)
     272{
     273        CPassThruImpl_THIS(iface,mpos);
     274
     275        FIXME("(%p)->() stub!\n",This);
     276
     277        return E_NOTIMPL;
     278}
     279
     280static HRESULT WINAPI
     281IMediaPosition_fnGetIDsOfNames(IMediaPosition* iface,REFIID riid, LPOLESTR* ppwszName, UINT cNames, LCID lcid, DISPID* pDispId)
     282{
     283        CPassThruImpl_THIS(iface,mpos);
     284
     285        FIXME("(%p)->() stub!\n",This);
     286
     287        return E_NOTIMPL;
     288}
     289
     290static HRESULT WINAPI
     291IMediaPosition_fnInvoke(IMediaPosition* iface,DISPID DispId, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarRes, EXCEPINFO* pExcepInfo, UINT* puArgErr)
     292{
     293        CPassThruImpl_THIS(iface,mpos);
     294
     295        FIXME("(%p)->() stub!\n",This);
     296
     297        return E_NOTIMPL;
     298}
     299
     300
     301static HRESULT WINAPI
     302IMediaPosition_fnget_Duration(IMediaPosition* iface,REFTIME* prefTime)
     303{
     304        CPassThruImpl_THIS(iface,mpos);
     305        QUERYPOSPASS
     306
     307        TRACE("(%p)->()\n",This);
     308
     309        return IMediaPosition_get_Duration(pPos,prefTime);
     310}
     311
     312static HRESULT WINAPI
     313IMediaPosition_fnput_CurrentPosition(IMediaPosition* iface,REFTIME refTime)
     314{
     315        CPassThruImpl_THIS(iface,mpos);
     316        QUERYPOSPASS
     317
     318        TRACE("(%p)->()\n",This);
     319
     320        return IMediaPosition_put_CurrentPosition(pPos,refTime);
     321}
     322
     323static HRESULT WINAPI
     324IMediaPosition_fnget_CurrentPosition(IMediaPosition* iface,REFTIME* prefTime)
     325{
     326        CPassThruImpl_THIS(iface,mpos);
     327        QUERYPOSPASS
     328
     329        TRACE("(%p)->()\n",This);
     330
     331        return IMediaPosition_get_CurrentPosition(pPos,prefTime);
     332}
     333
     334static HRESULT WINAPI
     335IMediaPosition_fnget_StopTime(IMediaPosition* iface,REFTIME* prefTime)
     336{
     337        CPassThruImpl_THIS(iface,mpos);
     338        QUERYPOSPASS
     339
     340        TRACE("(%p)->()\n",This);
     341
     342        return IMediaPosition_get_StopTime(pPos,prefTime);
     343}
     344
     345static HRESULT WINAPI
     346IMediaPosition_fnput_StopTime(IMediaPosition* iface,REFTIME refTime)
     347{
     348        CPassThruImpl_THIS(iface,mpos);
     349        QUERYPOSPASS
     350
     351        TRACE("(%p)->()\n",This);
     352
     353        return IMediaPosition_put_StopTime(pPos,refTime);
     354}
     355
     356static HRESULT WINAPI
     357IMediaPosition_fnget_PrerollTime(IMediaPosition* iface,REFTIME* prefTime)
     358{
     359        CPassThruImpl_THIS(iface,mpos);
     360        QUERYPOSPASS
     361
     362        TRACE("(%p)->()\n",This);
     363
     364        return IMediaPosition_get_PrerollTime(pPos,prefTime);
     365}
     366
     367static HRESULT WINAPI
     368IMediaPosition_fnput_PrerollTime(IMediaPosition* iface,REFTIME refTime)
     369{
     370        CPassThruImpl_THIS(iface,mpos);
     371        QUERYPOSPASS
     372
     373        TRACE("(%p)->()\n",This);
     374
     375        return IMediaPosition_put_PrerollTime(pPos,refTime);
     376}
     377
     378static HRESULT WINAPI
     379IMediaPosition_fnput_Rate(IMediaPosition* iface,double dblRate)
     380{
     381        CPassThruImpl_THIS(iface,mpos);
     382        QUERYPOSPASS
     383
     384        TRACE("(%p)->()\n",This);
     385
     386        return IMediaPosition_put_Rate(pPos,dblRate);
     387}
     388
     389static HRESULT WINAPI
     390IMediaPosition_fnget_Rate(IMediaPosition* iface,double* pdblRate)
     391{
     392        CPassThruImpl_THIS(iface,mpos);
     393        QUERYPOSPASS
     394
     395        TRACE("(%p)->()\n",This);
     396
     397        return IMediaPosition_get_Rate(pPos,pdblRate);
     398}
     399
     400static HRESULT WINAPI
     401IMediaPosition_fnCanSeekForward(IMediaPosition* iface,LONG* pCanSeek)
     402{
     403        CPassThruImpl_THIS(iface,mpos);
     404        QUERYPOSPASS
     405
     406        TRACE("(%p)->()\n",This);
     407
     408        return IMediaPosition_CanSeekForward(pPos,pCanSeek);
     409}
     410
     411static HRESULT WINAPI
     412IMediaPosition_fnCanSeekBackward(IMediaPosition* iface,LONG* pCanSeek)
     413{
     414        CPassThruImpl_THIS(iface,mpos);
     415        QUERYPOSPASS
     416
     417        TRACE("(%p)->()\n",This);
     418
     419        return IMediaPosition_CanSeekBackward(pPos,pCanSeek);
     420}
     421
     422
     423static ICOM_VTABLE(IMediaPosition) impos =
     424{
     425        ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
     426        /* IUnknown fields */
     427        IMediaPosition_fnQueryInterface,
     428        IMediaPosition_fnAddRef,
     429        IMediaPosition_fnRelease,
     430        /* IDispatch fields */
     431        IMediaPosition_fnGetTypeInfoCount,
     432        IMediaPosition_fnGetTypeInfo,
     433        IMediaPosition_fnGetIDsOfNames,
     434        IMediaPosition_fnInvoke,
     435        /* IMediaPosition fields */
     436        IMediaPosition_fnget_Duration,
     437        IMediaPosition_fnput_CurrentPosition,
     438        IMediaPosition_fnget_CurrentPosition,
     439        IMediaPosition_fnget_StopTime,
     440        IMediaPosition_fnput_StopTime,
     441        IMediaPosition_fnget_PrerollTime,
     442        IMediaPosition_fnput_PrerollTime,
     443        IMediaPosition_fnput_Rate,
     444        IMediaPosition_fnget_Rate,
     445        IMediaPosition_fnCanSeekForward,
     446        IMediaPosition_fnCanSeekBackward,
     447};
     448
     449
     450HRESULT CPassThruImpl_InitIMediaPosition( CPassThruImpl* pImpl )
     451{
     452        TRACE("(%p)\n",pImpl);
     453        ICOM_VTBL(&pImpl->mpos) = &impos;
     454
     455        return NOERROR;
     456}
     457
     458void CPassThruImpl_UninitIMediaPosition( CPassThruImpl* pImpl )
     459{
     460        TRACE("(%p)\n",pImpl);
     461}
     462
     463#undef QUERYPOSPASS
     464
     465
     466/***************************************************************************
     467 *
     468 *      An implementation for CPassThruImpl::IMediaSeeking.
     469 *
     470 */
     471
     472#define QUERYSEEKPASS \
     473        IMediaSeeking* pSeek = NULL; \
     474        HRESULT hr; \
     475        hr = CPassThruImpl_QuerySeekPass( This, &pSeek ); \
     476        if ( FAILED(hr) ) return hr;
     477
     478
     479static HRESULT WINAPI
     480IMediaSeeking_fnQueryInterface(IMediaSeeking* iface,REFIID riid,void** ppobj)
     481{
     482        CPassThruImpl_THIS(iface,mseek);
     483
     484        TRACE("(%p)->()\n",This);
     485
     486        return IUnknown_QueryInterface(This->punk,riid,ppobj);
     487}
     488
     489static ULONG WINAPI
     490IMediaSeeking_fnAddRef(IMediaSeeking* iface)
     491{
     492        CPassThruImpl_THIS(iface,mseek);
     493
     494        TRACE("(%p)->()\n",This);
     495
     496        return IUnknown_AddRef(This->punk);
     497}
     498
     499static ULONG WINAPI
     500IMediaSeeking_fnRelease(IMediaSeeking* iface)
     501{
     502        CPassThruImpl_THIS(iface,mseek);
     503
     504        TRACE("(%p)->()\n",This);
     505
     506        return IUnknown_Release(This->punk);
     507}
     508
     509
     510static HRESULT WINAPI
     511IMediaSeeking_fnGetCapabilities(IMediaSeeking* iface,DWORD* pdwCaps)
     512{
     513        CPassThruImpl_THIS(iface,mseek);
     514        QUERYSEEKPASS
     515
     516        TRACE("(%p)->()\n",This);
     517
     518        return IMediaSeeking_GetCapabilities(pSeek,pdwCaps);
     519}
     520
     521static HRESULT WINAPI
     522IMediaSeeking_fnCheckCapabilities(IMediaSeeking* iface,DWORD* pdwCaps)
     523{
     524        CPassThruImpl_THIS(iface,mseek);
     525        QUERYSEEKPASS
     526
     527        TRACE("(%p)->()\n",This);
     528
     529        return IMediaSeeking_CheckCapabilities(pSeek,pdwCaps);
     530}
     531
     532static HRESULT WINAPI
     533IMediaSeeking_fnIsFormatSupported(IMediaSeeking* iface,const GUID* pidFormat)
     534{
     535        CPassThruImpl_THIS(iface,mseek);
     536        QUERYSEEKPASS
     537
     538        TRACE("(%p)->()\n",This);
     539
     540        return IMediaSeeking_IsFormatSupported(pSeek,pidFormat);
     541}
     542
     543static HRESULT WINAPI
     544IMediaSeeking_fnQueryPreferredFormat(IMediaSeeking* iface,GUID* pidFormat)
     545{
     546        CPassThruImpl_THIS(iface,mseek);
     547        QUERYSEEKPASS
     548
     549        TRACE("(%p)->()\n",This);
     550
     551        return IMediaSeeking_QueryPreferredFormat(pSeek,pidFormat);
     552}
     553
     554static HRESULT WINAPI
     555IMediaSeeking_fnGetTimeFormat(IMediaSeeking* iface,GUID* pidFormat)
     556{
     557        CPassThruImpl_THIS(iface,mseek);
     558        QUERYSEEKPASS
     559
     560        TRACE("(%p)->()\n",This);
     561
     562        return IMediaSeeking_GetTimeFormat(pSeek,pidFormat);
     563}
     564
     565static HRESULT WINAPI
     566IMediaSeeking_fnIsUsingTimeFormat(IMediaSeeking* iface,const GUID* pidFormat)
     567{
     568        CPassThruImpl_THIS(iface,mseek);
     569        QUERYSEEKPASS
     570
     571        TRACE("(%p)->()\n",This);
     572
     573        return IMediaSeeking_IsUsingTimeFormat(pSeek,pidFormat);
     574}
     575
     576static HRESULT WINAPI
     577IMediaSeeking_fnSetTimeFormat(IMediaSeeking* iface,const GUID* pidFormat)
     578{
     579        CPassThruImpl_THIS(iface,mseek);
     580        QUERYSEEKPASS
     581
     582        TRACE("(%p)->()\n",This);
     583
     584        return IMediaSeeking_SetTimeFormat(pSeek,pidFormat);
     585}
     586
     587static HRESULT WINAPI
     588IMediaSeeking_fnGetDuration(IMediaSeeking* iface,LONGLONG* pllDuration)
     589{
     590        CPassThruImpl_THIS(iface,mseek);
     591        QUERYSEEKPASS
     592
     593        TRACE("(%p)->()\n",This);
     594
     595        return IMediaSeeking_GetDuration(pSeek,pllDuration);
     596}
     597
     598static HRESULT WINAPI
     599IMediaSeeking_fnGetStopPosition(IMediaSeeking* iface,LONGLONG* pllPos)
     600{
     601        CPassThruImpl_THIS(iface,mseek);
     602        QUERYSEEKPASS
     603
     604        TRACE("(%p)->()\n",This);
     605
     606        return IMediaSeeking_GetStopPosition(pSeek,pllPos);
     607}
     608
     609static HRESULT WINAPI
     610IMediaSeeking_fnGetCurrentPosition(IMediaSeeking* iface,LONGLONG* pllPos)
     611{
     612        CPassThruImpl_THIS(iface,mseek);
     613        QUERYSEEKPASS
     614
     615        TRACE("(%p)->()\n",This);
     616
     617        return IMediaSeeking_GetCurrentPosition(pSeek,pllPos);
     618}
     619
     620static HRESULT WINAPI
     621IMediaSeeking_fnConvertTimeFormat(IMediaSeeking* iface,LONGLONG* pllOut,const GUID* pidFmtOut,LONGLONG llIn,const GUID* pidFmtIn)
     622{
     623        CPassThruImpl_THIS(iface,mseek);
     624        QUERYSEEKPASS
     625
     626        TRACE("(%p)->()\n",This);
     627
     628        return IMediaSeeking_ConvertTimeFormat(pSeek,pllOut,pidFmtOut,llIn,pidFmtIn);
     629}
     630
     631static HRESULT WINAPI
     632IMediaSeeking_fnSetPositions(IMediaSeeking* iface,LONGLONG* pllCur,DWORD dwCurFlags,LONGLONG* pllStop,DWORD dwStopFlags)
     633{
     634        CPassThruImpl_THIS(iface,mseek);
     635        QUERYSEEKPASS
     636
     637        TRACE("(%p)->()\n",This);
     638
     639        return IMediaSeeking_SetPositions(pSeek,pllCur,dwCurFlags,pllStop,dwStopFlags);
     640}
     641
     642static HRESULT WINAPI
     643IMediaSeeking_fnGetPositions(IMediaSeeking* iface,LONGLONG* pllCur,LONGLONG* pllStop)
     644{
     645        CPassThruImpl_THIS(iface,mseek);
     646        QUERYSEEKPASS
     647
     648        TRACE("(%p)->()\n",This);
     649
     650        return IMediaSeeking_GetPositions(pSeek,pllCur,pllStop);
     651}
     652
     653static HRESULT WINAPI
     654IMediaSeeking_fnGetAvailable(IMediaSeeking* iface,LONGLONG* pllFirst,LONGLONG* pllLast)
     655{
     656        CPassThruImpl_THIS(iface,mseek);
     657        QUERYSEEKPASS
     658
     659        TRACE("(%p)->()\n",This);
     660
     661        return IMediaSeeking_GetAvailable(pSeek,pllFirst,pllLast);
     662}
     663
     664static HRESULT WINAPI
     665IMediaSeeking_fnSetRate(IMediaSeeking* iface,double dblRate)
     666{
     667        CPassThruImpl_THIS(iface,mseek);
     668        QUERYSEEKPASS
     669
     670        TRACE("(%p)->()\n",This);
     671
     672        return IMediaSeeking_SetRate(pSeek,dblRate);
     673}
     674
     675static HRESULT WINAPI
     676IMediaSeeking_fnGetRate(IMediaSeeking* iface,double* pdblRate)
     677{
     678        CPassThruImpl_THIS(iface,mseek);
     679        QUERYSEEKPASS
     680
     681        TRACE("(%p)->()\n",This);
     682
     683        return IMediaSeeking_GetRate(pSeek,pdblRate);
     684}
     685
     686static HRESULT WINAPI
     687IMediaSeeking_fnGetPreroll(IMediaSeeking* iface,LONGLONG* pllPreroll)
     688{
     689        CPassThruImpl_THIS(iface,mseek);
     690        QUERYSEEKPASS
     691
     692        TRACE("(%p)->()\n",This);
     693
     694        return IMediaSeeking_GetPreroll(pSeek,pllPreroll);
     695}
     696
     697
     698
     699
     700static ICOM_VTABLE(IMediaSeeking) imseek =
     701{
     702        ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
     703        /* IUnknown fields */
     704        IMediaSeeking_fnQueryInterface,
     705        IMediaSeeking_fnAddRef,
     706        IMediaSeeking_fnRelease,
     707        /* IMediaSeeking fields */
     708        IMediaSeeking_fnGetCapabilities,
     709        IMediaSeeking_fnCheckCapabilities,
     710        IMediaSeeking_fnIsFormatSupported,
     711        IMediaSeeking_fnQueryPreferredFormat,
     712        IMediaSeeking_fnGetTimeFormat,
     713        IMediaSeeking_fnIsUsingTimeFormat,
     714        IMediaSeeking_fnSetTimeFormat,
     715        IMediaSeeking_fnGetDuration,
     716        IMediaSeeking_fnGetStopPosition,
     717        IMediaSeeking_fnGetCurrentPosition,
     718        IMediaSeeking_fnConvertTimeFormat,
     719        IMediaSeeking_fnSetPositions,
     720        IMediaSeeking_fnGetPositions,
     721        IMediaSeeking_fnGetAvailable,
     722        IMediaSeeking_fnSetRate,
     723        IMediaSeeking_fnGetRate,
     724        IMediaSeeking_fnGetPreroll,
     725};
     726
     727
     728
     729HRESULT CPassThruImpl_InitIMediaSeeking( CPassThruImpl* pImpl )
     730{
     731        TRACE("(%p)\n",pImpl);
     732        ICOM_VTBL(&pImpl->mseek) = &imseek;
     733
     734        return NOERROR;
     735}
     736
     737void CPassThruImpl_UninitIMediaSeeking( CPassThruImpl* pImpl )
     738{
     739        TRACE("(%p)\n",pImpl);
     740}
     741
     742#undef QUERYSEEKPASS
  • trunk/src/quartz/seekpass.h

    r6710 r6952  
    1414#include "iunk.h"
    1515
     16
     17/****************************************************************************/
     18
     19typedef struct CPassThruImpl
     20{
     21        struct { ICOM_VFIELD(IMediaPosition); } mpos;
     22        struct { ICOM_VFIELD(IMediaSeeking); } mseek;
     23
     24        IUnknown* punk;
     25        IPin* pPin;
     26} CPassThruImpl;
     27
     28#define CPassThruImpl_THIS(iface,member)                CPassThruImpl*  This = ((CPassThruImpl*)(((char*)iface)-offsetof(CPassThruImpl,member)))
     29
     30HRESULT CPassThruImpl_InitIMediaPosition( CPassThruImpl* pImpl );
     31void CPassThruImpl_UninitIMediaPosition( CPassThruImpl* pImpl );
     32HRESULT CPassThruImpl_InitIMediaSeeking( CPassThruImpl* pImpl );
     33void CPassThruImpl_UninitIMediaSeeking( CPassThruImpl* pImpl );
     34
     35HRESULT CPassThruImpl_QueryPosPass(
     36        CPassThruImpl* pImpl, IMediaPosition** ppPosition );
     37HRESULT CPassThruImpl_QuerySeekPass(
     38        CPassThruImpl* pImpl, IMediaSeeking** ppSeeking );
     39
     40/****************************************************************************/
     41
    1642typedef struct QUARTZ_ISeekingPassThruImpl
    1743{
    1844        ICOM_VFIELD(ISeekingPassThru);
    1945} QUARTZ_ISeekingPassThruImpl;
    20 
    2146
    2247typedef struct CSeekingPassThru
     
    2651
    2752        /* ISeekingPassThru fields. */
     53        CRITICAL_SECTION        cs;
     54        CPassThruImpl   passthru;
    2855} CSeekingPassThru;
    2956
  • trunk/src/quartz/sysclock.c

    r6710 r6952  
    22 * Implementation of CLSID_SystemClock.
    33 *
    4  * FIXME - stub.
    5  *
    64 * hidenori@a2.ctktv.ne.jp
    75 */
     
    1210#include "winbase.h"
    1311#include "wingdi.h"
     12#include "winuser.h"
    1413#include "winerror.h"
    1514#include "wine/obj_base.h"
     
    2423
    2524
     25/***************************************************************************
     26 *
     27 *      new/delete for CLSID_SystemClock
     28 *
     29 */
     30
    2631/* can I use offsetof safely? - FIXME? */
    2732static QUARTZ_IFEntry IFEntries[] =
     
    6570        return S_OK;
    6671}
     72
     73
     74/***************************************************************************
     75 *
     76 *      CLSID_SystemClock::IReferenceClock
     77 *
     78 */
     79
     80#define QUARTZ_MSG_ADDTIMER                     (WM_APP+0)
     81#define QUARTZ_MSG_REMOVETIMER          (WM_APP+1)
     82#define QUARTZ_MSG_EXITTHREAD           (WM_APP+2)
     83
     84
     85/****************************************************************************/
     86
     87static QUARTZ_TimerEntry* IReferenceClock_AllocTimerEntry(CSystemClock* This)
     88{
     89        QUARTZ_TimerEntry*      pEntry;
     90        DWORD   dw;
     91
     92        pEntry = &This->m_timerEntries[0];
     93        for ( dw = 0; dw < WINE_QUARTZ_SYSCLOCK_TIMER_MAX; dw++ )
     94        {
     95                if ( pEntry->hEvent == (HANDLE)NULL )
     96                        return pEntry;
     97                pEntry ++;
     98        }
     99
     100        return NULL;
     101}
     102
     103static QUARTZ_TimerEntry* IReferenceClock_SearchTimer(CSystemClock* This, DWORD dwAdvCookie)
     104{
     105        QUARTZ_TimerEntry*      pEntry;
     106        DWORD   dw;
     107
     108        pEntry = &This->m_timerEntries[0];
     109        for ( dw = 0; dw < WINE_QUARTZ_SYSCLOCK_TIMER_MAX; dw++ )
     110        {
     111                if ( pEntry->hEvent != (HANDLE)NULL &&
     112                         pEntry->dwAdvCookie == dwAdvCookie )
     113                        return pEntry;
     114                pEntry ++;
     115        }
     116
     117        return NULL;
     118}
     119
     120static DWORD IReferenceClock_OnTimerUpdated(CSystemClock* This)
     121{
     122        QUARTZ_TimerEntry*      pEntry;
     123        REFERENCE_TIME  rtCur;
     124        REFERENCE_TIME  rtSignal;
     125        REFERENCE_TIME  rtCount;
     126        HRESULT hr;
     127        LONG    lCount;
     128        DWORD   dw;
     129        DWORD   dwTimeout = INFINITE;
     130        DWORD   dwTimeoutCur;
     131
     132        hr = IReferenceClock_GetTime((IReferenceClock*)(&This->refclk),&rtCur);
     133        if ( hr != NOERROR )
     134                return INFINITE;
     135
     136        pEntry = &This->m_timerEntries[0];
     137        for ( dw = 0; dw < WINE_QUARTZ_SYSCLOCK_TIMER_MAX; dw++ )
     138        {
     139                if ( pEntry->hEvent != (HANDLE)NULL )
     140                {
     141                        rtSignal = pEntry->rtStart + pEntry->rtInterval;
     142                        if ( rtCur >= rtSignal )
     143                        {
     144                                if ( pEntry->fPeriodic )
     145                                {
     146                                        rtCount = ((rtCur - pEntry->rtStart) / pEntry->rtInterval);
     147                                        lCount = ( rtCount > (REFERENCE_TIME)0x7fffffff ) ?
     148                                                (LONG)0x7fffffff : (LONG)rtCount;
     149                                        if ( !ReleaseSemaphore( pEntry->hEvent, lCount, NULL ) )
     150                                        {
     151                                                while ( lCount > 0 )
     152                                                {
     153                                                        if ( !ReleaseSemaphore( pEntry->hEvent, 1, NULL ) )
     154                                                                break;
     155                                                }
     156                                        }
     157                                        dwTimeout = 0;
     158                                }
     159                                else
     160                                {
     161                                        TRACE( "signal an event\n" );
     162                                        SetEvent( pEntry->hEvent );
     163                                        pEntry->hEvent = (HANDLE)NULL;
     164                                }
     165                        }
     166                        else
     167                        {
     168                                rtCount = rtSignal - rtCur;
     169                                /* [100ns] -> [ms] */
     170                                rtCount = (rtCount+(REFERENCE_TIME)9999)/(REFERENCE_TIME)10000;
     171                                dwTimeoutCur = (rtCount >= 0xfffffffe) ? (DWORD)0xfffffffe : (DWORD)rtCount;
     172                                if ( dwTimeout > dwTimeoutCur )
     173                                        dwTimeout = dwTimeoutCur;
     174                        }
     175                }
     176                pEntry ++;
     177        }
     178
     179        return dwTimeout;
     180}
     181
     182static
     183DWORD WINAPI IReferenceClock_TimerEntry( LPVOID lpvParam )
     184{
     185        CSystemClock*   This = (CSystemClock*)lpvParam;
     186        MSG     msg;
     187        DWORD   dwRes;
     188        DWORD   dwTimeout;
     189
     190        /* initialize the message queue. */
     191        PeekMessageA( &msg, (HWND)NULL, 0, 0, PM_NOREMOVE );
     192        /* resume the owner thread. */
     193        SetEvent( This->m_hEventInit );
     194
     195        TRACE( "Enter message loop.\n" );
     196
     197        /* message loop. */
     198        dwTimeout = INFINITE;
     199        while ( 1 )
     200        {
     201                if ( dwTimeout > 0 )
     202                {
     203                        dwRes = MsgWaitForMultipleObjects(
     204                                0, NULL, FALSE,
     205                                dwTimeout,
     206                                QS_ALLEVENTS );
     207                }
     208
     209                EnterCriticalSection( &This->m_csClock );
     210                dwTimeout = IReferenceClock_OnTimerUpdated(This);
     211                LeaveCriticalSection( &This->m_csClock );
     212                TRACE( "catch an event / timeout %lu\n", dwTimeout );
     213
     214                while ( PeekMessageA( &msg, (HWND)NULL, 0, 0, PM_REMOVE ) )
     215                {
     216                        if ( msg.message == WM_QUIT )
     217                                goto quitthread;
     218
     219                        if ( msg.hwnd != (HWND)NULL )
     220                        {
     221                                TranslateMessage( &msg );
     222                                DispatchMessageA( &msg );
     223                        }
     224                        else
     225                        {
     226                                switch ( msg.message )
     227                                {
     228                                case QUARTZ_MSG_ADDTIMER:
     229                                case QUARTZ_MSG_REMOVETIMER:
     230                                        dwTimeout = 0;
     231                                        break;
     232                                case QUARTZ_MSG_EXITTHREAD:
     233                                        PostQuitMessage(0);
     234                                        break;
     235                                default:
     236                                        FIXME( "invalid message %04u\n", (unsigned)msg.message );
     237                                        break;
     238                                }
     239                        }
     240                }
     241        }
     242
     243quitthread:
     244        TRACE( "quit thread\n" );
     245        return 0;
     246}
     247
     248/****************************************************************************/
     249
     250static HRESULT WINAPI
     251IReferenceClock_fnQueryInterface(IReferenceClock* iface,REFIID riid,void** ppobj)
     252{
     253        CSystemClock_THIS(iface,refclk);
     254
     255        TRACE("(%p)->()\n",This);
     256
     257        return IUnknown_QueryInterface(This->unk.punkControl,riid,ppobj);
     258}
     259
     260static ULONG WINAPI
     261IReferenceClock_fnAddRef(IReferenceClock* iface)
     262{
     263        CSystemClock_THIS(iface,refclk);
     264
     265        TRACE("(%p)->()\n",This);
     266
     267        return IUnknown_AddRef(This->unk.punkControl);
     268}
     269
     270static ULONG WINAPI
     271IReferenceClock_fnRelease(IReferenceClock* iface)
     272{
     273        CSystemClock_THIS(iface,refclk);
     274
     275        TRACE("(%p)->()\n",This);
     276
     277        return IUnknown_Release(This->unk.punkControl);
     278}
     279
     280static HRESULT WINAPI
     281IReferenceClock_fnGetTime(IReferenceClock* iface,REFERENCE_TIME* prtTime)
     282{
     283        CSystemClock_THIS(iface,refclk);
     284        DWORD   dwTimeCur;
     285
     286        TRACE( "(%p)->(%p)\n", This, prtTime );
     287
     288        if ( prtTime == NULL )
     289                return E_POINTER;
     290
     291        EnterCriticalSection( &This->m_csClock );
     292
     293        dwTimeCur = GetTickCount();
     294        This->m_rtLast += (REFERENCE_TIME)(DWORD)(dwTimeCur - This->m_dwTimeLast) * (REFERENCE_TIME)10000;
     295
     296        This->m_dwTimeLast = dwTimeCur;
     297
     298        *prtTime = This->m_rtLast;
     299
     300        LeaveCriticalSection( &This->m_csClock );
     301
     302        return NOERROR;
     303}
     304
     305static HRESULT WINAPI
     306IReferenceClock_fnAdviseTime(IReferenceClock* iface,REFERENCE_TIME rtBase,REFERENCE_TIME rtStream,HEVENT hEvent,DWORD_PTR* pdwAdvCookie)
     307{
     308        CSystemClock_THIS(iface,refclk);
     309        QUARTZ_TimerEntry*      pEntry;
     310        HRESULT hr;
     311        REFERENCE_TIME  rtCur;
     312
     313        TRACE( "(%p)->()\n", This );
     314
     315        if ( pdwAdvCookie == NULL )
     316                return E_POINTER;
     317        if ( hEvent == (HANDLE)NULL )
     318                return E_INVALIDARG;
     319
     320        EnterCriticalSection( &This->m_csClock );
     321
     322        *pdwAdvCookie = (DWORD_PTR)(This->m_dwAdvCookieNext ++);
     323
     324        hr = IReferenceClock_GetTime(iface,&rtCur);
     325        if ( hr != NOERROR )
     326                goto err;
     327        if ( rtCur >= (rtBase+rtStream) )
     328        {
     329                SetEvent(hEvent);
     330                hr = NOERROR;
     331                goto err;
     332        }
     333
     334        pEntry = IReferenceClock_AllocTimerEntry(This);
     335        if ( pEntry == NULL )
     336        {
     337                hr = E_FAIL;
     338                goto err;
     339        }
     340
     341        pEntry->dwAdvCookie = *pdwAdvCookie;
     342        pEntry->fPeriodic = FALSE;
     343        pEntry->hEvent = hEvent;
     344        pEntry->rtStart = rtBase;
     345        pEntry->rtInterval = rtStream;
     346
     347        if ( !PostThreadMessageA(
     348                        This->m_idThreadTimer,
     349                        QUARTZ_MSG_ADDTIMER,
     350                        0, 0 ) )
     351        {
     352                pEntry->hEvent = (HANDLE)NULL;
     353                hr = E_FAIL;
     354                goto err;
     355        }
     356
     357        hr = NOERROR;
     358err:
     359        LeaveCriticalSection( &This->m_csClock );
     360
     361        return hr;
     362}
     363
     364static HRESULT WINAPI
     365IReferenceClock_fnAdvisePeriodic(IReferenceClock* iface,REFERENCE_TIME rtStart,REFERENCE_TIME rtPeriod,HSEMAPHORE hSemaphore,DWORD_PTR* pdwAdvCookie)
     366{
     367        CSystemClock_THIS(iface,refclk);
     368        QUARTZ_TimerEntry*      pEntry;
     369        HRESULT hr;
     370
     371        TRACE( "(%p)->()\n", This );
     372
     373        if ( pdwAdvCookie == NULL )
     374                return E_POINTER;
     375        if ( hSemaphore == (HSEMAPHORE)NULL )
     376                return E_INVALIDARG;
     377
     378        EnterCriticalSection( &This->m_csClock );
     379
     380        *pdwAdvCookie = (DWORD_PTR)(This->m_dwAdvCookieNext ++);
     381
     382        pEntry = IReferenceClock_AllocTimerEntry(This);
     383        if ( pEntry == NULL )
     384        {
     385                hr = E_FAIL;
     386                goto err;
     387        }
     388
     389        pEntry->dwAdvCookie = *pdwAdvCookie;
     390        pEntry->fPeriodic = TRUE;
     391        pEntry->hEvent = (HANDLE)hSemaphore;
     392        pEntry->rtStart = rtStart;
     393        pEntry->rtInterval = rtPeriod;
     394
     395        if ( !PostThreadMessageA(
     396                        This->m_idThreadTimer,
     397                        QUARTZ_MSG_ADDTIMER,
     398                        0, 0 ) )
     399        {
     400                pEntry->hEvent = (HANDLE)NULL;
     401                hr = E_FAIL;
     402                goto err;
     403        }
     404
     405        hr = NOERROR;
     406err:
     407        LeaveCriticalSection( &This->m_csClock );
     408
     409        return hr;
     410}
     411
     412static HRESULT WINAPI
     413IReferenceClock_fnUnadvise(IReferenceClock* iface,DWORD_PTR dwAdvCookie)
     414{
     415        CSystemClock_THIS(iface,refclk);
     416        QUARTZ_TimerEntry*      pEntry;
     417
     418        TRACE( "(%p)->(%lu)\n", This, (DWORD)dwAdvCookie );
     419
     420        EnterCriticalSection( &This->m_csClock );
     421
     422        pEntry = IReferenceClock_SearchTimer(This,(DWORD)dwAdvCookie);
     423        if ( pEntry != NULL )
     424        {
     425                pEntry->hEvent = (HANDLE)NULL;
     426        }
     427
     428        LeaveCriticalSection( &This->m_csClock );
     429
     430        return NOERROR;
     431}
     432
     433static ICOM_VTABLE(IReferenceClock) irefclk =
     434{
     435        ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
     436        /* IUnknown fields */
     437        IReferenceClock_fnQueryInterface,
     438        IReferenceClock_fnAddRef,
     439        IReferenceClock_fnRelease,
     440        /* IReferenceClock fields */
     441        IReferenceClock_fnGetTime,
     442        IReferenceClock_fnAdviseTime,
     443        IReferenceClock_fnAdvisePeriodic,
     444        IReferenceClock_fnUnadvise,
     445};
     446
     447
     448HRESULT CSystemClock_InitIReferenceClock( CSystemClock* psc )
     449{
     450        HANDLE  hEvents[2];
     451
     452        TRACE("(%p)\n",psc);
     453        ICOM_VTBL(&psc->refclk) = &irefclk;
     454
     455        InitializeCriticalSection( &psc->m_csClock );
     456        psc->m_dwTimeLast = GetTickCount();
     457        psc->m_rtLast = (REFERENCE_TIME)0;
     458        psc->m_hThreadTimer = (HANDLE)NULL;
     459        psc->m_hEventInit = (HANDLE)NULL;
     460        psc->m_idThreadTimer = 0;
     461        psc->m_dwAdvCookieNext = 1;
     462        ZeroMemory( psc->m_timerEntries, sizeof(psc->m_timerEntries) );
     463
     464        psc->m_hEventInit = CreateEventA( NULL, TRUE, FALSE, NULL );
     465        if ( psc->m_hEventInit == (HANDLE)NULL )
     466                goto err;
     467
     468        psc->m_hThreadTimer = CreateThread(
     469                NULL, 0,
     470                IReferenceClock_TimerEntry,
     471                psc, 0, &psc->m_idThreadTimer );
     472
     473        if ( psc->m_hThreadTimer == (HANDLE)NULL )
     474        {
     475                CloseHandle( psc->m_hEventInit );
     476                psc->m_hEventInit = (HANDLE)NULL;
     477                goto err;
     478        }
     479
     480        hEvents[0] = psc->m_hEventInit;
     481        hEvents[1] = psc->m_hThreadTimer;
     482        if ( WaitForMultipleObjects( 2, hEvents, FALSE, INFINITE )
     483                        != WAIT_OBJECT_0 )
     484        {
     485                CloseHandle( psc->m_hEventInit );
     486                psc->m_hEventInit = (HANDLE)NULL;
     487                CloseHandle( psc->m_hThreadTimer );
     488                psc->m_hThreadTimer = (HANDLE)NULL;
     489                goto err;
     490        }
     491
     492        return NOERROR;
     493
     494err:
     495        DeleteCriticalSection( &psc->m_csClock );
     496        return E_FAIL;
     497}
     498
     499void CSystemClock_UninitIReferenceClock( CSystemClock* psc )
     500{
     501        TRACE("(%p)\n",psc);
     502
     503        if ( psc->m_hThreadTimer != (HANDLE)NULL )
     504        {
     505                if ( PostThreadMessageA(
     506                        psc->m_idThreadTimer,
     507                        QUARTZ_MSG_EXITTHREAD,
     508                        0, 0 ) )
     509                {
     510                        WaitForSingleObject( psc->m_hThreadTimer, INFINITE );
     511                }
     512                CloseHandle( psc->m_hThreadTimer );
     513                psc->m_hThreadTimer = (HANDLE)NULL;
     514        }
     515
     516        DeleteCriticalSection( &psc->m_csClock );
     517}
Note: See TracChangeset for help on using the changeset viewer.