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

Author Topic: AL_INVALID_OPERATION from SFML 2.3 Audio  (Read 11875 times)

0 Members and 1 Guest are viewing this topic.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
AL_INVALID_OPERATION from SFML 2.3 Audio
« on: June 25, 2015, 01:44:14 am »
The closest thing that I could find that already mentioned this error is this post but since the error I'm getting is in SFML 2.3 but not 2.2, I don't think that topic is relevant - barring the fact that it didn't seem that the problem in the thread had a solution.

The actual error I'm receiving is:
An internal OpenAL call failed in AudioDevice.cpp (157) : AL_INVALID_OPERATION, the specified operation is not allowed in the current state

#include <SFML/Audio.hpp>
int main()
{
        sf::Listener::setGlobalVolume(100.f);
        return EXIT_SUCCESS;
}
That code is enough for me to get the error. It doesn't get an error by instancing an sf::Sound object (like in this SFML Github issue that I visited to see if it was related) instead of using the Listener. In fact, after some extra tests while writing this, I found that of the setters in Listener, setGlobalVolume() and setPosition() causes the error but setDirection() and setUpVector() do not.

I've fully linked to 2.3 and it causes this error. I then fully linked to 2.2 and there is no error.
I then tried 2.3 with 2.2's Audio dll and the error disappears. 2.2 with 2.3's Audio dll brings it back.
Both versions of the SFML DLLs are the release versions.

Indeed, the reason I noticed this was because I linked my Faux Car project to 2.3 and it caused this error at the very beginning (when setting global volume) and then I had some weird destruction crash when main() closed. I've found the source of the crashing so they're not related as I originally considered. I addressed this first (the audio error) as it's the first error and I found it easy to reproduce with minimal code.


EDIT: This error is only appearing in debug mode, not release.
Windows 7 64-bit, VS Studio 2013, SFML 32-bit - dynamic and static both same result.
EDIT 2:
64-bit gives same result as 32-bit (debug, not release; both dynamic and static same result).
« Last Edit: June 25, 2015, 05:43:17 pm by Hapax »
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

dabbertorres

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • website/blog
Re: AL_INVALID_OPERATION from SFML 2.3 Audio
« Reply #1 on: June 25, 2015, 09:15:20 am »
I could not reproduce.

Windows 8.1 64-bit
VS 2013
SFML 32-bit.

I can try Linux tomorrow.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: AL_INVALID_OPERATION from SFML 2.3 Audio
« Reply #2 on: June 25, 2015, 03:27:39 pm »
Windows 8.1 64-bit
VS 2013
SFML 32-bit.
Did you try it in debug mode?

I can reproduce it in
Windows 8.1 x64
MinGW 5.1.0
SFML 2.3 x86 static
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

kitteh-warrior

  • Guest
Re: AL_INVALID_OPERATION from SFML 2.3 Audio
« Reply #3 on: June 25, 2015, 04:04:15 pm »
Cannot reproduce in debug mode.

Windows 7 Enterprise x64
MinGW 5.1.0
SFML 2.3 x64 dynamic

EDIT: I also tested SFML 2.3 x64 static on the same machine, still no issues.
« Last Edit: June 25, 2015, 04:55:24 pm by kitteh-warrior »

Rosme

  • Full Member
  • ***
  • Posts: 169
  • Proud member of the shoe club
    • View Profile
    • Code-Concept
Re: AL_INVALID_OPERATION from SFML 2.3 Audio
« Reply #4 on: June 25, 2015, 04:47:29 pm »
I have this issue only in Static Debug.

Windows 8.1 64-bit
VS 2012
SFML 2.3 x86 Static.
GitHub
Code Concept
Twitter
Rosme on IRC/Discord

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: AL_INVALID_OPERATION from SFML 2.3 Audio
« Reply #5 on: June 25, 2015, 05:17:58 pm »
Is it possible for you to confirm that the error was not present in 2.2?

Kitteh-warrior, can you test it in SFML 32-bit to see if you have a different result?

I will test my SFML 64-bit now...
...tested 64-bit and - for me - gives the same results as 32-bit (debug, not release; both dynamic and static same result).
I've modified the original post to include my 64-bit results.
« Last Edit: June 25, 2015, 05:32:05 pm by Hapax »
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

kitteh-warrior

  • Guest
Re: AL_INVALID_OPERATION from SFML 2.3 Audio
« Reply #6 on: June 25, 2015, 05:34:33 pm »
I tried with MinGW in 32-bit mode with SFML debug for both dynamic and release. Still no error.

Hapax, could you provide the compiled binary of the example that is causing a problem?

