Exemplo n.º 1
0
/*====================================================================*/
int freeProgram(DFHEIBLK *inDfheiptr,
                TraceParms* inTraceParms,
                CICSProgramDesc* pProgramDesc,
                Message* pRequestMessage,
                Message* pResponseMessage) {

    int rc = OK_CODE;
    dfheiptr = inDfheiptr;
    g_pTraceParms = inTraceParms;
    initLog(dfheiptr, inTraceParms);

    if (strlen(pProgramDesc->CICSChannel) > 0
        && pProgramDesc->CICSChannel[0] != ' ') {
        rc = freeChannel(dfheiptr,
                         g_pTraceParms,
                         pProgramDesc,
                         pRequestMessage,
                         pResponseMessage);
    } else {
        rc = freeCommarea(dfheiptr,
                          g_pTraceParms,
                          pProgramDesc,
                          pRequestMessage,
                          pResponseMessage);
    }
    return rc;
}
Exemplo n.º 2
0
KNMusicBackendBassThread::~KNMusicBackendBassThread()
{
    //Stop the position updater.
    m_positionUpdater->stop();
    //Clear up the channel sync handle.
    removeChannelSyncs();
    //Free the channel.
    freeChannel();
}
Exemplo n.º 3
0
int mycudaCompute()
{
    // ri scrivo la funzione di update presente in dll "seriale"
    // utilizzando "GPUCompute(boidSet)" come chiamata cuda anzichè la normale "compute()"

    unsigned int simulationLenght,progress;
    int exitValue;

    int test=0;

    progress=0;
    simulationLenght=(unsigned int)ceil(simParameters.fps * simParameters.lenght);

    _Output(&cacheFileOption);

    while((!abortSimulation) && (progress<=simulationLenght))
    {
        Channel *channels;

        channels=(Channel*)malloc(sizeof(Channel)*info.option);

        GPUCompute(boidSet);

        // data management
        cachingData(channels);

        // write data
        writeData(progress,channels);

        // update the index job progress
        simulationProgress = ((int)(100*progress)/simulationLenght);

        //advance to the next frame
        progress++;
        test++;
        // free channels memory
        freeChannel(channels);
    }

    simulationProgress=100;

    closeMethod();
    if(abortSimulation)
    {
        printf("Simulation interrupted\n");
        deleteData();
        exitValue=INTERRUPTED_SIM;
    }
    // restoring abortSimulation flag
    abortSimulation=FALSE;
    exitValue=SUCCESS_SIM;

    // free resources
    free(boidSet);
    return exitValue;
}
Exemplo n.º 4
0
void SoundManager::freeChannel(ChannelHandle &handle) {
	if ((handle.channel != 0) && (handle.id != 0) && _channels[handle.channel])
		// Only free if there is a channel to free
		if (handle.id == _channels[handle.channel]->id)
			// Only free if the IDs match
			freeChannel(handle.channel);

	handle.channel = 0;
	handle.id      = 0;
}
Exemplo n.º 5
0
// update simulation
void  update()
{
	unsigned int simulationLenght,progress;
	
	progress=0;
	simulationLenght=(unsigned int)ceil(simParameters.fps * simParameters.lenght);

	_Output(&cacheFileOption);
	
	while((!abortSimulation) && (progress<=simulationLenght))
	{
		Channel *channels;
		channels=(Channel*)malloc(sizeof(Channel)*info.option);

		// compute Boids' new positions, velocities, accelerations 
		compute();

		// data management
		cachingData(channels);

		// write data
		writeData(progress,channels);

		// update Boids properties and kdtree 
		updateBoids();

		// update the index job progress 
		simulationProgress = ((int)(100*progress)/simulationLenght);

		//advance to the next frame
		progress++;

		// free channels memory
		freeChannel(channels);
	}

	simulationProgress=100;
	
	closeMethod();
	if(abortSimulation)
	{
		printf("Simulation interrupted\n");
		deleteData();
	}
	// restoring abortSimulation flag
	abortSimulation=FALSE;

	// free resources
	free(boidSet);	
	kd_free(k3);
}
Exemplo n.º 6
0
void KNMusicBackendBassThread::save()
{
    //Pause the thread first.
    BASS_ChannelPause(m_channel);
    //Stop the updater.
    m_positionUpdater->stop();
    //Save the position of the current thread.
    m_savedPosition=position();
    //Reset the current playing thread, but saved all the other parameter.
    //Clear up the channel sync handle.
    removeChannelSyncs();
    //Check if the channel is not null.
    freeChannel();
}
Exemplo n.º 7
0
void SoundManager::update() {
	Common::StackLock lock(_mutex);

	for (int i = 1; i < kChannelCount; i++) {
		if (!_channels[i])
			continue;

		// Free the channel if it is no longer playing
		if (!isPlaying(i)) {
			freeChannel(i);
			continue;
		}

		// Try to buffer some more data
		bufferData(i);
	}
}
Exemplo n.º 8
0
void KNMusicBackendBassThread::reset()
{
    //Stop the position updater.
    m_positionUpdater->stop();
    //Clear up the channel sync handle.
    removeChannelSyncs();
    //Check if the channel is not null.
    freeChannel();
    //Reset the channel data.
    m_filePath.clear();
    //Reset the total duration.
    m_totalDuration=-1;
    //Reset the stream status data.
    resetChannelInformation();
    //Check the current state is stopped or not.
    setPlayingState(Stopped);
}
Exemplo n.º 9
0
void SoundManager::deinit() {
	if (!_ready)
		return;

	if (!destroyThread())
		warning("SoundManager::deinit(): Sound thread had to be killed");

	for (uint16 i = 1; i < kChannelCount; i++)
		freeChannel(i);

	if (_hasSound) {
		alcMakeContextCurrent(0);
		alcDestroyContext(_ctx);
		alcCloseDevice(_dev);
	}

	_ready = false;
}
Exemplo n.º 10
0
void SoundManager::stopAll() {
	Common::StackLock lock(_mutex);

	for (uint16 i = 1; i < kChannelCount; i++)
		freeChannel(i);
}
Exemplo n.º 11
0
void SoundManager::stopChannel(ChannelHandle &handle) {
	Common::StackLock lock(_mutex);

	freeChannel(handle);
}
Exemplo n.º 12
0
ChannelHandle SoundManager::playAudioStream(AudioStream *audStream, SoundType type, bool disposeAfterUse) {
	assert((type >= 0) && (type < kSoundTypeMAX));

	checkReady();

	if (!audStream)
		throw Common::Exception("No audio stream");

	Common::StackLock lock(_mutex);

	ChannelHandle handle = newChannel();

	_channels[handle.channel] = new Channel;
	Channel &channel = *_channels[handle.channel];

	channel.id              = handle.id;
	channel.state           = AL_PAUSED;
	channel.stream          = audStream;
	channel.source          = 0;
	channel.disposeAfterUse = disposeAfterUse;
	channel.type            = type;
	channel.typeIt          = _types[channel.type].list.end();
	channel.gain            = 1.0;

	try {

		if (!channel.stream)
			throw Common::Exception("Could not detect stream type");

		ALenum error = AL_NO_ERROR;

		if (_hasSound) {
			// Create the source
			alGenSources(1, &channel.source);
			if ((error = alGetError()) != AL_NO_ERROR)
				throw Common::Exception("OpenAL error while generating sources: %X", error);

			// Create all needed buffers
			for (int i = 0; i < kOpenALBufferCount; i++) {
				ALuint buffer;

				alGenBuffers(1, &buffer);
				if ((error = alGetError()) != AL_NO_ERROR)
					throw Common::Exception("OpenAL error while generating buffers: %X", error);

				if (fillBuffer(channel.source, buffer, channel.stream)) {
					// If we could fill the buffer with data, queue it

					alSourceQueueBuffers(channel.source, 1, &buffer);
					if ((error = alGetError()) != AL_NO_ERROR)
						throw Common::Exception("OpenAL error while queueing buffers: %X", error);

				} else
					// If not, put it into our free list
					channel.freeBuffers.push_back(buffer);

				channel.buffers.push_back(buffer);
			}

			// Set the gain to the current sound type gain
			alSourcef(channel.source, AL_GAIN, _types[channel.type].gain);
		}

		// Add the channel to the correct type list
		_types[channel.type].list.push_back(&channel);
		channel.typeIt = --_types[channel.type].list.end();

	} catch (...) {
		freeChannel(handle);
		throw;
	}

	return handle;
}
Exemplo n.º 13
0
void EMISound::freeAllChannels() {
	for (int i = 0; i < NUM_CHANNELS; i++) {
		freeChannel(i);
	}
}
Exemplo n.º 14
0
void EMISound::stopSound(const char *soundName) {
	int32 channel = getChannelByName(soundName);
	assert(channel != -1);
	g_system->getMixer()->stopHandle(*_channels[channel]->getHandle());
	freeChannel(channel);
}