コード例 #1
0
ファイル: api_device.c プロジェクト: archipelagos/sample
/* INFO: */
static int ApiDeviceCreateActionBinding(
		const unsigned int inpServiceIndex,
		const char * const inpActionName,
		const StructuresDynamicActionFunction inpActionFunction) {
	unsigned int localActionIndex = { 0 };
	unsigned int localActionCount = { 0 };
	const char * localActionName = { 0 };

	CHECK_INITIALIZED(staticInitializedFlag);

	CHECK(ApiDeviceGetServiceActionCount(inpServiceIndex,
		(& localActionCount)));

	for(; localActionIndex < localActionCount; ++localActionIndex) {
		CHECK(ApiDeviceGetServiceActionName(inpServiceIndex,
			localActionIndex, (& localActionName)));

		if(! strcmp(localActionName, inpActionName)) {
			CHECK(ApiDeviceSetActionFunction(inpServiceIndex,
				localActionIndex, inpActionFunction));

			return NO_ERROR;
		}
	}

	return ERROR;
}
コード例 #2
0
HRESULT SMPortOutputQueue::Flush(SMThread& Thread, DWORD dwTimeout /*= DEFAULT_FLUSH_TIMEOUT*/)
{
    HRESULT hr = S_OK;

    // Verify that the queue has been initialized
    CHECK_INITIALIZED(Flush);

    SMTimer Timer;
    bool bDone = false;
    while (!bDone && Thread.IsPermittedToRun() && m_Port.IsOpen())
    {
        // Need atomic access to queue
        SMSingleLock SingleLock(&m_QueueMutex);
        SingleLock.Lock();
        bDone = m_Queue.empty();
        SingleLock.Unlock();

        // Sleep for a while, even if the queue is now empty (in order to allow
        // for the last message removed to be fully transmitted).
        ::Sleep(100);
        if (!bDone && (Timer.ElapsedSeconds() >= dwTimeout))
        {
            bDone = true;
            hr = E_FAIL;
            SM_LOG_NAME(hr, 1, "SMPortOutputQueue::Flush(): Timed-out waiting for queue to become empty!");
        }
    }

    return hr;
}
コード例 #3
0
ファイル: opengl.cpp プロジェクト: parvizp/Halide
// Delete all texture information associated with a buffer. The OpenGL texture
// itself is only deleted if it was actually allocated by Halide and not
// provided by the host application.
EXPORT int halide_opengl_dev_free(void *user_context, buffer_t *buf) {
    CHECK_INITIALIZED(1);

    GLuint tex = get_texture_id(buf);
    if (tex == 0) {
        return 0;
    }

    // Look up corresponding HalideOpenGLTexture and unlink it from the list.
    HalideOpenGLTexture **ptr = &ST.textures;
    HalideOpenGLTexture *texinfo = *ptr;
    for (; texinfo != NULL; ptr = &texinfo->next, texinfo = *ptr) {
        if (texinfo->id == tex) {
            *ptr = texinfo->next;
            texinfo->next = NULL;
            break;
        }
    }
    if (!texinfo) {
        halide_error(user_context, "Internal error: texture not found");
        return 1;
    }

    // Delete texture if it was allocated by us.
    if (texinfo->halide_allocated) {
        ST.DeleteTextures(1, &tex);
        CHECK_GLERROR(1);
        buf->dev = 0;
    }

    free(texinfo);
    return 0;
}
コード例 #4
0
ファイル: device_list.c プロジェクト: archipelagos/sample
/* INFO: */
static int DeviceListMutexInit() {
	CHECK_INITIALIZED(staticInitializedFlag);

	CHECK(pthread_mutex_init((& staticDeviceListMutex), 0));

	return NO_ERROR;
}
コード例 #5
0
ファイル: device_list.c プロジェクト: archipelagos/sample
/* INFO: */
static int DeviceListMutexDestroy() {
	CHECK_INITIALIZED(staticInitializedFlag);

	CHECK(pthread_mutex_destroy(& staticDeviceListMutex));

	return NO_ERROR;
}
コード例 #6
0
IMPLEMENT_DEBUG_FUNCENTRY_4(CGDODatabase,get_ObjectsDef,VARIANT, vIndex, VARIANT_BOOL, fCreate, BSTR, Type, ITRiASObjects**, ppIObjectsDef) 
{
	CHECKOUTPOINTER(ppIObjectsDef);
	COM_TRY {
		CHECK_INITIALIZED();

	WTRiASObjects	pTRiASObjects;
	CComVariant	vItem;

		RETURN_FAILED_HRESULT(EnsureObjectsColl());
	
	HRESULT hr = m_pGDOObjectsCollection -> Item (vIndex, CLEARED(vItem));

		if (SUCCEEDED(hr)) 
			pTRiASObjects = V_DISPATCH(&vItem);
		else if (TRIASDB_E_UNKNOWN_OBJECTS == hr && fCreate) {
		WTRiASObjectsCollection	pTRiASObjectsCollection;
		
			ERROR_FAILED_HRESULT(m_pGDOObjectsCollection -> QueryInterface (pTRiASObjectsCollection.ppi()), E_FAIL);
			ERROR_FAILED_HRESULT(pTRiASObjectsCollection -> Add (V_BSTR(&vIndex), Type, pTRiASObjects.ppi()), E_FAIL);
		} else 
			return hr;

		*ppIObjectsDef = pTRiASObjects.detach();
	} COM_CATCH;
	return S_OK;
}
コード例 #7
0
ファイル: device_list.c プロジェクト: archipelagos/sample
/* INFO: */
int DeviceListPrintList() {
	StructuresDynamicNode * localNode = { 0 };
	unsigned int localDeviceNumber = { 0 };

	CHECK_INITIALIZED(staticInitializedFlag);

	++localDeviceNumber;

	CHECK(ConsolePrint(DEVICE_LIST_PRINT_LIST_STRING));

	CHECK(DeviceListMutexLock());
	{
		localNode = globalDeviceList;

		while(localNode) {
			CHECK(ConsolePrint(
				DEVICE_LIST_PRINT_LIST_ENTRY_FORMATTER,
				localDeviceNumber, localNode->device->
				friendlyName, localNode->device->
				uniqueDeviceName));
			localNode = localNode->next;

			++localDeviceNumber;
		}
	}
	CHECK(DeviceListMutexUnlock());

	CHECK(ConsolePrint(DEVICE_LIST_NEW_LINE_STRING));

	return NO_ERROR;
}
コード例 #8
0
ファイル: device_list.c プロジェクト: archipelagos/sample
/* INFO: */
int DeviceListUpdateTimeoutIfDeviceAlreadyKnown(
		const char * const inpUniqueDeviceName,
		const unsigned int inpAdvertisementTimeout,
		bool * const inpAlreadyKnownFlag) {
	StructuresDynamicNode * localNode = { 0 };
	bool localAlreadyKnownFlag = { 0 };

	CHECK_INITIALIZED(staticInitializedFlag);

	CHECK(DeviceListMutexLock());
	{
		localNode = globalDeviceList;

		while(localNode) {
			if(! strcmp(inpUniqueDeviceName, localNode->device->
					uniqueDeviceName)) {
				localNode->advertisementTimeout =
					inpAdvertisementTimeout;
				localAlreadyKnownFlag = true;

				break;
			}

			localNode = localNode->next;
		}
	}
	CHECK(DeviceListMutexUnlock());

	(* inpAlreadyKnownFlag) = localAlreadyKnownFlag;

	return NO_ERROR;
}
コード例 #9
0
ファイル: device_list.c プロジェクト: archipelagos/sample
/* INFO: */
int DeviceListMutexUnlock() {
	CHECK_INITIALIZED(staticInitializedFlag);

	CHECK(pthread_mutex_unlock(& staticDeviceListMutex));

	return NO_ERROR;
}
コード例 #10
0
ファイル: device_list.c プロジェクト: archipelagos/sample
/* INFO: */
static int DeviceListCreateNode(StructuresDynamicNode ** const inpDeviceNode,
		const char * const inpDescriptionDocumentURL,
		const unsigned int inpAdvertisementTimeout,
		StructuresDynamicDevice * const inpDeviceStructure) {
	StructuresDynamicNode * localDeviceNode = { 0 };

	CHECK_INITIALIZED(staticInitializedFlag);

	CHECK(DeviceListSubscribeServices(inpDeviceStructure->
		serviceArray, inpDeviceStructure->serviceCount,
		inpAdvertisementTimeout));

	localDeviceNode = malloc(sizeof(StructuresDynamicNode));

	CHECK_MALLOCED(localDeviceNode);

	localDeviceNode->descriptionDocumentURL = UtilsStringDuplicate(
		inpDescriptionDocumentURL);
	localDeviceNode->advertisementTimeout = inpAdvertisementTimeout;
	localDeviceNode->device = inpDeviceStructure;
	localDeviceNode->next = 0;

	(* inpDeviceNode) = localDeviceNode;

	return NO_ERROR;
}
コード例 #11
0
ファイル: api_device.c プロジェクト: archipelagos/sample
/* INFO: */
int ApiDeviceGetDeviceServiceCount(
		unsigned int * const inpDeviceServiceCountBuffer) {
	CHECK_INITIALIZED(staticInitializedFlag);

	(* inpDeviceServiceCountBuffer) = staticStructuresDynamicDevice->
		serviceCount;

	return NO_ERROR;
}
コード例 #12
0
ファイル: api_device.c プロジェクト: archipelagos/sample
/* INFO: */
int ApiDeviceGetUniqueDeviceName(
		const char ** const inpUniqueDeviceNameBuffer) {
	CHECK_INITIALIZED(staticInitializedFlag);

	(* inpUniqueDeviceNameBuffer) = staticStructuresDynamicDevice->
		uniqueDeviceName;

	return NO_ERROR;
}
コード例 #13
0
ファイル: device_list.c プロジェクト: archipelagos/sample
/* INFO: */
int DeviceListDestroy() {
	CHECK_INITIALIZED(staticInitializedFlag);

	CHECK(DeviceListMutexDestroy());

	staticInitializedFlag = false;

	return NO_ERROR;
}
コード例 #14
0
ファイル: api_device.c プロジェクト: archipelagos/sample
/* INFO: */
int ApiDeviceDestroy() {
	CHECK_INITIALIZED(staticInitializedFlag);

	CHECK(XmlParserDestroyDynamicStructureDevice(
		staticStructuresDynamicDevice));

	staticInitializedFlag = false;

	return NO_ERROR;
}
コード例 #15
0
ファイル: api_device.c プロジェクト: archipelagos/sample
/* INFO: */
int ApiDeviceGetServiceActionCount(
		const unsigned int inpServiceIndex,
		unsigned int * const inpDeviceActionCountBuffer) {
	CHECK_INITIALIZED(staticInitializedFlag);

	(* inpDeviceActionCountBuffer) = staticStructuresDynamicDevice->
		serviceArray[inpServiceIndex].actionCount;

	return NO_ERROR;
}
コード例 #16
0
ファイル: api_device.c プロジェクト: archipelagos/sample
/* INFO: */
int ApiDeviceGetServiceId(
		const unsigned int inpServiceIndex,
		const char ** const inpServiceIdBuffer) {
	CHECK_INITIALIZED(staticInitializedFlag);

	(* inpServiceIdBuffer) = staticStructuresDynamicDevice->
		serviceArray[inpServiceIndex].serviceId;

	return NO_ERROR;
}
コード例 #17
0
ファイル: api_device.c プロジェクト: archipelagos/sample
/* INFO: */
static int ApiDeviceSetActionFunction(
		const unsigned int inpServiceIndex,
		const unsigned int inpActionIndex,
		const StructuresDynamicActionFunction inpActionFunction) {
	CHECK_INITIALIZED(staticInitializedFlag);

	staticStructuresDynamicDevice->serviceArray[inpServiceIndex].
		actionArray[inpActionIndex].function = inpActionFunction;

	return NO_ERROR;
}
コード例 #18
0
ファイル: device_list.c プロジェクト: archipelagos/sample
/* INFO: */
static int DeviceListDestroyNode(StructuresDynamicNode * const inpNode) {
	CHECK_INITIALIZED(staticInitializedFlag);

	CHECK(DeviceListUnsubscribeServices(inpNode->device->serviceArray,
		inpNode->device->serviceCount));
	CHECK(XmlParserDestroyDynamicStructureDevice(inpNode->device));

	free(inpNode->descriptionDocumentURL);
	free(inpNode);

	return NO_ERROR;
}
コード例 #19
0
ファイル: api_device.c プロジェクト: archipelagos/sample
/* INFO: */
int ApiDeviceGetServiceStateVariableValueArray(
		const unsigned int inpServiceIndex,
		char * const ** const inpStateVariableValuesBuffer) {
	CHECK_INITIALIZED(staticInitializedFlag);

	/* TODO: Why casting is used? */
	(* inpStateVariableValuesBuffer) = (char ** const)
		staticStructuresDynamicDevice->serviceArray[inpServiceIndex].
		stateVariableValueArray;

	return NO_ERROR;	
}
コード例 #20
0
ファイル: device_list.c プロジェクト: archipelagos/sample
/* TODO: This is logic funtion. This function should not be stored in this
         scope. */
