예제 #1
0
	void SimpleAudioEngine::end()
	{
		checkALError("end");

		// clear all the sounds
	    EffectsMap::const_iterator end = s_effects.end();
	    for (EffectsMap::iterator it = s_effects.begin(); it != end; it++)
	    {
	        alSourceStop(it->second->source);
	        checkALError("end");
			alDeleteBuffers(1, &it->second->buffer);
			checkALError("end");
			alDeleteSources(1, &it->second->source);
			checkALError("end");
			delete it->second;
	    }
	    s_effects.clear();

		// and the background too
		stopBackground(true);

		for (BackgroundMusicsMap::iterator it = s_backgroundMusics.begin(); it != s_backgroundMusics.end(); ++it)
		{
			alSourceStop(it->second->source);
			checkALError("end");
			alDeleteBuffers(1, &it->second->buffer);
			checkALError("end");
			alDeleteSources(1, &it->second->source);
			checkALError("end");
			delete it->second;
		}
		s_backgroundMusics.clear();
	}
예제 #2
0
	void SimpleAudioEngine::stopBackgroundMusic(bool bReleaseData)
	{
    	// if we were paused then we need to resume first so that we can play
		if (s_playStatus == PAUSED)
			resumeBackgroundMusic();

		stopBackground(bReleaseData);
	}
예제 #3
0
void SoundHandler::enableSound(bool enable) {
	_sound = enable;
	CCUserDefault::sharedUserDefault()->setBoolForKey("soundIsEnabled", _sound);

	if (_sound)
		playBackground(_currentBackgroundMusic, true);
	else
		stopBackground();
}
void SimpleAudioEngine::stopBackgroundMusic(bool bReleaseData)
{
    // If there is no source, then there is nothing that can be stopped
    if (s_backgroundSource == AL_NONE)
        return;

    ALint state;
    alGetSourcei(s_backgroundSource, AL_SOURCE_STATE, &state);
    if (state == AL_PLAYING)
        stopBackground(bReleaseData);
}
void SimpleAudioEngine::end()
{
    checkALError("end:init");

    // clear all the sound effects
    EffectsMap::const_iterator end = s_effects.end();
    for (auto it = s_effects.begin(); it != end; ++it)
    {
        alSourceStop(it->second->source);
        checkALError("end:alSourceStop");

        alDeleteSources(1, &it->second->source);
        checkALError("end:alDeleteSources");

        alDeleteBuffers(1, &it->second->buffer);
        checkALError("end:alDeleteBuffers");

        delete it->second;
    }
    s_effects.clear();

    // and the background music too
    stopBackground(true);

    for (auto it = s_backgroundMusics.begin(); it != s_backgroundMusics.end(); ++it)
    {
        alSourceStop(it->second->source);
        checkALError("end:alSourceStop");

        alDeleteSources(1, &it->second->source);
        checkALError("end:alDeleteSources");

        alDeleteBuffers(1, &it->second->buffer);
        checkALError("end:alDeleteBuffers");

        delete it->second;
    }
    s_backgroundMusics.clear();

    CC_SAFE_DELETE(s_engine);
}
	void SimpleAudioEngine::end()
	{
		// clear all the sounds
	    EffectsMap::const_iterator end = s_effects.end();
	    for (EffectsMap::iterator it = s_effects.begin(); it != end; it++)
	    {
            Mix_FreeChunk(it->second->chunk);
			delete it->second;
	    }
	    s_effects.clear();

		// and the background too
		stopBackground(true);

		for (BackgroundMusicsMap::iterator it = s_backgroundMusics.begin(); it != s_backgroundMusics.end(); ++it)
		{
            Mix_FreeMusic(it->second->music);
			delete it->second;
		}
		s_backgroundMusics.clear();
	}
예제 #7
0
	void SimpleAudioEngine::end()
	{
		// clear all the sounds
	    EffectsMap::const_iterator end = s_effects.end();
	    for (EffectsMap::iterator it = s_effects.begin(); it != end; it++)
	    {
	        alSourceStop(it->second->source);

			alDeleteBuffers(1, &it->second->buffer);
			alDeleteSources(1, &it->second->source);
			delete it->second;
	    }
	    s_effects.clear();

		if (s_isBackgroundInitialized)
		{
			s_isBackgroundInitialized = false;
		}

		// and the background too
		stopBackground(true);
	}
예제 #8
0
	void SimpleAudioEngine::stopBackgroundMusic(bool bReleaseData)
	{
		stopBackground(bReleaseData);
	}