Ignore:
Timestamp:
Sep 15, 2001, 11:28:23 AM (24 years ago)
Author:
sandervl
Message:

wine update

File:
1 edited

Legend:

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

    r6649 r6710  
    1 /* $Id: imem.c,v 1.3 2001-09-05 13:36:35 bird Exp $ */
    21/*
    32 * Implementation of CLSID_MemoryAllocator.
     
    2827IMemAllocator_fnQueryInterface(IMemAllocator* iface,REFIID riid,void** ppobj)
    2928{
    30     CMemoryAllocator_THIS(iface,memalloc);
     29        CMemoryAllocator_THIS(iface,memalloc);
    3130
    32     TRACE("(%p)->()\n",This);
     31        TRACE("(%p)->()\n",This);
    3332
    34     return IUnknown_QueryInterface(This->unk.punkControl,riid,ppobj);
     33        return IUnknown_QueryInterface(This->unk.punkControl,riid,ppobj);
    3534}
    3635
     
    3837IMemAllocator_fnAddRef(IMemAllocator* iface)
    3938{
    40     CMemoryAllocator_THIS(iface,memalloc);
     39        CMemoryAllocator_THIS(iface,memalloc);
    4140
    42     TRACE("(%p)->()\n",This);
     41        TRACE("(%p)->()\n",This);
    4342
    44     return IUnknown_AddRef(This->unk.punkControl);
     43        return IUnknown_AddRef(This->unk.punkControl);
    4544}
    4645
     
    4847IMemAllocator_fnRelease(IMemAllocator* iface)
    4948{
    50     CMemoryAllocator_THIS(iface,memalloc);
     49        CMemoryAllocator_THIS(iface,memalloc);
    5150
    52     TRACE("(%p)->()\n",This);
     51        TRACE("(%p)->()\n",This);
    5352
    54     return IUnknown_Release(This->unk.punkControl);
     53        return IUnknown_Release(This->unk.punkControl);
    5554}
    5655
     
    5857IMemAllocator_fnSetProperties(IMemAllocator* iface,ALLOCATOR_PROPERTIES* pPropReq,ALLOCATOR_PROPERTIES* pPropActual)
    5958{
    60     CMemoryAllocator_THIS(iface,memalloc);
     59        CMemoryAllocator_THIS(iface,memalloc);
     60        long    padding;
    6161
    62     FIXME( "(%p)->() stub!\n", This );
    63     return E_NOTIMPL;
     62        TRACE( "(%p)->(%p,%p)\n", This, pPropReq, pPropActual );
     63
     64        if ( pPropReq == NULL || pPropActual == NULL )
     65                return E_POINTER;
     66        if ( pPropReq->cBuffers < 0 ||
     67             pPropReq->cbBuffer < 0 ||
     68             pPropReq->cbAlign < 0 ||
     69             pPropReq->cbPrefix < 0 )
     70                return E_INVALIDARG;
     71
     72        if ( ( pPropReq->cbAlign & (pPropReq->cbAlign-1) ) != 0 )
     73                return E_INVALIDARG;
     74
     75        EnterCriticalSection( &This->csMem );
     76
     77        This->prop.cBuffers = pPropReq->cBuffers;
     78        This->prop.cbBuffer = pPropReq->cbBuffer;
     79        This->prop.cbAlign = pPropReq->cbAlign;
     80        This->prop.cbPrefix = pPropReq->cbPrefix;
     81
     82        if ( This->prop.cbAlign == 0 )
     83                This->prop.cbAlign = 1;
     84        padding = This->prop.cbAlign -
     85                ( (This->prop.cbBuffer+This->prop.cbPrefix) % This->prop.cbAlign );
     86
     87        This->prop.cbBuffer += padding;
     88
     89        memcpy( pPropActual, &This->prop, sizeof(ALLOCATOR_PROPERTIES) );
     90
     91        LeaveCriticalSection( &This->csMem );
     92
     93        return NOERROR;
    6494}
    6595
     
    6797IMemAllocator_fnGetProperties(IMemAllocator* iface,ALLOCATOR_PROPERTIES* pProp)
    6898{
    69     CMemoryAllocator_THIS(iface,memalloc);
     99        CMemoryAllocator_THIS(iface,memalloc);
    70100
    71     FIXME( "(%p)->() stub!\n", This );
    72     return E_NOTIMPL;
     101        TRACE( "(%p)->(%p)\n", This, pProp );
     102
     103        if ( pProp == NULL )
     104                return E_POINTER;
     105
     106        EnterCriticalSection( &This->csMem );
     107
     108        memcpy( pProp, &This->prop, sizeof(ALLOCATOR_PROPERTIES) );
     109
     110        LeaveCriticalSection( &This->csMem );
     111
     112        return NOERROR;
    73113}
    74114
     
    76116IMemAllocator_fnCommit(IMemAllocator* iface)
    77117{
    78     CMemoryAllocator_THIS(iface,memalloc);
     118        CMemoryAllocator_THIS(iface,memalloc);
    79119
    80     FIXME( "(%p)->() stub!\n", This );
    81     return E_NOTIMPL;
     120        FIXME( "(%p)->() stub!\n", This );
     121        return E_NOTIMPL;
    82122}
    83123
     
    85125IMemAllocator_fnDecommit(IMemAllocator* iface)
    86126{
    87     CMemoryAllocator_THIS(iface,memalloc);
     127        CMemoryAllocator_THIS(iface,memalloc);
    88128
    89     FIXME( "(%p)->() stub!\n", This );
    90     return E_NOTIMPL;
     129        FIXME( "(%p)->() stub!\n", This );
     130        return E_NOTIMPL;
    91131}
    92132
     
    94134IMemAllocator_fnGetBuffer(IMemAllocator* iface,IMediaSample** ppSample,REFERENCE_TIME* prtStart,REFERENCE_TIME* prtEnd,DWORD dwFlags)
    95135{
    96     CMemoryAllocator_THIS(iface,memalloc);
     136        CMemoryAllocator_THIS(iface,memalloc);
    97137
    98     FIXME( "(%p)->() stub!\n", This );
    99     return E_NOTIMPL;
     138        FIXME( "(%p)->() stub!\n", This );
     139        return E_NOTIMPL;
    100140}
    101141
     
    103143IMemAllocator_fnReleaseBuffer(IMemAllocator* iface,IMediaSample* pSample)
    104144{
    105     CMemoryAllocator_THIS(iface,memalloc);
     145        CMemoryAllocator_THIS(iface,memalloc);
    106146
    107     FIXME( "(%p)->() stub!\n", This );
    108     return E_NOTIMPL;
     147        FIXME( "(%p)->() stub!\n", This );
     148        return E_NOTIMPL;
    109149}
    110150
     
    113153static ICOM_VTABLE(IMemAllocator) imemalloc =
    114154{
    115     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
    116     /* IUnknown fields */
    117     IMemAllocator_fnQueryInterface,
    118     IMemAllocator_fnAddRef,
    119     IMemAllocator_fnRelease,
    120     /* IMemAllocator fields */
    121     IMemAllocator_fnSetProperties,
    122     IMemAllocator_fnGetProperties,
    123     IMemAllocator_fnCommit,
    124     IMemAllocator_fnDecommit,
    125     IMemAllocator_fnGetBuffer,
    126     IMemAllocator_fnReleaseBuffer,
     155        ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
     156        /* IUnknown fields */
     157        IMemAllocator_fnQueryInterface,
     158        IMemAllocator_fnAddRef,
     159        IMemAllocator_fnRelease,
     160        /* IMemAllocator fields */
     161        IMemAllocator_fnSetProperties,
     162        IMemAllocator_fnGetProperties,
     163        IMemAllocator_fnCommit,
     164        IMemAllocator_fnDecommit,
     165        IMemAllocator_fnGetBuffer,
     166        IMemAllocator_fnReleaseBuffer,
    127167};
    128168
    129169
    130 void CMemoryAllocator_InitIMemAllocator( CMemoryAllocator* pma )
     170HRESULT CMemoryAllocator_InitIMemAllocator( CMemoryAllocator* pma )
    131171{
    132     TRACE("(%p)\n",pma);
    133     ICOM_VTBL(&pma->memalloc) = &imemalloc;
     172        TRACE("(%p)\n",pma);
     173
     174        ICOM_VTBL(&pma->memalloc) = &imemalloc;
     175
     176        ZeroMemory( &pma->prop, sizeof(pma->prop) );
     177
     178        InitializeCriticalSection( &pma->csMem );
     179
     180        return NOERROR;
    134181}
     182
     183void CMemoryAllocator_UninitIMemAllocator( CMemoryAllocator* pma )
     184{
     185        TRACE("(%p)\n",pma);
     186
     187        IMemAllocator_Decommit( (IMemAllocator*)(&pma->memalloc) );
     188
     189        DeleteCriticalSection( &pma->csMem );
     190}
Note: See TracChangeset for help on using the changeset viewer.