Error generating lots of Sources

I’m trying to load and play many sources. Everything runs fine until I hit sound #30. Trying to generate Source #30 (and all subsequent Sources) throws this error:

Here’s what I’m getting:
Error Code = 40963
AL_INVALID_VALUE

and I’m calling this method each time:
al.alGenSources(1, source.sourceId);

My question is, can I query the device/context to see how many sounds it supports? Maybe I’m going over my limit (shouldn’t be though). Any ideas? I can’t find anything in the docs/api.

Okay, I just ran the SourcesSharingBuffers.java demo and it does the exact same thing.

So then I tried calling alDeleteSources() before calling alGenSources() again, to see if that would fix the problem, but it STILL broke on the 30th sound.

What’s the proper way to delete/release and/or reuse Sources?

okay, i know what i need to do. i found this in another thread:

  1. Generate about 16 sources in an array.
  2. Create an array of bool values to track which one is in use and which are free.
  3. When you want to play a buffer, a sound, find a location using the bool lookup array. Send the buffer to that source.
  4. Once every so often, every frame if you want, check the state of each source. Any state that reports a stopped state, set the bool flag in the array to 0 so you know that you can use it again.

here’s my problem: i have no idea how to bind/rebing a source to a buffer. i don’t see anything in the api that will bind an existing source to a different buffer for reuse. anyone?

I don’t see the problem you’re seeing wtih the SourcesSharingBuffers demo. What is the device name reported by that demo? Using the “Generic Software” driver and the OpenAL 1.1 binaries from openal.org I was easily able to add 100+ water drops without any errors being reported from alGenSources. I don’t know whether there might be a bug in the glue code for the version of JOAL you’re using but I’m using the gluegen-branch-1-0 branch in which all of the JNI code, etc. has been rewritten. If you would like me to post a test binary for you to try let me know which platform you’re on.

I don’t see the problem you’re seeing wtih the SourcesSharingBuffers demo.

Well, I found other people with the same problem and there seems to be a definite limit to how many sources you can create, and they should be reused from what I can tell

What is the device name reported by that demo?

“Generic Hardware” - which isn’t good because I have a NICE sound card and cannot find out how to get an enumerated list of available devices or select one or what not. Here’s the code I’m using:

    ALC.Device device = null;
    ALC.Context context;
    String deviceSpecifier = null;
    String deviceName = "DirectSound3D";
    device = alc.alcOpenDevice(deviceName);
    deviceSpecifier = alc.alcGetString(device, ALC.ALC_DEVICE_SPECIFIER);
    context = alc.alcCreateContext(device, null);
    alc.alcMakeContextCurrent(context);

… I don’t like the idea of hard coding “DirectSound3D”, but when I do this: device = alc.alcOpenDevice(null) I get a NullPointerException, which I shouldn’t be getting, or at least OpenAL won’t blow up on that call (from what I can tell).

Using the “Generic Software” driver and the OpenAL 1.1 binaries from openal.org I was easily able to add 100+ water drops without any errors being reported from alGenSources. I don’t know whether there might be a bug in the glue code for the version of JOAL you’re using but I’m using the gluegen-branch-1-0 branch in which all of the JNI code, etc. has been rewritten. If you would like me to post a test binary for you to try let me know which platform you’re on.

Well, again, I think all I need to know is how to attach a source to a buffer (without using al.alGenSources()). That and how do I get a list of available devices?

But any help is greatly appreciated.

WinXP
Intel P4 3gHz
1GB RAM
Creative 5.1 Soundcard

I don’t have any confidence in the current JOAL binaries that are out there. Could you please try upgrading to these?

http://www.rawbw.com/~kbrussel/joaltmp/joal.jar
http://www.rawbw.com/~kbrussel/joaltmp/joal_native.dll
http://www.rawbw.com/~kbrussel/joaltmp/javadoc_public.zip
http://www.rawbw.com/~kbrussel/joaltmp/joal-demos.jar

These are current Windows binaries from the gluegen-branch-1-0 branch of the JOAL tree. I have high confidence that the native code is correct and that calls like alcOpenDevice(null) should work fine. The public APIs have changed somewhat from the current JOAL out there but on the whole your application shouldn’t require much modification (addition of offset parameters when passing down arrays, ALC.Device and ALC.Context promoted to top-level data types, and some other changes). Please try these and let me know if the behavior is any different / better or whether the problems you’re seeing are still present.

Thanks for all your help. I finally got the code working, whew! I’m reusing the sources and simply binding them to new buffers as needed, and pooling my resources of course. But I’m still using the old jar/dll for now. I just don’t feel like changing the code now that it works. ;D

If you have the time at some point to do a test with just the demos.devmaster.lesson5.SourcesSharingBuffers demo from the binaries I sent you, I would be interested to know whether the new JOAL behaves any differently or better than the version you’re currently using.