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

Author Topic: Unhandled Exception Openal32.dll  (Read 12779 times)

0 Members and 2 Guests are viewing this topic.

Xenotater

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Unhandled Exception Openal32.dll
« on: May 22, 2017, 07:43:36 pm »
I just began working with SFML in my C++ intro class, so I apologize if I'm being a bit dumb here. However, I recently made a simple game and wanted to include some background music and a short clip to play. The sounds play perfectly fine and function exactly as I'd like them to. However, after about 7 minutes (give or take) of runtime, my program crashes. The error says something about an unhandled exception by openal32.dll (which I know handles the audio) and something about an access violation.
Quote
Unhandled exception at 0x00007FFF9B7AB20E (openal32.dll) in <PROGRAM_NAME>.exe: 0xC0000005: Access violation reading location 0x00007A3C0000E684.
I'm pretty sure I'm not destroying the buffer or anything simple like that, but I'd like some help with this if possible. Here's the portion of my code that's playing audio:

Quote
SoundBuffer buffer;
   buffer.loadFromFile("Clip.ogg");
   Sound clip;
   clip.setBuffer(buffer);

   Music music;
   music.openFromFile("Music.ogg");
   music.setVolume(10);
   music.setLoop(true);
   music.play();

   while (window.isOpen())
   {
      menu(window, inGame, asX, ai, aiDifficulty);
      if (ai)
      {
         clip.play();
      }

That's all I believe is necessary, but let me know if more is needed. I'd appreciate some help if possible so I can make this program reliable, thanks.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
Re: Unhandled Exception Openal32.dll
« Reply #1 on: May 23, 2017, 12:10:32 pm »
Did you use the OpenAL32.dll provided by SFML or did you randomly (and dangerously) download one form the internet?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Xenotater

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Re: Unhandled Exception Openal32.dll
« Reply #2 on: May 23, 2017, 02:51:50 pm »
Nonono, I know not to go around downloading dll files. I used the one provided in SFML's bin folder.  :P

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
Re: Unhandled Exception Openal32.dll
« Reply #3 on: May 23, 2017, 04:48:51 pm »
What SFML version are you running?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Xenotater

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Re: Unhandled Exception Openal32.dll
« Reply #4 on: May 23, 2017, 09:34:03 pm »
SFML 2.4.2 for Visual Studio.
« Last Edit: May 23, 2017, 09:40:32 pm by Xenotater »

Melcx

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: Unhandled Exception Openal32.dll
« Reply #5 on: June 05, 2017, 04:48:59 pm »
Similar problem here, same version, 2.4.2 on vs2015 : "Exception thrown at 0x0F8843E9 (openal32.dll) in NOOT.exe: 0xC0000005: Access violation reading location 0x00000000."
I'm making a game with some music layers played synchronously and some sound effects. I'm crashing randomly around 7 minutes too (almost every time). I tried to disable sound effects and music but it keeps crashing, it seems to come from the OpenAL thead.
The game thread isn't directly involved since the crash happen randomly during drawing, logic updates...
I tried with various OpenAL32.dll (including the one of the SMFL SDK), running in Debug or Release, with static and dynamic linking, only tested with SFML 2.4.2, 32bits only.
« Last Edit: June 05, 2017, 05:35:31 pm by Melcx »

Xenotater

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Re: Unhandled Exception Openal32.dll
« Reply #6 on: June 06, 2017, 03:31:23 am »
For some reason the issue has resolved itself for me, I'm not sure why as I changed absolutely nothing. I'm thankful that it's working now, but I'd really like to know why this happened so I can avoid it happening in the future, particularly since I plan to start a much bigger project soon that will require OpenAL. Thanks for your help.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
Re: Unhandled Exception Openal32.dll
« Reply #7 on: June 06, 2017, 11:31:27 am »
OpenAL has been working fine for a long time, so I can't really explain random crashes like that.
My first guess would be either a driver issue (reboot might fix it already) or wrong usage of OpenAL (e.g. global object), including using the wrong dll.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Melcx

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: Unhandled Exception Openal32.dll
« Reply #8 on: June 06, 2017, 01:23:10 pm »
I think so, or maybe a wrong pointer somewhere of my program (but it's always the same error, so it's not that random). My program doesn't directly use OpenAL, i'm only using it trough SFML (sf::Music, sf::Sound).
I changed to vs2012 : with this other OpenAL dll, I have the same symptom (error in OpenAL thread around 5-7min), but the error is different : Exception thrown at 0x6FA12B69 (MMDevAPI.dll) in NOOT.exe: 0xC0000005: Access violation writing location 0x746E6973.
Maybe an OpenAL dependency is involved ?

Anyway, i'll try to update the audio pilot, restarting it...
« Last Edit: June 06, 2017, 01:28:59 pm by Melcx »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
Re: Unhandled Exception Openal32.dll
« Reply #9 on: June 06, 2017, 01:44:46 pm »
If it crashes in MMDevAPI.dll which seems to be a Microsoft audio lib, then it really seems like some driver issue.
Newer Windows versions now install a lot of "basic" drivers that will get your system up and running, but these drivers are sometimes not the right fit for your soundcrad, so make sure you install the driver of your soundcard's vendor and make sure that it's up to date.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Melcx

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: Unhandled Exception Openal32.dll
« Reply #10 on: June 07, 2017, 11:28:57 am »
I updated my driver (by the Realtek website), changed the PC, but nothing changed. It must have something to do with my code.

I tried to disable any SFML dependency gradually. The error never happen if I don't instanciate any sf::Sound classes. But my LoopingMusic class doesn't induce any error : it's based on a LoopingMusic class I found on Github, inherit from SoundStream, there are 4 of these playing at the same time (I'm experimenting things with music layers xD).

