Esempio n. 1
0
//================================================================================================
//
//  DeviceRemoved
//
//  This routine will get called whenever any kIOGeneralInterest notification happens.  We are
//  interested in the kIOMessageServiceIsTerminated message so that's what we look for.  Other
//  messages are defined in IOMessage.h.
//
//================================================================================================
static void DeviceRemoved(void *refCon, io_service_t service, natural_t messageType, void *messageArgument) {
	kern_return_t kr;
	stDeviceListItem* deviceListItem = (stDeviceListItem *) refCon;
	DeviceItem_t* deviceItem = deviceListItem->deviceItem;

	if(messageType == kIOMessageServiceIsTerminated) {
		if(deviceListItem->deviceInterface) {
			kr = (*deviceListItem->deviceInterface)->Release(deviceListItem->deviceInterface);
		}

		kr = IOObjectRelease(deviceListItem->notification);


		ListResultItem_t* item = NULL;
		if(deviceItem) {
			item = CopyElement(&deviceItem->deviceParams);
			RemoveItemFromList(deviceItem);
			delete deviceItem;
		}
		else {
			item = new ListResultItem_t();
		}

		WaitForDeviceHandled();
		currentItem = item;
		isAdded = false;
		uv_async_send(&async_handler);
	}
}
Esempio n. 2
0
/***********************************************************************************
 Function Name      : NamedItemDelRef
 Inputs             : gc, psNamesArray, psNamedItem
 Outputs            : -
 Returns            : -
 Description        : Decrements the reference counter of the given named item.
                      Deletes the item if its refcount drops to zero.
************************************************************************************/
IMG_INTERNAL IMG_VOID NamedItemDelRef(GLES2Context *gc, GLES2NamesArray *psNamesArray, GLES2NamedItem* psNamedItem)
{
	GLES2_TIME_START(GLES2_TIMER_NAMES_ARRAY);
	LOCK_NAMES_ARRAY(psNamesArray);

	GLES_ASSERT(psNamedItem->ui32Name);
	GLES_ASSERT(psNamedItem->ui32RefCount > 0);

	if(psNamedItem->ui32RefCount == 1)
	{
		/* The item must be deleted. Remove it from the list */
		psNamedItem->ui32RefCount = 0;
		RemoveItemFromList(psNamesArray, psNamedItem);
	}
	else if(psNamedItem->ui32RefCount > 1)
	{
		/* Simply decrement the reference count */
		psNamedItem->ui32RefCount--;
		psNamedItem = IMG_NULL;
	}

	UNLOCK_NAMES_ARRAY(psNamesArray);
	GLES2_TIME_STOP(GLES2_TIMER_NAMES_ARRAY);

	/* Delete the data if its refcount dropped to zero */
	if(psNamedItem)
	{
		psNamesArray->pfnFree(gc, psNamedItem, IMG_FALSE);
	}
}
Esempio n. 3
0
/***********************************************************************************
 Function Name      : NamedItemDelRefByName
 Inputs             : gc, psNamesArray, ui32Num, ui32Name
 Outputs            : -
 Returns            : -
 Description        : Decreases the refcount of a list of items given their names.
                      The objects are deleted if their refcount drops to zero.
                      The names are removed from the list whether the objects are deleted or not.
                      The array ui32Name must have length ui32Num.
                      Names that do not match an object in the array are ignored silently.
************************************************************************************/
IMG_INTERNAL IMG_VOID NamedItemDelRefByName(GLES2Context *gc, GLES2NamesArray *psNamesArray,
							   IMG_UINT32 ui32Num, const IMG_UINT32 ui32Name[/*ui32Num*/])
{
	IMG_UINT32      i;
	GLES2NamedItem  *psNamedItem, *psNext, *psDeadMan = IMG_NULL;

	GLES2_TIME_START(GLES2_TIMER_NAMES_ARRAY);
	LOCK_NAMES_ARRAY(psNamesArray);

	for(i=0; i < ui32Num; ++i)
	{
		psNamedItem = LookupItemByName(psNamesArray, ui32Name[i]);

		if(psNamedItem)
		{
			GLES_ASSERT(psNamedItem->ui32RefCount > 0);
			
			/* Remove the name from the list even if the object is not going to be deleted */
			RemoveItemFromList(psNamesArray, psNamedItem);

			if(psNamedItem->ui32RefCount == 1)
			{
				/* The item must be deleted. Append it to the list of dead items
				 */
				psNamedItem->ui32RefCount = 0;
				psNamedItem->psNext = psDeadMan;
				psDeadMan = psNamedItem;
			}
			else if(psNamedItem->ui32RefCount > 1)
			{
				psNamedItem->ui32RefCount--;
			}
		}
	}

	UNLOCK_NAMES_ARRAY(psNamesArray);
	GLES2_TIME_STOP(GLES2_TIMER_NAMES_ARRAY);

	while(psDeadMan)
	{
		psNext = psDeadMan->psNext;
		if(psDeadMan->bGeneratedButUnused)
		{
			GLES2Free(gc, psDeadMan);
		}
		else
		{
			psNamesArray->pfnFree(gc, psDeadMan, IMG_FALSE);
		}
		psDeadMan = psNext;
	}
}