2001-08-15 21:26:52 +02:00
|
|
|
/*
|
|
|
|
* Implementation of CLSID_MemoryAllocator.
|
|
|
|
*
|
|
|
|
* FIXME - stub.
|
|
|
|
*
|
|
|
|
* hidenori@a2.ctktv.ne.jp
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
#include "wine/obj_base.h"
|
|
|
|
#include "strmif.h"
|
|
|
|
#include "uuids.h"
|
|
|
|
|
|
|
|
#include "debugtools.h"
|
|
|
|
DEFAULT_DEBUG_CHANNEL(quartz);
|
|
|
|
|
|
|
|
#include "quartz_private.h"
|
|
|
|
#include "memalloc.h"
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IMemAllocator_fnQueryInterface(IMemAllocator* iface,REFIID riid,void** ppobj)
|
|
|
|
{
|
|
|
|
CMemoryAllocator_THIS(iface,memalloc);
|
|
|
|
|
|
|
|
TRACE("(%p)->()\n",This);
|
|
|
|
|
2001-08-22 20:06:00 +02:00
|
|
|
return IUnknown_QueryInterface(This->unk.punkControl,riid,ppobj);
|
2001-08-15 21:26:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
|
|
|
IMemAllocator_fnAddRef(IMemAllocator* iface)
|
|
|
|
{
|
|
|
|
CMemoryAllocator_THIS(iface,memalloc);
|
|
|
|
|
|
|
|
TRACE("(%p)->()\n",This);
|
|
|
|
|
2001-08-22 20:06:00 +02:00
|
|
|
return IUnknown_AddRef(This->unk.punkControl);
|
2001-08-15 21:26:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
|
|
|
IMemAllocator_fnRelease(IMemAllocator* iface)
|
|
|
|
{
|
|
|
|
CMemoryAllocator_THIS(iface,memalloc);
|
|
|
|
|
|
|
|
TRACE("(%p)->()\n",This);
|
|
|
|
|
2001-08-22 20:06:00 +02:00
|
|
|
return IUnknown_Release(This->unk.punkControl);
|
2001-08-15 21:26:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IMemAllocator_fnSetProperties(IMemAllocator* iface,ALLOCATOR_PROPERTIES* pPropReq,ALLOCATOR_PROPERTIES* pPropActual)
|
|
|
|
{
|
|
|
|
CMemoryAllocator_THIS(iface,memalloc);
|
2001-09-11 02:29:03 +02:00
|
|
|
long padding;
|
2001-08-15 21:26:52 +02:00
|
|
|
|
2001-09-11 02:29:03 +02:00
|
|
|
TRACE( "(%p)->(%p,%p)\n", This, pPropReq, pPropActual );
|
|
|
|
|
|
|
|
if ( pPropReq == NULL || pPropActual == NULL )
|
|
|
|
return E_POINTER;
|
|
|
|
if ( pPropReq->cBuffers < 0 ||
|
|
|
|
pPropReq->cbBuffer < 0 ||
|
|
|
|
pPropReq->cbAlign < 0 ||
|
|
|
|
pPropReq->cbPrefix < 0 )
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if ( ( pPropReq->cbAlign & (pPropReq->cbAlign-1) ) != 0 )
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
EnterCriticalSection( &This->csMem );
|
|
|
|
|
|
|
|
This->prop.cBuffers = pPropReq->cBuffers;
|
|
|
|
This->prop.cbBuffer = pPropReq->cbBuffer;
|
|
|
|
This->prop.cbAlign = pPropReq->cbAlign;
|
|
|
|
This->prop.cbPrefix = pPropReq->cbPrefix;
|
|
|
|
|
|
|
|
if ( This->prop.cbAlign == 0 )
|
|
|
|
This->prop.cbAlign = 1;
|
|
|
|
padding = This->prop.cbAlign -
|
|
|
|
( (This->prop.cbBuffer+This->prop.cbPrefix) % This->prop.cbAlign );
|
|
|
|
|
|
|
|
This->prop.cbBuffer += padding;
|
|
|
|
|
|
|
|
memcpy( pPropActual, &This->prop, sizeof(ALLOCATOR_PROPERTIES) );
|
|
|
|
|
|
|
|
LeaveCriticalSection( &This->csMem );
|
|
|
|
|
|
|
|
return NOERROR;
|
2001-08-15 21:26:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IMemAllocator_fnGetProperties(IMemAllocator* iface,ALLOCATOR_PROPERTIES* pProp)
|
|
|
|
{
|
|
|
|
CMemoryAllocator_THIS(iface,memalloc);
|
|
|
|
|
2001-09-11 02:29:03 +02:00
|
|
|
TRACE( "(%p)->(%p)\n", This, pProp );
|
|
|
|
|
|
|
|
if ( pProp == NULL )
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
EnterCriticalSection( &This->csMem );
|
|
|
|
|
|
|
|
memcpy( pProp, &This->prop, sizeof(ALLOCATOR_PROPERTIES) );
|
|
|
|
|
|
|
|
LeaveCriticalSection( &This->csMem );
|
|
|
|
|
|
|
|
return NOERROR;
|
2001-08-15 21:26:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IMemAllocator_fnCommit(IMemAllocator* iface)
|
|
|
|
{
|
|
|
|
CMemoryAllocator_THIS(iface,memalloc);
|
|
|
|
|
|
|
|
FIXME( "(%p)->() stub!\n", This );
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IMemAllocator_fnDecommit(IMemAllocator* iface)
|
|
|
|
{
|
|
|
|
CMemoryAllocator_THIS(iface,memalloc);
|
|
|
|
|
|
|
|
FIXME( "(%p)->() stub!\n", This );
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IMemAllocator_fnGetBuffer(IMemAllocator* iface,IMediaSample** ppSample,REFERENCE_TIME* prtStart,REFERENCE_TIME* prtEnd,DWORD dwFlags)
|
|
|
|
{
|
|
|
|
CMemoryAllocator_THIS(iface,memalloc);
|
|
|
|
|
|
|
|
FIXME( "(%p)->() stub!\n", This );
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IMemAllocator_fnReleaseBuffer(IMemAllocator* iface,IMediaSample* pSample)
|
|
|
|
{
|
|
|
|
CMemoryAllocator_THIS(iface,memalloc);
|
|
|
|
|
|
|
|
FIXME( "(%p)->() stub!\n", This );
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static ICOM_VTABLE(IMemAllocator) imemalloc =
|
|
|
|
{
|
|
|
|
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
|
|
|
/* IUnknown fields */
|
|
|
|
IMemAllocator_fnQueryInterface,
|
|
|
|
IMemAllocator_fnAddRef,
|
|
|
|
IMemAllocator_fnRelease,
|
|
|
|
/* IMemAllocator fields */
|
|
|
|
IMemAllocator_fnSetProperties,
|
|
|
|
IMemAllocator_fnGetProperties,
|
|
|
|
IMemAllocator_fnCommit,
|
|
|
|
IMemAllocator_fnDecommit,
|
|
|
|
IMemAllocator_fnGetBuffer,
|
|
|
|
IMemAllocator_fnReleaseBuffer,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-09-07 21:46:49 +02:00
|
|
|
HRESULT CMemoryAllocator_InitIMemAllocator( CMemoryAllocator* pma )
|
2001-08-15 21:26:52 +02:00
|
|
|
{
|
|
|
|
TRACE("(%p)\n",pma);
|
2001-09-11 02:29:03 +02:00
|
|
|
|
2001-08-15 21:26:52 +02:00
|
|
|
ICOM_VTBL(&pma->memalloc) = &imemalloc;
|
2001-09-07 21:46:49 +02:00
|
|
|
|
2001-09-11 02:29:03 +02:00
|
|
|
ZeroMemory( &pma->prop, sizeof(pma->prop) );
|
|
|
|
|
|
|
|
InitializeCriticalSection( &pma->csMem );
|
|
|
|
|
2001-09-07 21:46:49 +02:00
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMemoryAllocator_UninitIMemAllocator( CMemoryAllocator* pma )
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n",pma);
|
2001-09-11 02:29:03 +02:00
|
|
|
|
|
|
|
IMemAllocator_Decommit( (IMemAllocator*)(&pma->memalloc) );
|
|
|
|
|
|
|
|
DeleteCriticalSection( &pma->csMem );
|
2001-08-15 21:26:52 +02:00
|
|
|
}
|