Edit: fixed the wording
« Last Edit: June 25, 2015, 05:41:25 pm by kitteh-warrior »

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: AL_INVALID_OPERATION from SFML 2.3 Audio
« Reply #7 on: June 25, 2015, 05:49:20 pm »
Hapax, could you provide the compiled binary of the example that is causing a problem?
Good idea.
Here's a static debug executable that causes the error (for me). openal32.dll is included (obviously).
http://www.mediafire.com/download/mqp1254xqfyveht/CausesAudioError.zip
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: AL_INVALID_OPERATION from SFML 2.3 Audio
« Reply #8 on: June 25, 2015, 05:54:22 pm »
Just found an odd 'solution'. It might not be odd to someone who knows why it works as it may be expected.

Basically, if you contruct an sf::Sound before setting the global volume of the listener, no error is given, thus:
#include <SFML/Audio.hpp>
int main()
{
        sf::Sound sound;
        sf::Listener::setGlobalVolume(100.f);

        return EXIT_SUCCESS;
}

That seems to work fine so at least it's a workaround for now.


p.s. actually, creating an sf::Sound, sf::SoundBuffer, or sf::Music object before the Listener line, clears the error.
« Last Edit: June 25, 2015, 05:56:12 pm by Hapax »
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

kitteh-warrior

  • Guest
Re: AL_INVALID_OPERATION from SFML 2.3 Audio
« Reply #9 on: June 25, 2015, 05:58:09 pm »
I tested your executable with the openal32.dll in the same directory, and it gave the same error that you were getting.
I moved the DLL to another directory (thinking that maybe the one in my system might not give the same error), and the error went away.

Try installing this into your system, and removing the previous DLL's: http://www.openal.org/creative-installers/oalinst.zip
This is what I just installed today to test your example.
« Last Edit: June 25, 2015, 06:01:55 pm by kitteh-warrior »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: AL_INVALID_OPERATION from SFML 2.3 Audio
« Reply #10 on: June 25, 2015, 06:20:43 pm »
No, don't do that!

SFML is written for OpenAL Soft and not for the outdated Creative version.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

kitteh-warrior

  • Guest
Re: AL_INVALID_OPERATION from SFML 2.3 Audio
« Reply #11 on: June 25, 2015, 06:33:58 pm »
SFML is written for OpenAL Soft and not for the outdated Creative version.

Opps, sorry. I forgot that it used OpenAL Soft, and when the error came up (of missing OpenAL32.dll), I just got the OpenGL Creation version. I downloaded OpenAL Soft, and placed the DLL in the correct location and the error is coming up as it did with Hapax and eXpl0it3r.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
AW: AL_INVALID_OPERATION from SFML 2.3 Audio
« Reply #12 on: June 25, 2015, 07:23:18 pm »
After all it's more or less just a warning and in a real application chances are probably rather low to run into this. Given the message I assume there's just something (OpenAL contex?) that needs to be "initialized" before one can use the function.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: AL_INVALID_OPERATION from SFML 2.3 Audio
« Reply #13 on: June 25, 2015, 08:00:10 pm »
It looks like the OpenAL device is not initialized. Earlier, there were function calls ensureALInit() to make OpenAL ready, but those were removed in this commit. The new architecture relies on the initialization of an AlResource object to trigger the initialization -- and sf::Listener bypasses that.

After all it's more or less just a warning and in a real application chances are probably rather low to run into this.
I think it's relatively common to set configuration values like volume before playing any sounds... I'm not sure if the user settings are applied correctly in that case.

I'll have a closer look.
[Edit] So far, I struggle to reproduce the problem...
« Last Edit: June 25, 2015, 09:12:05 pm by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: AL_INVALID_OPERATION from SFML 2.3 Audio
« Reply #14 on: June 25, 2015, 09:34:51 pm »
Okay, that's one sneaky bug :D

void AudioDevice::setGlobalVolume(float volume)
{
    if (audioContext)
        alCheck(alListenerf(AL_GAIN, volume * 0.01f));

    listenerVolume = volume;
}
In this code, the OpenAL call is executed even if audioContext is NULL.

How is this possible? alCheck() is not a function, but an macro that's implemented in a way how you should not implement macros:
#ifdef SFML_DEBUG
    #define alCheck(x) x; sf::priv::alCheckError(__FILE__, __LINE__);
#else
    #define alCheck(Func) (Func)
#endif
See? Two statements, and only the first is executed in an if-branch.
By the way, the conditional compilation also explains why it only happens in debug mode.

I'll fix it as soon as possible.
[Edit] Fix is available in the bugfix/alcheck_macro branch.

I would like to do something similar for glCheck(), because such macros are bloody time bombs. Unfortunately, there's a lot of client code that currently relies on these strange semantics :-\
« Last Edit: June 25, 2015, 09:41:38 pm by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: