1
Audio / Crashing on loading a sound
« on: May 06, 2011, 07:30:46 pm »Quote from: "Laurent"
What was the problem?
vc++2010, I had to compile the libs again
thank you,
your sfml is just awesome!
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
What was the problem?
QuoteI'm compiling in release mode, the libs to use are sfml-audio-s.lib and sfml-system-s.lib, aren't they?
Yes.
You should compile in debug mode and run the debugger, it will tell you what's wrong
Also, make sure that your version of Visual Studio matches the one of the libs that you're using (for example VC++ 2010 can't use VC++ 2008 libraries).
Code: [Select]buffer->~SoundBuffer();
You must never call a destructor explicitely. Here you must call delete, since you allocated the object with new.
int SoundManager::LoadSound(string strFileName)
{
sf::SoundBuffer *buffer = new sf::SoundBuffer();
if (!buffer->LoadFromFile(strFileName))
{
buffer->~SoundBuffer();
return -1;
}
for (size_t i = 0; i < m_buffers.size(); i++)
{
if (!m_buffers[i])
{
m_buffers[i] = buffer;
return i;
}
}
m_buffers.push_back(buffer);
return m_buffers.size() - 1;
//return 0;
}