THEN it must come from my using of sf::Sound.
It's  pretty sound intensive game with a lot of shooting, explosions, so I thought it was a good idea to prepare 8 layers of sounds, empty at start, that will be filled with previously loaded buffers and played when needed (32 different sounds).
If I simply load the SoundBuffer in memory, no crash, But if I have some prepared sound that plays nothing, here come the crash.
Here is a minimal code (way simpler than the real one) :
class SoundManager {
        sf::Sound soundLayers[NOOT_SOUNDLAYERS_COUNT];//"preparing" the layers, when I comment this line, no more crash
        vector<sf::SoundBuffer> loadedSounds;

        void PlaySound(int sound_id) {
                for (int i=0;i<NOOT_SOUNDLAYERS_COUNT;i++) {
                        sf::Sound* sfsound=&soundLayers[i];

                        if (sfsound->getStatus()!=sf::Sound::Playing) {//if the layer isn't used
                                sfsound->setBuffer(*loadedSounds[sound_id]->buffer);
                                sfsound->play();
                        }
                }
        }
}
 

Is it a bad practice to keep empty sound that just wait to be filled and played ? Or may I instanciate them when needed then release them when they are Stopped ?

KorolBoxta

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Unhandled Exception Openal32.dll
« Reply #11 on: June 07, 2017, 11:35:59 am »
I have the same issue as this. It occurs on my Win10 Dell XPS 9560 (All drivers up to date @ time of post).

When I run the same game on another Win10 Desktop my wife owns the issue does not occur.

This seems to indicate the issue is with a driver/audio card root cause and/or how the underlying openal code interfaces with it.

To cover a few things I've done on my XPS (still get a console warning and crash with all the following cases):
1. Static and Dynamic setups tested
2. X86 and X64 builds tested
3. sf::Music objects created and used in the same class(different functions)
3. sf::Music objects created and used in the same code block
4. Filename and SoundBuffer patterns used

The issue is best identified by the console output warning at runtime:
AL lib: (EE) MMDevApiMsgProc: Unexpected message: 49403

This warning occurs when a sf::Music object is created. The object can be used as expected (played, stopped etc.) until the crash occurs (3-5mins).

I've not yet used sf::Sound but will update if I get the same issues when I do.

Melcx

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: Unhandled Exception Openal32.dll
« Reply #12 on: June 07, 2017, 12:33:18 pm »
Okay that's strange, now it crashes regardless of the instancing of sf::Sound (it crashes even with the "sf::Sound soundLayers[NOOT_SOUNDLAYERS_COUNT];" line commented) or loading the SoundBuffers. It only seem to reduce the crash probability.

The crash always happen at more than 320 seconds on my PCs. I don't have any console warning.
There is two openal.dll threads, is it normal ?

Maybe it's related to the memory used by my program:
The resource monitor says it's using 1093 Mb commited memory, 277 to 1077Mb Working Set, 19Mb Shared, 1058Mb Shared.
I'm not really sure of the meaning of that, does that mean my program is using more than 3Gb ? Or at least 1093Mb ?

I'm going to test it with less memory used, 64bit build, then with previous SFML version.
« Last Edit: June 07, 2017, 12:36:08 pm by Melcx »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
Re: Unhandled Exception Openal32.dll
« Reply #13 on: June 07, 2017, 12:40:05 pm »
If it crashes in OpenAL Soft, the best next step would be to test the latest​ version of OpenAL soft by building it from source and rebuilding SFML with those.
If that still crashes then get the debug version of OpenAL soft to get a meaningful stack trace.

Unless it can be shown that SFML is doing something wrong that causes the crash in the MMDevAPI lib, there's probably not much we can do.
Maybe an updated OpenAL soft will already do the trick?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Melcx

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: Unhandled Exception Openal32.dll
« Reply #14 on: June 07, 2017, 01:47:23 pm »
Okay, I tried with this implementation : http://kcat.strangesoft.net/openal.html (openal-soft-1.18.0)
Just renamed their compilated soft_oal.dll to openal32.dll, aaand...

No more crashes :D thanks a lot !!!

Is there some performance implication using this ? Do you prefer some other implementation ?