Libgdx: LWJGL2 OpenALMusic - Unable to allocate audio buffers. AL Error: 40963

Created on 20 Jul 2018  路  3Comments  路  Source: libgdx/libgdx

Issue details

This is a really elusive bug to reproduce. From the crash reports I receive from players, it crops up randomly if one does pause(), setPosition(), play() or dispose() repeatedly. I'm not sure if its hardware related or due to some timing issue. While I could reproduce it consistently with a code similar to #5316 , I'm pretty sure it is not related.

Reproduction steps/code

Just the render() of an empty ApplicationListener:

            Music music = null;

            @Override
            public void render() {
                int frameNumber = (int)Gdx.graphics.getFrameId();
                Gdx.app.log("CRASH", "Frame " + frameNumber);
                switch (frameNumber) {
                    case 0:
                        // Frame 1
                        music = Gdx.audio.newMusic(Gdx.files.external("any_audio_file.ogg"));
                        music.play();
                        break;

                    case 1:
                        // Frame 2
                        music.setPosition(26.300f);     // must be within at least 200ms from the end
                        break;

                    case 2:
                        // Frame 3
                        music.setPosition(26.300f);     // must be within at least 200ms from the end
                        break;

                    case 3:
                        // Frame 4
                        music.dispose();
                        break;

                    case 4:
                        // Frame 5
                        music = Gdx.audio.newMusic(Gdx.files.external("any_audio_file.ogg"));
                        music.play();       // Crashes here
                        break;
                }
            }

Version of LibGDX and/or relevant dependencies

1.9.9-SNAPSHOT

Stacktrace

com.badlogic.gdx.utils.GdxRuntimeException: Unable to allocate audio buffers. AL Error: 40963
    at com.badlogic.gdx.backends.lwjgl.audio.OpenALMusic.play(OpenALMusic.java:83)
    at game27.DesktopMain$2.render(DesktopMain.java:270)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:225)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:126)

Please select the affected platforms

  • [ ] Android
  • [ ] iOS (robovm)
  • [ ] iOS (MOE)
  • [ ] HTML/GWT
  • [X] Windows
  • [ ] Linux
  • [ ] MacOS
audio desktop

Most helpful comment

i'm able to reproduce with the libgdx MusicTest.

First case :

  • run WAV example with looping disabled
  • play with the cursor back and forth several times
  • let the song finish
  • you can't start the song (it fails silently)

Second case :

  • run WAV example with looping disabled
  • play with the cursor back and forth several times
  • change the music (mp3 or ogg) before it finish
  • it crashes : Unable to allocate audio buffers. AL Error: 40963

libgdx code properly unqueue buffers but as per OpenAL doc : The unqueue operation will only take place if all n buffers can be removed from the queue. maybe OpenAL can't cancel some running buffers which lead to a kind of accumultation due to allocation/free frequency.

Maybe those kind of use are extreme and maybe Sound should be used instead.

All 3 comments

i'm able to reproduce with the libgdx MusicTest.

First case :

  • run WAV example with looping disabled
  • play with the cursor back and forth several times
  • let the song finish
  • you can't start the song (it fails silently)

Second case :

  • run WAV example with looping disabled
  • play with the cursor back and forth several times
  • change the music (mp3 or ogg) before it finish
  • it crashes : Unable to allocate audio buffers. AL Error: 40963

libgdx code properly unqueue buffers but as per OpenAL doc : The unqueue operation will only take place if all n buffers can be removed from the queue. maybe OpenAL can't cancel some running buffers which lead to a kind of accumultation due to allocation/free frequency.

Maybe those kind of use are extreme and maybe Sound should be used instead.

I have the exact same error on Windows :( - Any news on this ?

Scenario:

  • Playing Music one
  • Player selects some action
  • Stopping Music one
  • Start Music two
  • Crash with Unable to allocate audio buffers. AL Error: 40963

Also happens with LWJGL3, haven't found a solution thus far.

Was this page helpful?
0 / 5 - 0 ratings