Example #1
0
bool OscHandler::InitReceiveConnection( int a_port_num )
{
	m_socket.bindTo( a_port_num );

	if ( !m_socket.isOk() )
	{
		MESSAGE_BOX("Socket Bind Failed", "Cannot bind to socket %d", a_port_num );
		LOG( "Cannot bind to socket %d", a_port_num );
		HALT_ERROR();
		return false;
	}

	return true;
}
Example #2
0
	PRIVATE RETCODE MemCollectBytes (Dword numBytes)
	{
#ifdef _DEBUG	// Error checking
		if (MemHead->FreeBytes + numBytes > MEMPOOL_SIZE)//GetMemPoolSize ())	// Check whether collection may be processed
		{
			MESSAGE_BOX("Overflow: MemCollectBytes failed","Error");
			return MEMCODE_OVERFLOW;
			// Return overflow code
		}
#endif	// _DEBUG

		MemHead->FreeBytes += numBytes;	// Increment count of free bytes

		return RETCODE_SUCCESS;
		// Return success
	}
Example #3
0
	PRIVATE RETCODE MemAllotBytes (Dword numBytes)
	{
#ifdef _DEBUG	// Error checking
		if (MemHead->FreeBytes < numBytes)	// Check whether allotment may be processed
		{
			MESSAGE_BOX("Out of memory: MemAllotBytes failed","Error");
			return MEMCODE_OUTOFMEMORY;
			// Return out of memory code
		}
#endif	// _DEBUG

		MemHead->FreeBytes -= numBytes;	// Decrement count of free bytes

		return RETCODE_SUCCESS;
		// Return success
	}
Example #4
0
void CLKernel::Init()
{
	Deinit();

	cl_context & ctx = CLManager::Get()->GetContext();
	const cl_device_id *device = &(CLManager::Get()->GetDeviceId());

	cl_int ciErrNum;	// Error code var

	printf("CL Compiling file '%s', kernel '%s'....\n", m_filename.c_str(), m_kernelName.c_str() );

	while (true)
	{
		int numBytes;          // Byte size of kernel code
		const char * cSourceCL = ::TextFileRead( m_filename.c_str(), &numBytes );

		// Create the program
		size_t programSize = numBytes;
		m_clProgram = clCreateProgramWithSource(ctx, 1, (const char **)&cSourceCL, &programSize, &ciErrNum);
		CHECK_CL(ciErrNum);

		delete[] cSourceCL;

		// build program
		ciErrNum = clBuildProgram(m_clProgram, 1, device, NULL, NULL, NULL);
		if (ciErrNum != CL_SUCCESS)
		{
			size_t len;
			char buffer[4096];
			clGetProgramBuildInfo(m_clProgram, CLManager::Get()->GetDeviceId(), CL_PROGRAM_BUILD_LOG, sizeof(buffer), buffer, &len);
			MESSAGE_BOX("CL Compile Error", "CL '%s'\nCompile Error: %s", m_filename.c_str(), buffer );
		}
		else
		{
			printf("CL Compiled file '%s', kernel '%s' successfully!\n", m_filename.c_str(), m_kernelName.c_str() );
			// compiled successfully, quit!
			break;
		}
	}

	// create kernel
	m_clKernel = clCreateKernel(m_clProgram, m_kernelName.c_str(), &ciErrNum);
	CHECK_CL(ciErrNum);
}
Example #5
0
	PUBLIC RETCODE MemAlloc (void ** memory, Dword numBytes)
	{
		assert(memory);	// Verify that memory points to valid memory

		MALLOC(*memory,Byte,numBytes);
		// Allocate requested amount of memory

		if (*memory == NULL)	// Ascertain that malloc succeeded
		{
			MESSAGE_BOX("Unable to allocate memory: MemAlloc failed","Error");
			return MEMCODE_OUTOFMEMORY;
			// Return out of memory code
		}

		++MemHead->NumAllocs;	// Increment count of active allocations

		return RETCODE_SUCCESS;
		// Return success
	}
Example #6
0
	PROTECTED RETCODE MemTerm (void)
	{
		if (MemHead->NumAllocs != 0)	// Ascertain that allocations have been freed
		{
			char buf [MAXCHARBUFF];

			sprintf (buf, "Memory leak, %d unfreed allocations: MemTerm failed", MemHead->NumAllocs);
			assert(0);

			MESSAGE_BOX(buf,"Error");
			
			return MEMCODE_MEMORYLEAK;
			// Return memory leak code
		}

		FREE(MemHead);
		// Deallocate memory

		return RETCODE_SUCCESS;
		// Return success
	}
Example #7
0
	PROTECTED RETCODE MemInit (void)
	{
		MALLOC(MemHead,MEMHEAD,sizeof(MEMHEAD) + MEMPOOL_SIZE);//GetMemPoolSize ());
		// Allocate memory for memory

		if (!MemHead)	// Ascertain that malloc succeeded
		{
			MESSAGE_BOX("Unable to allocate memory: MemInit failed","Error");
			return MEMCODE_OUTOFMEMORY;
			// Return out of memory code
		}

		MemHead->MemBlocks = (PMEMBLOCK) MemHead->Memory;	// Point MemBlocks field at Memory field
		MemHead->NumAllocs = 0;								// Set number of allocations to 0
	 
		MemHead->FreeBytes = MEMPOOL_SIZE;//GetMemPoolSize ();	// Set free bytes to pool size amount

		MemHead->MemBlocks->Next = NULL;				// Nullify Next field of MemBlocks
		MemHead->MemBlocks->Size = MEMPOOL_SIZE; //GetMemPoolSize ();	// Set Size field of MemBlocks to pool size amount

		return RETCODE_SUCCESS;
		// Return success
	}