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

Author Topic: 2.6.2 to 3.0 WSAPI  (Read 1770 times)

0 Members and 2 Guests are viewing this topic.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11145
    • View Profile
    • development blog
    • Email
Re: 2.6.2 to 3.0 WSAPI
« Reply #15 on: February 18, 2025, 07:21:44 am »
Someone else just reported that same warning and it turned out, that they destroyed the only sf::Sound instance while still trying to play aduio, which will destroy the audio device likely leading to the given warning.

Make sure your sf::Sound and sf::Music instances exist for as long as you're using them to play audio.
Official FAQ: https://www.sfml-dev.org/faq/
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

HeinzK

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
    • ZwiAner
    • Email
Re: 2.6.2 to 3.0 WSAPI
« Reply #16 on: February 18, 2025, 09:13:44 am »
The trees, that obstruct the view on the forest, can be allowed to fall! (Die Bäume, die die Sicht auf einen Wald versperren, dürfen gefällt werden!)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11145
    • View Profile
    • development blog
    • Email
Re: 2.6.2 to 3.0 WSAPI
« Reply #17 on: February 19, 2025, 08:40:47 am »
With so much manual memory & lifetime management, it's going to be really hard to tell what is correct and what could cause some lost reference (i.e. memory leak).

If you can rebuild SFML, you could uncomment the // #define MA_DEBUG_OUTPUT line in Miniaudio.cpp which will give you more information on what miniaudio is doing.
Official FAQ: https://www.sfml-dev.org/faq/
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Hapax

  • Hero Member
  • *****
  • Posts: 3402
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: 2.6.2 to 3.0 WSAPI
« Reply #18 on: February 19, 2025, 07:22:06 pm »
Does this work (without that error)?
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>

int main()
{
        sf::SoundBuffer* pSb{};
        sf::Sound* pSd{};

        pSb = new sf::SoundBuffer{};
        if (!pSb->loadFromFile("D:/resources/audio/music/Shiny Toy Guns - You Are The One.ogg"))
                return EXIT_FAILURE;

        pSd = new sf::Sound(*pSb);

        pSd->play();



        sf::RenderWindow window(sf::VideoMode({ 960u, 540u }), "");
        while (window.isOpen())
        {
                while (const auto event{ window.pollEvent() })
                {
                        if (event->is<sf::Event::Closed>())
                                window.close();
                        else if (const auto * keyPressed{ event->getIf<sf::Event::KeyPressed>() })
                        {
                                switch (keyPressed->code)
                                {
                                case sf::Keyboard::Key::Escape:
                                        window.close();
                                        break;
                                }
                        }
                }



                window.clear();
                //window.draw();
                window.display();
        }
}
 

It's based on your code and seems to be what it does.
Obviously, you'd need to insert a filename that is valid for you ;)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*