How to enumerate available sound-renderers

Started by Skippy0, May 01, 2005, 10:04:54

Previous topic - Next topic

Skippy0

OpenGL can enumerate DisplayModes,
OpenAL can't enumerate sound-renderers?

Hardcoding in AL.create(String, int, int, boolean) isn't really a
solution and usually ends up targeting the software-driver on
every system, except the dev's.

I might have missed something... maybe :wink:

Sormuras

Hej Skippy0,

the enumeration of available sound devices(renderers) is switched off by the current implementation on LWJGL. That is because the ALC.alcGetString(int i) always uses the current device. Here's line 167 from ALC.java:
String result = nalcGetString(AL.device.device, pname);


If one could pass 0 as the first parameter, the returned value would be the enumeration encoded in one string. Here's some C code from SDK (aldlist.cpp from the Framework sample):
char *devices;
devices = (char *)ALFunction.alcGetString(NULL,ALC_DEVICE_SPECIFIER);
// go through device list (each device terminated with a single NULL, list terminated with double NULL)
while (*devices != NULL) {
  ALCdevice *device = ALFunction.alcOpenDevice(devices);
  if (device) {
    ALFunction.alcMakeContextCurrent(context);
    // if new actual device name isn't already in the list, then add it...
    actualDeviceName = ALFunction.alcGetString(device, ALC_DEVICE_SPECIFIER);
    ...
  }
  ...
}


You didn't miss something, LWJGL is missing something. :)

Cheers,
Sormuras


Edit: Fixed typos and added more source details.

Matzon

the problem is that we can't support the function in an exact context, since they implemented it in a hack'ish way.

They seperate the different suppliers by using \0 as the seperator (usually the end of string seperator). So if you call the fucntion you will always only get the first supplier back.
The only way to fix this - which no one has needed before - is to create an entirely new lwjgl-specific OpenAL method that returns the implementers as an array of strings...

Sormuras

Hi Matzon!

Yes, the way "they" return the list is ... c-stylish. That's a good example why I prefer hacking in Java. :)

On topic. At least Skippy0 and me need that enumration. And to add another analogy next to the one with GLs display modes, take the java.io package that enumerates all NICs - because sometimes, you want the end-user of your application to choose the screen resolution, the NIC(IP address) to bind a service to and regarding OpenAL, you want to offer all available sound devices.

+1 for enumerating all sound device names in a clean String[] like you suggested.

Evil-Devil

That would be really cool to have that implemented.

I have a onBoard Sound additional to my SB Live! and like to have the possibility to change the device that is used for sound playback.

Sormuras

Counting all - non ever needed this - we have a +3... :)

Matzon

I am on it - already comitted to cvs - just looking into rewriting it a bit to use less native code.

new method is String[] AL.getImplementations()

Sormuras

Quote from: "Matzon"new method is String[] AL.getImplementations()

Danke!  :D