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

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

0 Members and 2 Guests are viewing this topic.

smguyk

  • Jr. Member
  • **
  • Posts: 79
    • View Profile
Hi,

I get this error message (in fact, 3 same messages) in the Windows console after closing the window:

Code: [Select]
An internal OpenAL call failed in SoundBuffer.cpp (75) : AL_INVALID_OPERATION, the specified operation is not allowed in the current state
and the program also crashes ("the program has stopped working" window) with the following details:

Code: [Select]
Problem signature:
  Problem Event Name: APPCRASH
  Application Name: Mastermind.exe
  Application Version: 0.1.3.2
  Application Timestamp: 530db220
  Fault Module Name: MSVCP110D.dll
  Fault Module Version: 11.0.51106.1
  Fault Module Timestamp: 50988588
  Exception Code: c0000005
  Exception Offset: 0000f069
  OS Version: 6.1.7601.2.1.0.256.48

Everything in my program is working. Audio and everything else is fine but after closing the program it crashes.

I don't know what code to post, so I'll just post the sound system stuff:

soundsystem.h:

#ifndef __SOUNDSYSTEM_H__
#define __SOUNDSYSTEM_H__

#include <string>
#include <SFML/Audio.hpp>

class SoundSystem {

public:
  SoundSystem();
  virtual ~SoundSystem();

  void setAudioEnabled(bool status) { audioEnabled_ = status; };
  void setMenuSoundsEnabled(bool status) { menuSoundsEnabled_ = status; };
  void setGameSoundsEnabled(bool status) { gameSoundsEnabled_ = status; };
  void forceDisabledAudio() { disabledAudioForced_ = true; };

  bool audioEnabled() const { return audioEnabled_; };
  bool menuSoundsEnabled() const { return menuSoundsEnabled_; };
  bool gameSoundsEnabled() const { return gameSoundsEnabled_; };
  unsigned int getSoundVolume() const { return soundsVolume_; };
  bool disabledAudioForced() const { return disabledAudioForced_; };

  void playSound(const std::string &soundName);
  void setSoundsVolume(unsigned int volume);
  void stopAll();

private:
  int maximumSounds_;
  sf::Sound sounds_[30];
  bool audioEnabled_;
  bool menuSoundsEnabled_;
  bool gameSoundsEnabled_;
  unsigned int soundsVolume_;
  int lastSoundPlayed_;
  bool disabledAudioForced_;

};

#endif

soundsystem.cpp:

#include "soundsystem.h"
#include "config.h"
#include "resources.h"

SoundSystem::SoundSystem() :
  maximumSounds_(30),
  audioEnabled_(true),
  menuSoundsEnabled_(true),
  gameSoundsEnabled_(true),
  soundsVolume_(50),
  lastSoundPlayed_(0),
  disabledAudioForced_(false)
  {
}

SoundSystem::~SoundSystem() {
}

void SoundSystem::playSound(const std::string &soundName) {
  if (audioEnabled_) {
    if (lastSoundPlayed_ == maximumSounds_) {
      lastSoundPlayed_ = 0;
    }
    sf::Sound &sound = sounds_[lastSoundPlayed_];
    if (sound.getStatus() == sf::Sound::Playing) {
      sound.stop();
    }
    sound.setBuffer(resourceHolder.getSoundBuffer(soundName));
    sound.setPitch(1);
    sound.play();
    ++lastSoundPlayed_;
  }
}

void SoundSystem::setSoundsVolume(unsigned int volume) {
  if (volume > 100) {
    volume = 100;
  }
  soundsVolume_ = volume;
  for (int i = 0; i < maximumSounds_; ++i) {
    sounds_[i].setVolume((float)volume);
  }
}

void SoundSystem::stopAll() {
  for (int i = 0; i < maximumSounds_; ++i) {
    if (sounds_[i].getStatus() == sf::Sound::Playing) {
      sounds_[i].stop();
    }
  }
}

Before closing the window I call SoundSystem's stopAll() if that's relevant.

Could anyone please help me?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Does it also crash with a minimal example, i.e. no fancy class stuff but a simple main() with native SFML class instances?

Make sure you don't have another version of OpenAL installed somewhere on your system. Copy the OpenAL.dll from the SFML package next to your application.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

smguyk

  • Jr. Member
  • **
  • Posts: 79
    • View Profile
Does it also crash with a minimal example, i.e. no fancy class stuff but a simple main() with native SFML class instances?

Make sure you don't have another version of OpenAL installed somewhere on your system. Copy the OpenAL.dll from the SFML package next to your application.

libsndfile-1.dll and openal32.dll are both in the directory.

Actually I just created a new project to test it, and now it doesn't crash.

Damn... so the error is somewhere else. When I debug my original program:

Unhandled exception at 0x59C0F069 (msvcp110d.dll) in Mastermind.exe: 0xC0000005: Access violation reading location 0xFEEEFEEE.

This is the call stack:

