2001-08-22 20:06:00 +02:00
|
|
|
/*
|
|
|
|
* List of components. (for internal use)
|
|
|
|
*
|
|
|
|
* 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 "debugtools.h"
|
|
|
|
DEFAULT_DEBUG_CHANNEL(quartz);
|
|
|
|
|
|
|
|
#include "quartz_private.h"
|
|
|
|
#include "complist.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct QUARTZ_CompList
|
|
|
|
{
|
|
|
|
QUARTZ_CompListItem* pFirst;
|
|
|
|
QUARTZ_CompListItem* pLast;
|
2001-09-07 21:46:49 +02:00
|
|
|
CRITICAL_SECTION csList;
|
2001-08-22 20:06:00 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct QUARTZ_CompListItem
|
|
|
|
{
|
|
|
|
IUnknown* punk;
|
|
|
|
QUARTZ_CompListItem* pNext;
|
|
|
|
QUARTZ_CompListItem* pPrev;
|
2001-09-07 21:46:49 +02:00
|
|
|
void* pvData;
|
|
|
|
DWORD dwDataLen;
|
2001-08-22 20:06:00 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
QUARTZ_CompList* QUARTZ_CompList_Alloc( void )
|
|
|
|
{
|
|
|
|
QUARTZ_CompList* pList;
|
|
|
|
|
|
|
|
pList = (QUARTZ_CompList*)QUARTZ_AllocMem( sizeof(QUARTZ_CompList) );
|
|
|
|
if ( pList != NULL )
|
|
|
|
{
|
|
|
|
/* construct. */
|
|
|
|
pList->pFirst = NULL;
|
|
|
|
pList->pLast = NULL;
|
2001-09-07 21:46:49 +02:00
|
|
|
|
|
|
|
InitializeCriticalSection( &pList->csList );
|
2001-08-22 20:06:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return pList;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QUARTZ_CompList_Free( QUARTZ_CompList* pList )
|
|
|
|
{
|
|
|
|
QUARTZ_CompListItem* pCur;
|
|
|
|
QUARTZ_CompListItem* pNext;
|
|
|
|
|
|
|
|
if ( pList != NULL )
|
|
|
|
{
|
|
|
|
pCur = pList->pFirst;
|
|
|
|
while ( pCur != NULL )
|
|
|
|
{
|
|
|
|
pNext = pCur->pNext;
|
|
|
|
if ( pCur->punk != NULL )
|
|
|
|
IUnknown_Release( pCur->punk );
|
2001-09-07 21:46:49 +02:00
|
|
|
if ( pCur->pvData != NULL )
|
|
|
|
QUARTZ_FreeMem( pCur->pvData );
|
2001-08-22 20:06:00 +02:00
|
|
|
QUARTZ_FreeMem( pCur );
|
|
|
|
pCur = pNext;
|
|
|
|
}
|
2001-09-07 21:46:49 +02:00
|
|
|
|
|
|
|
DeleteCriticalSection( &pList->csList );
|
|
|
|
|
2001-08-22 20:06:00 +02:00
|
|
|
QUARTZ_FreeMem( pList );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-09-07 21:46:49 +02:00
|
|
|
void QUARTZ_CompList_Lock( QUARTZ_CompList* pList )
|
|
|
|
{
|
|
|
|
EnterCriticalSection( &pList->csList );
|
|
|
|
}
|
|
|
|
|
|
|
|
void QUARTZ_CompList_Unlock( QUARTZ_CompList* pList )
|
|
|
|
{
|
|
|
|
LeaveCriticalSection( &pList->csList );
|
|
|
|
}
|
|
|
|
|
|
|
|
QUARTZ_CompList* QUARTZ_CompList_Dup(
|
|
|
|
const QUARTZ_CompList* pList, BOOL fDupData )
|
2001-08-22 20:06:00 +02:00
|
|
|
{
|
|
|
|
QUARTZ_CompList* pNewList;
|
2001-09-07 21:46:49 +02:00
|
|
|
const QUARTZ_CompListItem* pCur;
|
2001-08-22 20:06:00 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
pNewList = QUARTZ_CompList_Alloc();
|
|
|
|
if ( pNewList == NULL )
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
pCur = pList->pFirst;
|
|
|
|
while ( pCur != NULL )
|
|
|
|
{
|
|
|
|
if ( pCur->punk != NULL )
|
|
|
|
{
|
2001-09-07 21:46:49 +02:00
|
|
|
if ( fDupData )
|
|
|
|
hr = QUARTZ_CompList_AddComp(
|
|
|
|
pNewList, pCur->punk,
|
|
|
|
pCur->pvData, pCur->dwDataLen );
|
|
|
|
else
|
|
|
|
hr = QUARTZ_CompList_AddComp(
|
|
|
|
pNewList, pCur->punk, NULL, 0 );
|
2001-08-22 20:06:00 +02:00
|
|
|
if ( FAILED(hr) )
|
|
|
|
{
|
|
|
|
QUARTZ_CompList_Free( pNewList );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pCur = pCur->pNext;
|
|
|
|
}
|
|
|
|
|
|
|
|
return pNewList;
|
|
|
|
}
|
|
|
|
|
2001-09-07 21:46:49 +02:00
|
|
|
HRESULT QUARTZ_CompList_AddComp(
|
|
|
|
QUARTZ_CompList* pList, IUnknown* punk,
|
|
|
|
const void* pvData, DWORD dwDataLen )
|
2001-08-22 20:06:00 +02:00
|
|
|
{
|
|
|
|
QUARTZ_CompListItem* pItem;
|
|
|
|
|
|
|
|
pItem = (QUARTZ_CompListItem*)QUARTZ_AllocMem( sizeof(QUARTZ_CompListItem) );
|
|
|
|
if ( pItem == NULL )
|
|
|
|
return E_OUTOFMEMORY; /* out of memory. */
|
2001-09-07 21:46:49 +02:00
|
|
|
|
|
|
|
pItem->pvData = NULL;
|
|
|
|
pItem->dwDataLen = 0;
|
|
|
|
if ( pvData != NULL )
|
|
|
|
{
|
|
|
|
pItem->pvData = (void*)QUARTZ_AllocMem( dwDataLen );
|
|
|
|
if ( pItem->pvData == NULL )
|
|
|
|
{
|
|
|
|
QUARTZ_FreeMem( pItem );
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
memcpy( pItem->pvData, pvData, dwDataLen );
|
|
|
|
pItem->dwDataLen = dwDataLen;
|
|
|
|
}
|
|
|
|
|
2001-08-22 20:06:00 +02:00
|
|
|
pItem->punk = punk; IUnknown_AddRef(punk);
|
|
|
|
|
|
|
|
if ( pList->pFirst != NULL )
|
|
|
|
pList->pFirst->pPrev = pItem;
|
|
|
|
else
|
|
|
|
pList->pLast = pItem;
|
|
|
|
pItem->pNext = pList->pFirst;
|
2001-09-07 21:46:49 +02:00
|
|
|
pList->pFirst = pItem;
|
2001-08-22 20:06:00 +02:00
|
|
|
pItem->pPrev = NULL;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT QUARTZ_CompList_RemoveComp( QUARTZ_CompList* pList, IUnknown* punk )
|
|
|
|
{
|
|
|
|
QUARTZ_CompListItem* pCur;
|
|
|
|
|
|
|
|
pCur = QUARTZ_CompList_SearchComp( pList, punk );
|
|
|
|
if ( pCur == NULL )
|
|
|
|
return S_FALSE; /* already removed. */
|
|
|
|
|
|
|
|
/* remove from list. */
|
|
|
|
if ( pCur->pNext != NULL )
|
|
|
|
pCur->pNext->pPrev = pCur->pPrev;
|
|
|
|
else
|
|
|
|
pList->pLast = pCur->pPrev;
|
|
|
|
if ( pCur->pPrev != NULL )
|
|
|
|
pCur->pPrev->pNext = pCur->pNext;
|
|
|
|
else
|
|
|
|
pList->pFirst = pCur->pNext;
|
|
|
|
|
|
|
|
/* release this item. */
|
|
|
|
if ( pCur->punk != NULL )
|
|
|
|
IUnknown_Release( pCur->punk );
|
2001-09-07 21:46:49 +02:00
|
|
|
if ( pCur->pvData != NULL )
|
|
|
|
QUARTZ_FreeMem( pCur->pvData );
|
2001-08-22 20:06:00 +02:00
|
|
|
QUARTZ_FreeMem( pCur );
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
QUARTZ_CompListItem* QUARTZ_CompList_SearchComp(
|
|
|
|
QUARTZ_CompList* pList, IUnknown* punk )
|
|
|
|
{
|
|
|
|
QUARTZ_CompListItem* pCur;
|
|
|
|
|
|
|
|
pCur = pList->pFirst;
|
|
|
|
while ( pCur != NULL )
|
|
|
|
{
|
|
|
|
if ( pCur->punk == punk )
|
|
|
|
return pCur;
|
|
|
|
pCur = pCur->pNext;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-09-07 21:46:49 +02:00
|
|
|
QUARTZ_CompListItem* QUARTZ_CompList_SearchData(
|
|
|
|
QUARTZ_CompList* pList, const void* pvData, DWORD dwDataLen )
|
|
|
|
{
|
|
|
|
QUARTZ_CompListItem* pCur;
|
|
|
|
|
|
|
|
pCur = pList->pFirst;
|
|
|
|
while ( pCur != NULL )
|
|
|
|
{
|
|
|
|
if ( pCur->dwDataLen == dwDataLen &&
|
|
|
|
!memcmp( pCur->pvData, pvData, dwDataLen ) )
|
|
|
|
return pCur;
|
|
|
|
pCur = pCur->pNext;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-08-22 20:06:00 +02:00
|
|
|
QUARTZ_CompListItem* QUARTZ_CompList_GetFirst(
|
|
|
|
QUARTZ_CompList* pList )
|
|
|
|
{
|
|
|
|
return pList->pFirst;
|
|
|
|
}
|
|
|
|
|
|
|
|
QUARTZ_CompListItem* QUARTZ_CompList_GetNext(
|
|
|
|
QUARTZ_CompList* pList, QUARTZ_CompListItem* pPrev )
|
|
|
|
{
|
|
|
|
return pPrev->pNext;
|
|
|
|
}
|
|
|
|
|
|
|
|
IUnknown* QUARTZ_CompList_GetItemPtr( QUARTZ_CompListItem* pItem )
|
|
|
|
{
|
|
|
|
return pItem->punk;
|
|
|
|
}
|
2001-09-07 21:46:49 +02:00
|
|
|
|
|
|
|
const void* QUARTZ_CompList_GetDataPtr( QUARTZ_CompListItem* pItem )
|
|
|
|
{
|
|
|
|
return pItem->pvData;
|
|
|
|
}
|
|
|
|
|
|
|
|
DWORD QUARTZ_CompList_GetDataLength( QUARTZ_CompListItem* pItem )
|
|
|
|
{
|
|
|
|
return pItem->dwDataLen;
|
|
|
|
}
|