OpenAL : alGenSources() problem

Started by
10 comments, last by weasalmongler 21 years, 9 months ago
Hi. I know that most people don''t use OpenAL but I''m hoping some people may know the problem that I am having. Please don''t say "Use FMOD", I''m trying to learn a range of API''s to find out what I like best before sticking to one. I''m making a game where I want a different sound source for each unit, so that it can make noises that originate from the unit. Problem is, I have about 40 units, each containing its own sounds, and each time I load a sound I generate a new source and attach the sound buffer to it. The first few sources are generated fine, but after I have generated a few, it stops generating them, and I get errors. Is there a limit to the number of sources that I can create or something? Thanks for any help. - Weasalmongler
Advertisement
What error(s) do you get back from alGetError? This doesn''t sound normal. I''m digging through the OpenAL source code looking for a cause, but it''s difficult without knowing exactly what error message I''m looking for.

alGenSources(1, &temp->source)

returns : "Invalid Value" as a "alGetError()" message.

- Weasalmongler

[EDIT : Then I get an "Invalid Name" error when binding the buffer to the source, but that is obviously because alGenSources fails and "temp->source" is invalid]

[edited by - weasalmongler on July 3, 2002 5:14:57 AM]
Well, I wasn''t finding any potential issues in the source code, then I figured you''re probably using Windows, so I should look in the Windows OpenAL source code . Here''s what I found:
AL_INVALID_VALUE can be flagged:
  • If you request more than are available through whatever internal device OpenAL is using (this check isn''t needed in the Linux code, so I didn''t see it). This is probably your problem.
  • If there''s an internal out of memory error (I''m not sure why they''d do INVALID_VALUE for this?).

    I didn''t know there was a maximum number of sources until I looked into this . Here''s what I''ve found out: The maximum number of sources is apparently limited to 32 in Windows (only) because of some limit with DirectX 8. Look in openal/win/Alc/ALc.c to get a better understanding of this (search for "MaxNoOfSources", you''ll see what I mean). I may have to contact the developers in inquery about this issue, actually...

  • Actually weasalmongler, i have exactly the same problem as you do.., but i generate about 15/20 sounds.
    I tought the problem was mine, but now i see the problem is OpenAL itselft.,
    Null And Void, if a card as for example 8 hardware channels, does this means we will only be able to generate 8 sources ?
    Isn''t OpenAL able to use Software mode when there''s no more hardware channels available ?
    Thanks,

    Bruno
    Oh well, unless anyone knows a way around this then I''ll look into FMOD.
    Anyone know a way around it that they are willing to share?

    - Weasalmongler
    Actually, you will have the same problem with FMOD
    After some samples, he won''t load them anymore.
    I''m not sure how to handle this....,
    Anyone has any ideias ?

    Bruno
    Bruno, look at the source code that I referenced above if you want the ''whole story''. Basically, this is what it does:
  • If you select DirectSound3D for the device:

    • If DirectSound3D supports more than 31 sources, OpenAL assumes it''s lying and clamps it to 31.
    • If DirectSound3D supports less than or equal to 15 sources, OpenAL falls back on software mode, but allows you to use 16 devices.

  • If you select DirectSound, you automatically get 32 sources.
  • If you select WaveOut, you automatically get 32 sources.

    I think this is a serious annoyance, and today I''ll try to look into the reasoning behind this further (mainly because the ports of OpenAL don''t have this issue, as far as I can tell).

  • Hey NULL, do you have something to do with the ports to windows ? This problem is non-existent in Linux ?
    Are you on the OpenAL team ?


    quote:Original post by Bruno
    Hey NULL, do you have something to do with the ports to windows?

    Nope.
    quote:Original post by Bruno
    This problem is non-existent in Linux ?

    There is no check in the allocation of sources in Linux, but I haven''t actually ''stress tested'' the implementation. So, as far as I know, this problem is non-existent in Linux. I''m working on getting the official state of this issue (i.e. no plans to fix it, what OS''s it affects, et cetera).
    quote:Original post by Bruno
    Are you on the OpenAL team?

    Nope.

    This topic is closed to new replies.

    Advertisement