SFML community forums
Help => Audio => Topic started by: Visor 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:
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:
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:
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 ?
-
I suppose it could depend on what an "sSoundManager" object is and also how it behaves when it is deleted.
-
Sorry, I forfot to show the struct:
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.
-
What's your OS?
-
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.
-
How large are your 100 sounds that you load?
-
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.
-
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 !