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

Author Topic: An internal OpenAL call failed in SoundBuffer.cpp  (Read 3580 times)

0 Members and 1 Guest are viewing this topic.

smguyk

  • Jr. Member
  • **
  • Posts: 79
    • View Profile
An internal OpenAL call failed in SoundBuffer.cpp
« on: November 30, 2013, 03:03:55 pm »
An internal OpenAL call failed in SoundBuffer.cpp: AL_INVALID_OPERATION, the specified operation is not allowed in the current state

I get 2 of these error messages in the console after the application exits, but while it's running there are no errors and everything is working. I have read about this error message but the posted code doesn't match mine, so I don't know how to fix it. I'm only using sounds right now, no music.

I'll post the complete code that I'm using:

soundsystem.h:

soundsystem.cpp:

resources.h:

resources.cpp:

That's the entire code. Could someone please help me?

I really don't see what's wrong and why the error shows up after I exit the app.

I would appreciate any help! Thanks!
« Last Edit: December 03, 2013, 08:47:50 pm by smguyk »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: An internal OpenAL call failed in SoundBuffer.cpp
« Reply #1 on: November 30, 2013, 03:14:26 pm »
Why is everything static? That's surely a bad idea. In general, don't make things global/static, it will only cause trouble and is not necessary if you design the code well. It's well possible that the error is related to this (e.g. the sound is destroyed after OpenAL is cleaned up). Just give objects a clear ownership and lifetime, and don't use a single static or global variable.

And why don't you use a dynamic data structure, such as std::queue, to store the sounds? A fixed size array is an unnecessary limitation (and even then, you should prefer std::array).

By the way, the code tags you had initially (the C++ ones) were better. Please edit back...
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

smguyk

  • Jr. Member
  • **
  • Posts: 79
    • View Profile
Re: An internal OpenAL call failed in SoundBuffer.cpp
« Reply #2 on: November 30, 2013, 03:37:01 pm »
All of what you pointed out and suggested is true and I agree completely with it - my code is pretty flawed! However, I am too much of a beginner to port and refract all that code.

I already searched for existing sound/resource systems but haven't found one that I can switch my own code with. (I just need a really simple one that can also preload all of my sounds).

I also changed the code tags back to C++ ones, but now the post is considerably longer ;)

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: An internal OpenAL call failed in SoundBuffer.cpp
« Reply #3 on: November 30, 2013, 03:44:24 pm »
However, I am too much of a beginner to port and refract all that code.
It's not that difficult. Remove all the statics and use normal member variables. Then create a SoundSystem object, as a member of another class.

I already searched for existing sound/resource systems but haven't found one that I can switch my own code with. (I just need a really simple one that can also preload all of my sounds).
You can have a look at the SoundPlayer and MusicPlayer classes we have developed for the SFML book. Here is the code repository, search the Include and Source subdirectories.

I also plan to integrate these features into my library Thor, so they would be ready-to-use, ideally in a straightforward way :)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

smguyk

  • Jr. Member
  • **
  • Posts: 79
    • View Profile
Re: An internal OpenAL call failed in SoundBuffer.cpp
« Reply #4 on: November 30, 2013, 03:53:42 pm »
Thank you, I will certainly have a look at that!