61
Audio / Sounds stop suddenly
« on: August 22, 2010, 06:32:08 pm »
Im using SFML v1.5
I have the same problem... and i try delete instace but.. SFML fail.. :\ (me fail but... xDDD)
I have this:
In this code.... "pos" never is == to "duration" :S
This code delete the sound more fast... (NO LISTEN SOUND :S)
I add new sound with:
Help me pls!
I have the same problem... and i try delete instace but.. SFML fail.. :\ (me fail but... xDDD)
I have this:
Code: [Select]
std::deque<sf::Sound*>::iterator it = sounds.begin();
while(it != sounds.end())
{
const sf::SoundBuffer *sbuffer = (*it)->GetBuffer();
float duration = sbuffer->GetDuration();
float pos = (*it)->GetPlayingOffset();
if (pos == duration)
{
delete((*it));
(*it) = 0x0;
it = sounds.erase(it);
}
else
++it;
}
In this code.... "pos" never is == to "duration" :S
Code: [Select]
std::deque<sf::Sound*>::iterator it = sounds.begin();
while(it != sounds.end())
{
if ((*it)->GetStatus() == sf::Sound::Stopped)
{
delete((*it));
(*it) = 0x0;
it = sounds.erase(it);
}
else
++it;
}
This code delete the sound more fast... (NO LISTEN SOUND :S)
I add new sound with:
Code: [Select]
void CEngine::playSound(int sound_type)
{
sf::Sound *sound;
switch(sound_type)
{
case SOUND_FIRE:
{
sound = new sf::Sound(snd_fire01);
} break;
case SOUND_IMPACT:
{
sound = new sf::Sound(snd_impact01);
} break;
case SOUND_JUMP:
{
sound = new sf::Sound(snd_jump);
} break;
case SOUND_HURT:
{
sound = new sf::Sound(snd_hurt01);
} break;
case SOUND_FX1:
{
sound = new sf::Sound(snd_fx01);
} break;
default:
return;
}
sound->Play();
sounds.push_back(sound);
}
Help me pls!