SFML community forums

Help => Audio => Topic started by: TheMagicNumber on November 07, 2010, 09:04:44 am

Title: sf::Sound destructor crash
Post by: TheMagicNumber on November 07, 2010, 09:04:44 am
I've been getting this issue with sf::Sound with my outdated SFML2 and just updated it, but I still have the problem. I don't know why it's happening but it sure is a problem.

Whenever I use sf::Sound (I haven't checked others) the program always crashes when it is released from memory: http://i.imgur.com/V3kia.png However, sometimes if given some time, it will just leave a thread running and keep the program open.

Here's the code I'm using:
Code: [Select]
#include <iostream>
#include <SFML/Audio.hpp>

int main()
{
sf::SoundBuffer sb;

if (!sb.LoadFromFile("piano3.ogg"))
return 0;

sf::Sound snd(sb);
snd.Play();

while (snd.GetStatus() == sf::Sound::Playing)
sf::Sleep(0.01f);

return 0;
}


Although just this would replicate the problem:
Code: [Select]
#include <iostream>
#include <SFML/Audio.hpp>

int main()
{
sf::Sound snd;
snd.GetStatus(); // don't let it optimize out!
return 0;
}


I haven't done much with audio so I don't know if I'm doing anything wrong.
Title: sf::Sound destructor crash
Post by: Laurent on November 07, 2010, 10:25:09 am
Make sure that you use the openal32 DLL from the SFML SDK, and that you don't have another one that conflicts (like in Windows\System32).
Title: sf::Sound destructor crash
Post by: TheMagicNumber on November 07, 2010, 07:26:17 pm
I am using the one from the SFML SDK.
Title: sf::Sound destructor crash
Post by: TheMagicNumber on November 10, 2010, 09:37:09 pm
Nothing? Is SFML's Audio useless for me?
Title: sf::Sound destructor crash
Post by: Spodi on November 10, 2010, 09:53:03 pm
Does it happen just when the program closes, or any time that the audio is destroyed? Did this happen with SFML 1.6? Do the SFML samples work for you?
Title: sf::Sound destructor crash
Post by: TheMagicNumber on November 10, 2010, 09:57:04 pm
Any time a sound is destroyed.
SFML2 (downloaded a few days ago, updating did not fix it)
Samples, didn't try, I see no reason why it would work.

I've once got it to show where it crashed and it showed a line that had alcCloseDevice called.
Title: sf::Sound destructor crash
Post by: Rock_Hardbuns on November 10, 2010, 10:43:16 pm
Well, it's a memory error. Could be a simple array index thing.

Could be an allocation thing. Does it happen if you go
Code: [Select]

sf::Sound* snd = new sf::Sound();
snd->GetStatus(); // don't let it optimize out!
delete snd;
return 0;
Title: sf::Sound destructor crash
Post by: Spodi on November 10, 2010, 11:17:10 pm
Just noticed the error says its trying to read address 0xFEEEFEEE, which indicates it is freed heap memory (http://tinyurl.com/5bdzsf). Though why it would be happening... not sure.
Title: sf::Sound destructor crash
Post by: TheMagicNumber on November 11, 2010, 01:37:16 am
Yes, I've tried allocating it on the heap. Same thing. I'm going to try using sf::Music to see if it does the same thing.

Yup, same thing. Any other suggestions?

Oh, and the heap allocation actually does something different but may help a bit. It doesn't crash until the program ends.
Title: sf::Sound destructor crash
Post by: Laurent on November 11, 2010, 09:28:26 am
Have you tried the SDK examples? If they don't work, then there's definitely a problem with your environment. What OS and compiler do you use? Are you sure that you don't have an OpenAL DLL hidden somewhere that may conflict?
Title: sf::Sound destructor crash
Post by: TheMagicNumber on November 11, 2010, 01:43:44 pm
The sound example did work, but it built statically. I couldn't even get anything to build as static due to BS linker errors.

VC++ 2008 Express on Windows 7 x64

There is absolutely no conflict, if I do not copy the DLL to a directory where the binary can find it, I get an error.

I'm pretty sure this has something to do with me failing with CMake now. I'm going to delete this SFML download and redownload it, hopefully someone can help me get a decent way of using CMake (no the tutorial on the site only helped...).
Title: sf::Sound destructor crash
Post by: Groogy on November 11, 2010, 02:26:25 pm
Why you get linker errors when statically linking it is possibly because of that you haven't declared the define SFML_STATIC
Title: sf::Sound destructor crash
Post by: dvoid on April 28, 2011, 02:16:31 pm
Im having the same problem,
using openal32.dll from sfml svn.
crashes on alcCloseDevice.
the occurs only when something has accessed the sound system so the device
has been created.. (i just created a soundbuffer and then released it again).
this seems to happen only on XP , seems to work fine on vista anyway.

tried to use the latest version of openal_soft (i rebuilt sfml with it). but that did not make any difference.
Title: sf::Sound destructor crash
Post by: dvoid on April 29, 2011, 03:48:39 pm
correction:
it crashes in alcDestroyContext(audioContext);
Title: sf::Sound destructor crash
Post by: floflo on May 01, 2011, 01:45:44 pm
This issue has already been recorded.
You can see it here:https://github.com/SFML/SFML/issues/30