SFML community forums
Help => Audio => Topic started 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: #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:#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.
-
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).
-
I am using the one from the SFML SDK.
-
Nothing? Is SFML's Audio useless for me?
-
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?
-
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.
-
Well, it's a memory error. Could be a simple array index thing.
Could be an allocation thing. Does it happen if you go
sf::Sound* snd = new sf::Sound();
snd->GetStatus(); // don't let it optimize out!
delete snd;
return 0;
-
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.
-
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.
-
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?
-
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...).
-
Why you get linker errors when statically linking it is possibly because of that you haven't declared the define SFML_STATIC
-
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.
-
correction:
it crashes in alcDestroyContext(audioContext);
-
This issue has already been recorded.
You can see it here:https://github.com/SFML/SFML/issues/30