int DeviceListRefresh() {
	const char * localDeviceType = { 0 };

	CHECK_INITIALIZED(staticInitializedFlag);

	CHECK(DeviceListRemoveAll());
	CHECK(ApiControllerGetDeviceType(& localDeviceType));
	CHECK(HandleControllerSearchAsync(localDeviceType,
		DEVICE_LIST_SEARCH_TIME_INTERVAL));

	return NO_ERROR;
}
コード例 #21
0
ファイル: api_device.c プロジェクト: archipelagos/sample
/* INFO: */
int ApiDeviceGetServiceActionFunction(
		const unsigned int inpServiceIndex,
		const unsigned int inpActionIndex,
		StructuresDynamicActionFunction * const inpActionFunctionBuffer) {
	CHECK_INITIALIZED(staticInitializedFlag);

	(* inpActionFunctionBuffer) = staticStructuresDynamicDevice->
		serviceArray[inpServiceIndex].actionArray[inpActionIndex].
		function;

	return NO_ERROR;
}
コード例 #22
0
ファイル: device_list.c プロジェクト: archipelagos/sample
/* INFO: */
int DeviceListRemoveDevice(const char * const inpUniqueDeviceName) {
	CHECK_INITIALIZED(staticInitializedFlag);

	CHECK(DeviceListMutexLock());
	{
		CHECK(DeviceListRemoveNode(inpUniqueDeviceName));
	}
	CHECK(DeviceListMutexUnlock());

	//CHECK(DeviceListPrintList());

	return NO_ERROR;
}
コード例 #23
0
ファイル: device_list.c プロジェクト: archipelagos/sample
/* INFO: */
static int DeviceListUnsubscribeServices(
		StructuresDynamicService * const inpServiceArray,
		const unsigned int inpServiceCount) {
	unsigned int localServiceIndex = { 0 };
	Upnp_SID * localSubscriptionId = { 0 };

	CHECK_INITIALIZED(staticInitializedFlag);
	
	for(; localServiceIndex < inpServiceCount; ++localServiceIndex) {
		localSubscriptionId = (& inpServiceArray[localServiceIndex].
			subscriptionId);
		
		CHECK(HandleControllerUnsubscribe(* localSubscriptionId));
	}

	return NO_ERROR;
}
コード例 #24
0
ファイル: opengl.cpp プロジェクト: parvizp/Halide
// Release all data allocated by the runtime.
//
// The OpenGL context itself is generally managed by the host application, so
// we leave it untouched.
EXPORT void halide_opengl_release(void *user_context) {
    CHECK_INITIALIZED();
    ST.DeleteShader(ST.vertex_shader_id);
    ST.DeleteFramebuffers(1, &ST.framebuffer_id);

    HalideOpenGLKernel *cur = ST.kernels;
    while (cur) {
        HalideOpenGLKernel *next = cur->next;
        halide_opengl_delete_kernel(user_context, cur);
        cur = next;
    }

    // Delete all textures that were allocated by us.
    HalideOpenGLTexture *tex = ST.textures;
    int freed_textures = 0;
    while (tex) {
        HalideOpenGLTexture *next = tex->next;
        if (tex->halide_allocated) {
            ST.DeleteTextures(1, &tex->id);
            CHECK_GLERROR();
            freed_textures++;
        }
        free(tex);
        tex = next;
    }
#ifdef DEBUG
    if (freed_textures > 0) {
        halide_printf(user_context,
            "halide_opengl_release: deleted %d dangling texture(s).\n",
            freed_textures);
    }
#endif

    ST.DeleteBuffers(1, &ST.vertex_buffer);
    ST.DeleteBuffers(1, &ST.element_buffer);

    ST.vertex_shader_id = 0;
    ST.framebuffer_id = 0;
    ST.vertex_buffer = 0;
    ST.element_buffer = 0;
    ST.kernels = NULL;
    ST.textures = NULL;
    ST.initialized = false;
}
コード例 #25
0
ファイル: api_device.c プロジェクト: archipelagos/sample
/* INFO: */
int ApiDeviceSetServiceStateVariableValue(
		const unsigned int inpServiceIndex,
		const unsigned int inpStateVariableIndex,
		const char * const inpStateVariableValue) {
	char ** localStateVariableValue = { 0 };

	CHECK_INITIALIZED(staticInitializedFlag);

	localStateVariableValue = (& staticStructuresDynamicDevice->
		serviceArray[inpServiceIndex].
		stateVariableValueArray[inpStateVariableIndex]);

	free(* localStateVariableValue);

	(* localStateVariableValue) = UtilsStringDuplicate(
		inpStateVariableValue);

	return NO_ERROR;
}
コード例 #26
0
ファイル: device_list.c プロジェクト: archipelagos/sample
/* TODO: This function should be moved to more "logic" module (maybe
         core_controller)*/
