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

Author Topic: Static sf::Sound cause the application to crash on MAC  (Read 2590 times)

0 Members and 1 Guest are viewing this topic.

Carlo Meroni

  • Newbie
  • *
  • Posts: 13
    • View Profile
    • Email
Static sf::Sound cause the application to crash on MAC
« on: September 26, 2014, 08:34:21 pm »
Hi,

While I was creating a game on Mac OS X I noticed that if I declare a static sf :: Sound variable and I set a SoundBuffer to it, then when I close the application it crash with bad errors.
The problem is in the sf::Sound destructor.
On windows everything works fine (with visual studio compiler).

Here is minimal code example:
//=======================
#include <SFML/Window.hpp>
#include <SFML/Audio.hpp>
#include <map>

//=======================
#include "ResourcePath.hpp"

//======================
using namespace sf;

//static sound declaration
static sf::Sound snd;

int main()
{
    sf::Window win;
        win.create(VideoMode(1100, 700), "TEST", Style::Titlebar | Style::Close);
        win.setVerticalSyncEnabled(true);

    sf::SoundBuffer sndb;
    sndb.loadFromFile(resourcePath() + "Greenkey.wav");
    snd.setBuffer(sndb);
    snd.play();

        while (win.isOpen())
        {
                Event ev;
                while (win.pollEvent(ev)) {
                        switch (ev.type) {
                        case Event::Closed:
                                win.close();
                                break;
                        }
                }

                win.display();
        }

        return EXIT_SUCCESS;
}
 

Here is what XCode says:
https://www.dropbox.com/s/qgy36in0bjkytbp/Prove.png?dl=0

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Static sf::Sound cause the application to crash on MAC
« Reply #1 on: September 26, 2014, 10:33:02 pm »
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

 

anything