Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sf::Sound destructor crash  (Read 9747 times)

0 Members and 1 Guest are viewing this topic.

TheMagicNumber

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
sf::Sound destructor crash
« 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::Sound destructor crash
« Reply #1 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).
Laurent Gomila - SFML developer

TheMagicNumber

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
sf::Sound destructor crash
« Reply #2 on: November 07, 2010, 07:26:17 pm »
I am using the one from the SFML SDK.

TheMagicNumber

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
sf::Sound destructor crash
« Reply #3 on: November 10, 2010, 09:37:09 pm »
Nothing? Is SFML's Audio useless for me?

Spodi

  • Full Member
  • ***
  • Posts: 150
    • View Profile
    • http://www.netgore.com/
sf::Sound destructor crash
« Reply #4 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?

TheMagicNumber

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
sf::Sound destructor crash
« Reply #5 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.

Rock_Hardbuns

  • Newbie
  • *
  • Posts: 10
    • View Profile
sf::Sound destructor crash
« Reply #6 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;

Spodi

  • Full Member
  • ***
  • Posts: 150
    • View Profile
    • http://www.netgore.com/
sf::Sound destructor crash
« Reply #7 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. Though why it would be happening... not sure.

TheMagicNumber

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
sf::Sound destructor crash
« Reply #8 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::Sound destructor crash
« Reply #9 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?
Laurent Gomila - SFML developer

TheMagicNumber

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
sf::Sound destructor crash
« Reply #10 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...).

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
sf::Sound destructor crash
« Reply #11 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
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

dvoid

  • Newbie
  • *
  • Posts: 7
    • View Profile
sf::Sound destructor crash
« Reply #12 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.

dvoid

  • Newbie
  • *
  • Posts: 7
    • View Profile
sf::Sound destructor crash
« Reply #13 on: April 29, 2011, 03:48:39 pm »
correction:
it crashes in alcDestroyContext(audioContext);

floflo

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
sf::Sound destructor crash
« Reply #14 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