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

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

0 Members and 1 Guest are viewing this topic.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11154
    • 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: 68
    • 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: 11154
    • 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: 3410
  • 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*

HeinzK

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
    • ZwiAner
    • Email
Re: 2.6.2 to 3.0 WSAPI
« Reply #19 on: February 25, 2025, 02:03:54 pm »
... I have added a text output to the sound loading loop.
... the sounds are all present and work after loading during the game.
... the warning comes 3* and only after the first sound:
Quote
Sound<V:/VCke/_KKlang/_KKrach/SoundLaden1.ogg>
miniaudio WARNING: [WASAPI] Failed to find suitable device format for device info retrieval.
miniaudio WARNING: [WASAPI] Failed to find suitable device format for device info retrieval.
miniaudio WARNING: [WASAPI] Failed to find suitable device format for device info retrieval.
Sound<V:/VCke/_KKlang/_KKrach/Warnung.ogg>
Sound<V:/VCke/_KKlang/_KKrach/Achtung.ogg>
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: 11154
    • View Profile
    • development blog
    • Email
Re: 2.6.2 to 3.0 WSAPI
« Reply #20 on: February 25, 2025, 09:49:48 pm »
We lack some information to determine the underlying issue.

I suggest to try Hapax's example code and see if it produces the same error.

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 ;)


And otherwise try to enable miniaudio debug information to get more clarity on what's going on:

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/

HeinzK

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
    • ZwiAner
    • Email
Re: 2.6.2 to 3.0 WSAPI
« Reply #21 on: February 26, 2025, 10:24:59 am »
... I use SFML via LIB and INCLUDE, so I have no access to miniaudio.cpp.
... the current programming with SFML is a Hoppy project to which I have only limited access at the moment.
... since everything works despite the warning, I'm happy with it at the moment.
... thanks for the information and the help.
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!)