SFML community forums

Help => Audio => Topic started by: Dante12129 on May 19, 2013, 02:00:30 am

Title: Memory leak with music
Post by: Dante12129 on May 19, 2013, 02:00:30 am
I am trying to load a music file. Loading and playing and using it work fine, but when I have an sf::Music object in my program, it gives me a return status of -2147418113.

Here's my code:
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>

int main()
{
        sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");

        sf::Music background_music;
        background_music.openFromFile("Five Armies.ogg");

        while (window.isOpen())
        {
            //Handle events
                sf::Event event;
                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                                window.close();
                }
                //Logic

                //Render
        }

        return 0;
}

 

I am using MinGW 4.7.1 on Windows 7 with Code::Blocks as my IDE.

I have narrowed it down to the music because if I comment out the music and loading it will work without leaking. And it gives me the same return value whether I play it or not.
Title: Re: Memory leak with music
Post by: eigenbom on May 19, 2013, 02:34:31 am
Might be related to this: https://github.com/SFML/SFML/issues/30 (https://github.com/SFML/SFML/issues/30)
Title: Re: Memory leak with music
Post by: Dante12129 on May 19, 2013, 03:28:18 am
But that says that it's not a problem for Windows 7. Also, here's my call stack from gdb:

(http://i39.tinypic.com/33onpr4.png)
Title: Re: Memory leak with music
Post by: eXpl0it3r on May 20, 2013, 04:07:29 pm
Are you mixing debug and release modes?

I am trying to load a music file. Loading and playing and using it work fine, but when I have an sf::Music object in my program, it gives me a return status of -2147418113.
When exactly do you get the crash? Is it while loading or really just when you close the application?
If it's when closing then it really might be issue #30 or outdated audio drivers...

Besides this is not really called a memory leak, this is a crash. ;)
Title: Re: Memory leak with music
Post by: Dante12129 on May 21, 2013, 12:07:05 am
Well it runs fine and never crashes, so I guess it is an audio driver (the hardware in my computer is a few years old, like I have integrated graphics that only support OpenGL 2.0).