int DeviceListCheckIfWantedDeviceType(const char * const inpDeviceType,
		bool * const inpWantedFlag) {
	const char * localDeviceType = { 0 };
	bool localWantedFlag = { 0 };

	CHECK_INITIALIZED(staticInitializedFlag);

	CHECK(ApiControllerGetDeviceType(& localDeviceType));

	if(! strcmp(inpDeviceType, localDeviceType)) {
		localWantedFlag = true;
	}
	else {
		localWantedFlag = false;
	}

	(* inpWantedFlag) = localWantedFlag;

	return NO_ERROR;
}
コード例 #27
0
ファイル: device_list.c プロジェクト: archipelagos/sample
/* INFO: */
static int DeviceListSubscribeServices(
		StructuresDynamicService * const inpServiceArray,
		const unsigned int inpServiceCount,
		const unsigned int inpAdvertisementTimeout) {
	unsigned int localServiceIndex = { 0 };
	char * localEventSubUrl = { 0 };
	Upnp_SID * localSubscriptionId = { 0 };

	CHECK_INITIALIZED(staticInitializedFlag);

	for(; localServiceIndex < inpServiceCount; ++localServiceIndex) {
		localEventSubUrl = inpServiceArray[localServiceIndex].
			eventSubURL;
		localSubscriptionId = (& inpServiceArray[localServiceIndex].
			subscriptionId);
		
		CHECK(HandleControllerSubscribe(localEventSubUrl,
			inpAdvertisementTimeout, localSubscriptionId));
	}

	return NO_ERROR;
}
コード例 #28
0
ファイル: api_device.c プロジェクト: archipelagos/sample
/* INFO: */
static int ApiDeviceBindActions(
		const unsigned int inpServiceIndex,
		const ApiDeviceActionBind * const inpActionsBindArray,
		const unsigned int inpActionCount) {
	unsigned int inpActionIndex = { 0 };
	const char * localActionName = { 0 };
	StructuresDynamicActionFunction localActionFunction = { 0 };

	CHECK_INITIALIZED(staticInitializedFlag);

	for(; inpActionIndex < inpActionCount; ++inpActionIndex) {
		localActionName = inpActionsBindArray[inpActionIndex].
			actionName;
		localActionFunction = inpActionsBindArray[inpActionIndex].
			actionFunction;

		CHECK(ApiDeviceCreateActionBinding(inpServiceIndex,
			localActionName, localActionFunction));
	}

	return NO_ERROR;
}
コード例 #29
0
ファイル: device_list.c プロジェクト: archipelagos/sample
/* INFO: */
int DeviceListAddDevice(const char * const inpDescriptionDocumentURL,
		const unsigned int inpAdvertisementTimeout) {
	StructuresDynamicNode * localDeviceNode = { 0 };
	StructuresDynamicDevice * localStructuresDynamicDevice = { 0 };

	CHECK_INITIALIZED(staticInitializedFlag);

	CHECK(DeviceListMutexLock());
	{
		CHECK(XmlParserCreateDynamicStructureDeviceOnline(
			inpDescriptionDocumentURL,
			(& localStructuresDynamicDevice)));
		CHECK(DeviceListCreateNode((& localDeviceNode),
			inpDescriptionDocumentURL, inpAdvertisementTimeout,
			localStructuresDynamicDevice));
		CHECK(DeviceListAddNode(localDeviceNode));
	}
	CHECK(DeviceListMutexUnlock());

	//CHECK(DeviceListPrintList());

	return NO_ERROR;
}
コード例 #30
0
ファイル: api_device.c プロジェクト: archipelagos/sample
/* INFO: */
static int ApiDeviceBindServices(
		const ApiDeviceServiceBind * const inpServicesBindArray,
		const unsigned int inpServiceCount) {
	unsigned int inpServiceIndex = { 0 };
	const ApiDeviceActionBind * localActionsBindArray = { 0 };
	unsigned int localActionsBindArraySize = { 0 };

	CHECK_INITIALIZED(staticInitializedFlag);

	for(; inpServiceIndex < inpServiceCount; ++inpServiceIndex) {
		localActionsBindArray =
			inpServicesBindArray[inpServiceIndex].
			actionsBindArray;
		localActionsBindArraySize =
			inpServicesBindArray[inpServiceIndex].
			actionsBindArraySize;

		CHECK(ApiDeviceBindActions(inpServiceIndex,
			localActionsBindArray, localActionsBindArraySize));
	}

	return NO_ERROR;
}