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

Author Topic: [SOLVED] OpenAL error (AL_OUT_OF_MEMORY)  (Read 5507 times)

0 Members and 1 Guest are viewing this topic.

Visor

  • Newbie
  • *
  • Posts: 21
    • View Profile
[SOLVED] OpenAL error (AL_OUT_OF_MEMORY)
« on: April 13, 2017, 03:56:08 pm »
Hello,

I get an AL error, but I have no idea what I did wrong in my code. I really don't think it's a memory problem, I have RAM 16 GB and create new sounds only if there are less than 100 sounds in the vector (I read that it can works until 256).

The first error I get is:
Quote
An internal OpenAL call failed in SoundSource.cpp(37).
Expression:
   alGenSources(1, &m_source)
Error description:
   AL_OUT_OF_MEMORY
   There is not enough memory left to execute the command.

And then, every new sound created implies this error:
Quote
An internal OpenAL call failed in SoundSource.cpp(37).
Expression:
   alSourcei(m_source, AL_BUFFER, 0)
Error description:
   AL_INVALID_NAME
   A bad name (ID) has been specified.

It's probably because of my sound manager, so here is it:
Quote

for (std::vector<sSoundManager*>::iterator iteratorSounds = m_soundManager.begin(); iteratorSounds != m_soundManager.end() ; )
   {   
      if ((*iteratorSounds)->m_bPlayed == false // Play the sound if not played yet
         && (*iteratorSounds)->m_iTimeDelay <= 0)
      {
         (*iteratorSounds)->m_bPlayed = true;
         (*iteratorSounds)->m_sound.play();
         iteratorSounds++;
      }
      else if ((*iteratorSounds)->m_bPlayed == true // Purge played sounds
         && ((*iteratorSounds)->m_sound.getStatus() == sf::Sound::Status::Stopped
         || ((*iteratorSounds)->m_bTimeToLive_enabled && (*iteratorSounds)->m_iTimeToLive <= 0)))
      {
         if ((*iteratorSounds)->m_sound.getStatus() != sf::Sound::Status::Stopped)
            (*iteratorSounds)->m_sound.stop();

         delete(*iteratorSounds);
         iteratorSounds = m_soundManager.erase(iteratorSounds);
      }
      else // Processing sounds
      {
         (*iteratorSounds)->m_iTimeDelay -= m_DeltaTime;

         if ((*iteratorSounds)->m_bTimeToLive_enabled
            && (*iteratorSounds)->m_iTimeDelay <= 0)
            (*iteratorSounds)->m_iTimeToLive -= m_DeltaTime;

         iteratorSounds++;
      }
}

I saw that "erase.()" deletes the element when it want (not instantly)... But I don't think it can be the problem.

Do anybody have an idea where the problem can be ?
« Last Edit: April 21, 2017, 03:12:23 pm by Bloo »

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: OpenAL error (AL_OUT_OF_MEMORY)
« Reply #1 on: April 13, 2017, 09:27:22 pm »
I suppose it could depend on what an "sSoundManager" object is and also how it behaves when it is deleted.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Visor

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: OpenAL error (AL_OUT_OF_MEMORY)
« Reply #2 on: April 13, 2017, 09:39:23 pm »
Sorry, I forfot to show the struct:

Quote

struct sSoundManager
{
public:
   sf::Sound m_sound;
   sf::Vector2f m_position;
   bool m_bPlayed;
   int m_iDistanceMin;
   int m_iDistanceMax;
   int m_iTimeToLive;
   int m_iTimeDelay;
   bool m_bTimeToLive_enabled;
   
   sSoundManager()
   {
      m_bPlayed = false;
      m_iTimeToLive = 0;
      m_iTimeDelay = 0;
      m_bTimeToLive_enabled = false;
   }
};

The sf::Sound is deleted with the *sSoundManager when calling m_soundManager.erase(iteratorSounds). Nothing strange according to me.
« Last Edit: April 13, 2017, 09:41:15 pm by Bloo »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: OpenAL error (AL_OUT_OF_MEMORY)
« Reply #3 on: April 13, 2017, 11:04:18 pm »
What's your OS?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Visor

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: OpenAL error (AL_OUT_OF_MEMORY)
« Reply #4 on: April 13, 2017, 11:49:27 pm »
Windows 8.1 (64bits), I build in 32bits.

Edit: I put the OpenAL.dll from SFML_2.4.2 zip in the app's executable folder.
« Last Edit: April 13, 2017, 11:55:16 pm by Bloo »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: OpenAL error (AL_OUT_OF_MEMORY)
« Reply #5 on: April 14, 2017, 11:15:51 pm »
How large are your 100 sounds that you load?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Visor

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: OpenAL error (AL_OUT_OF_MEMORY)
« Reply #6 on: April 15, 2017, 12:32:21 am »
Thank you for helping.

It's really depending on what's happening ingame, I can't really know.
I use a vector of sf::SoundBuffer with 24mb of flac loaded in at startup,
and I get the pointer I need to use it in the processing vector (the one with max 100 elements).

Most of the sounds are just alternatives (e.g multiples step sound), so I guess only the half are used at the same time in the <100 elem vector. One of them is pretty huge tho, ~10mb. All the others are less than 1mb.

Visor

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: OpenAL error (AL_OUT_OF_MEMORY)
« Reply #7 on: April 21, 2017, 03:12:12 pm »
Ok I think I found what was the real problem, it seems a sf::sound's pointer could have had an unexpected behavior depending on some cases.
Thank you again for trying to help !