Code: [Select]
msvcp110d.dll!std::locale::locale(const std::locale & _Right) Line 324 C++
  msvcp110d.dll!std::ios_base::getloc() Line 443 C++
  msvcp110d.dll!std::basic_ostream<char,std::char_traits<char> >::operator<<(unsigned int _Val) Line 327 C++
  Mastermind.exe!sf::priv::alCheckError(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned int) Unknown
  Mastermind.exe!sf::SoundBuffer::~SoundBuffer(void) Unknown
  Mastermind.exe!std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,sf::SoundBuffer>::~pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,sf::SoundBuffer>() C++
  Mastermind.exe!std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,sf::SoundBuffer>::`scalar deleting destructor'(unsigned int) C++
  Mastermind.exe!std::allocator<std::_Tree_node<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,sf::SoundBuffer>,void *> >::destroy<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,sf::SoundBuffer> >(std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,sf::SoundBuffer> * _Ptr) Line 624 C++
  Mastermind.exe!std::allocator_traits<std::allocator<std::_Tree_node<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,sf::SoundBuffer>,void *> > >::destroy<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,sf::SoundBuffer> >(std::allocator<std::_Tree_node<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,sf::SoundBuffer>,void *> > & _Al, std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,sf::SoundBuffer> * _Ptr) Line 758 C++
  Mastermind.exe!std::_Wrap_alloc<std::allocator<std::_Tree_node<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,sf::SoundBuffer>,void *> > >::destroy<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,sf::SoundBuffer> >(std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,sf::SoundBuffer> * _Ptr) Line 909 C++
  Mastermind.exe!std::_Tree<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,sf::SoundBuffer,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,sf::SoundBuffer> >,0> >::_Erase(std::_Tree_node<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,sf::SoundBuffer>,void *> * _Rootnode) Line 2069 C++
  Mastermind.exe!std::_Tree<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,sf::SoundBuffer,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,sf::SoundBuffer> >,0> >::_Erase(std::_Tree_node<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,sf::SoundBuffer>,void *> * _Rootnode) Line 2065 C++
  Mastermind.exe!std::_Tree<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,sf::SoundBuffer,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,sf::SoundBuffer> >,0> >::_Erase(std::_Tree_node<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,sf::SoundBuffer>,void *> * _Rootnode) Line 2065 C++
  Mastermind.exe!std::_Tree<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,sf::SoundBuffer,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,sf::SoundBuffer> >,0> >::clear() Line 1538 C++
  Mastermind.exe!std::_Tree<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,sf::SoundBuffer,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,sf::SoundBuffer> >,0> >::erase(std::_Tree_const_iterator<std::_Tree_val<std::_Tree_simple_types<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,sf::SoundBuffer> > > > _First, std::_Tree_const_iterator<std::_Tree_val<std::_Tree_simple_types<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,sf::SoundBuffer> > > > _Last) Line 1512 C++
  Mastermind.exe!std::_Tree<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,sf::SoundBuffer,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,sf::SoundBuffer> >,0> >::_Tidy() Line 2216 C++
  Mastermind.exe!std::_Tree<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,sf::SoundBuffer,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,sf::SoundBuffer> >,0> >::~_Tree<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,sf::SoundBuffer,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,sf::SoundBuffer> >,0> >() Line 1190 C++
  Mastermind.exe!std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,sf::SoundBuffer,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,sf::SoundBuffer> > >::~map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,sf::SoundBuffer,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,sf::SoundBuffer> > >() C++
  Mastermind.exe!Resources::~Resources() C++
  Mastermind.exe!`dynamic atexit destructor for 'resourceHolder''() C++
  msvcr110d.dll!doexit(int code, int quick, int retcaller) Line 585 C
  msvcr110d.dll!exit(int code) Line 395 C
  Mastermind.exe!__tmainCRTStartup() Line 549 C
  Mastermind.exe!mainCRTStartup() Line 377 C
  kernel32.dll!75ed336a() Unknown
  [Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]
  ntdll.dll!77969f72() Unknown
  ntdll.dll!77969f45() Unknown

Looks like I'm fucked :(

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Cool stack trace, but with a complete and minimal code example that reproduces the error, it's impossible to tell what's going on. ;D

Do you use static/global variables?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

smguyk

  • Jr. Member
  • **
  • Posts: 79
    • View Profile
Okay first off let me just thank you for helping me!

Cool stack trace, but with a complete and minimal code example that reproduces the error, it's impossible to tell what's going on. ;D

Well yeah, but unfortunately the test program I just made doesn't crash and posting my original project isn't really a good idea because I have a whole lot of code lines spread across 40+ files.

I'll see if I can reproduce the errors and crash with a minimal example but I'm not that optimistic. I'll try my best!

Do you use static/global variables?

I'm not using global or static variabales at all except for one static variable

static Resources resourceHolder;

declared in config.h. It hasn't produced any errors earlier though. Hm...

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
I'm not using global or static variabales at all except for one static variable

static Resources resourceHolder;

declared in config.h. It hasn't produced any errors earlier though. Hm...
One is enough when it is the class that manages the resources. There are enough topics floating around why static and global variables should never be used with SFML resources and nearly never in any other situation.
Think of a better design that doesn't require you to make things globally available. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything